Correct way of setting up auto deployment in VS2019 for a software WDM driver?

I have always used either the windbg attaching or VS attaching to debug my drivers, now I want to try out automatic deployment.

My goal:
Set up VS2019 in such a way that when I put a breakpoint on my driverEntry and press F5, visual studio automatically compile the driver and deploy it on the test machine, and create a service for the driver, attach to the target machine and start the service. And when I stop debugging, it should detach and stop the service and delete it.

I have already setup a target machine (using provisioning in the Configure devices → add device) and the required WDK components are already installed on the target machine. And this is a software WDM driver and I don’t have a INF to install it, I load it using sc create + start (similar to osrloader).

My question is:
What should I select in the project properties -> Driver install -> Deployment, considering that I don’t have a INF file?
Should I select Custom Command Line? Because I already tried that, but you can’t just give it a command line like "sc create ... & sc start ..", because based on msdn, it seems like we actually have to give it a “script file” name? I tried to also create a batch file that does the sc create + start and use additional Files to add that .bat file (so i can type this script file’s name in the custom command line box), but right clicking and selecting add file in additional files doesn’t work and nothing happens!!

So how can i set this up for my case? I also tried to select “Fast reinstall” and “Install/Reinstall And Verify” But i get weird errors which are probably related to the driver not having an INF file.

I encourage you to experiment with this and report your results, but you should know that many of the professionals on this list abandoned automatic deployment because it was so finicky.

@Tim_Roberts said:
I encourage you to experiment with this and report your results, but you should know that many of the professionals on this list abandoned automatic deployment because it was so finicky.

Sure, I will try to make it work in these few days and will report back the results to see if it’s worth it or not.

But two questions:

  1. What is the most popular approach that professional driver developers use to debug their drivers fast? Anyone here managed to implement something that basically you can put a breakpoint on your driver in Visual Studio, press F5 and starting debuging right away? Or do people usually manually copy the driver files to the test machine, attach windbg/VisualStudio to test machine, put deferred breakpoint on driverentry, and then load the driver manually using OsrLoader? Because the second approach involves a lot of manually doing stuff which seems redundant.

(The funny thing is, when I develop Linux kernel modules using Visual Studio + Visual Kernel, it is literally the first approach where I press F5 on module init and that’s it, so it’s weird that doing the same thing on Windows which Visual studio is mostly made for is so much headache!!)

  1. What is the most popular approach that professional driver developers use to automatically test their drivers against 10/20 different Windows versions automatically? For example maybe automatically use driver verifier or any other driver related tool to catch bugs (such as memory leaks, handle/reference leaks, invalid IRQL usage, etc) and BSODS on these test machines?
  1. Most of us use windbg and copy the files into place, or use the .kdfiles command to insert them at boot time.
  2. I don’t know anyone who tests their drivers on 10/20 different WIndows versions. What’s the point? The kernel just doesn’t change that much. Driver verifier and WDF verifier are both essential tools.

@Tim_Roberts said:
2. I don’t know anyone who tests their drivers on 10/20 different WIndows versions. What’s the point? The kernel just doesn’t change that much. Driver verifier and WDF verifier are both essential tools.

Well, rare bugs could occur on a specific Windows versions, for example I have encountered many bugs that only occured on Windows 7 x64 (specially in networking such as NDIS drivers), or even more specific, on a particular build. Another example is using APIs that are only available in newer Windows versions, so in 7 you would use a different API to register process notification than in 10, so you need to test both, therefore it never hurts to test the driver against different and popular versions/builds of Windows.

But let’s even say I only want to test it against a specific Windows version, is there anyway to automate testing the driver using Driver verifier after building the driver? Is there any tool that can help with automating the driver verifier checking?

Just a side Note:

Microsoft seems to be the one of the BEST companies at making very simple tasks extremely complicated, to the point that not facing multiple ridiculous problems and meaningless errors along the way a MIRACLE.

The amount of headache that setting up a simple thing like auto deployment causes is just hilarious, so many bugs, weird things, so many things that could go wrong and random errors happening…

Just look at one of the problems i faced when trying provisioning which seems like most people also face when trying this:

https://developercommunity.visualstudio.com/t/visual-studio-2019-wdk10/596096

Random errors like "ERROR: Task “Configuring kernel debugger settings (possible reboot)” "

What is the cause? Its a bug in visual studio that its provisioning is looking for a file IN A WRONG DIRECTORY!! lol, and their solution? Create a JUNCTION!!!

The same thing happened for another file called “Microsoft.WTT.Log.dll”, which I had to just copy to the folder that Visual studio was expecting it to be (even tho it was on another folder…) and not to mention the error itself is 100% meaningless, and you have to look through the long log files and find the root cause of the problem there instead.

And now I am facing yet another error “Task “Configuring computer settings (possible reboot)” was aborted because an error occured on the target machine during execution”, so gotta figure this one out now…

And the Laughable part is, a small group of developers have already developed an extension called VisualKernel for visual studio, which does the exact thing that Microsoft is so horribly trying to do, which is auto deployment and testing, and that one works with just a few clicks… and the hilarious part is that one is for LINUX driver development/testing in visual studio…

The same type of ridiculous problems that I am facing right now, I also faced when trying to implement and do their horrendous HLK/HCK testing suit… random and meaningless errors happening all over, for something so simple that could be done using simple python scripts… I guess I am better off writing a python script that does this instead of relying in Visual studio…

for something so simple that could be done using simple python scripts
Well I would not use python as then you have to install that too. In the recent past I’ve automated testing of assorted drivers using powershell scripts to perform the deployment and run the tests.

As others have noted, the VS test stuff is mostly useless and best avoided. It is also very helpful if your test systems can be vms and you can just revert them to a clean state after each test.

For the HLK/HCK Microsoft makes VMs freely available for use as the test server and I strongly recommend using that instead of trying to build your own. And yes those tests are a PITA, but they also can be automated.

@Mark_Roddy said:

for something so simple that could be done using simple python scripts
Well I would not use python as then you have to install that too. In the recent past I’ve automated testing of assorted drivers using powershell scripts to perform the deployment and run the tests.

As others have noted, the VS test stuff is mostly useless and best avoided. It is also very helpful if your test systems can be vms and you can just revert them to a clean state after each test.

For the HLK/HCK Microsoft makes VMs freely available for use as the test server and I strongly recommend using that instead of trying to build your own. And yes those tests are a PITA, but they also can be automated.

Yeah after few other errors, i realized it’s just basically useless. At the end I did manage to make it somewhat work, but it’s basically useless as you can encounter many random errors along the way and it’s not worth the headache, what a waste of time. And as for the python, it not that much of a problem because you just have to install it once on test machines, and yes I am already using VMs for test machines.

But I still can wrap my head around the fact that I can write a Linux kernel module in Visual studio, press F5 and debug the driver right away, stop debugging and it gets unloaded, very simple, just by using a simple third party extension, but all the work Microsoft has put into doing the same thing in WDK has basically failed as no one is using it, because they over complicated it too much which has lead to loads of bugs and random errors. So sad and embarrassing for Microsoft, what a shame.