Visual Studio project has strange build behavior.

I created a VS 2017 project for my driver, using the ‘Empty WDM Driver’ template. I then added a .cpp file and three .h files to the project.

Two strange things are happening.

  1. I cannot run the Compile command on the .cpp file, either from the open window for the file, or from the context menu in Solution Explorer.

  2. Build / Clean (or Rebuild, which does a Clean first) removes all the files from the project directory, including the project file itself and the .inf file generated by the driver template when I created the project. Fortunately, I put all these files into source control, so I can get them back (although if I have uncommitted changes, I will lose these).

The Build / Build (F7) command works fine. It compiles the .cpp file, links to another referenced project, and signs the .sys output file.

Is there something special about a WDM driver project that I should know about?

I suspect this may trigger some interesting discussions…

Without getting too deep into it, the driver template uses a completely
different build system than the standard C++ projects, more like a makefile
approach. One side effect (there are many others) is that it only builds the
entire project, there is no way to tell it to build (compile) just a single
component.

There are other ways to build drivers, but they are not the “Microsoft Way”.

xxxxx@nlited.com wrote:

I suspect this may trigger some interesting discussions…

Without getting too deep into it, the driver template uses a completely
different build system than the standard C++ projects, more like a makefile
approach. One side effect (there are many others) is that it only builds the
entire project, there is no way to tell it to build (compile) just a single
component.

Who wrote this?  Because it’s entirely untrue.  A driver vcxproj is
exactly like any other vcxproj.  You certainly can build one file at a time.

What you say was the case when people were hacking in Visual Studio
support in WDK 7.0 and before, but since WDK 8.0, it is totally integrated.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

xxxxx@rolle.name wrote:

I created a VS 2017 project for my driver, using the ‘Empty WDM Driver’ template. I then added a .cpp file and three .h files to the project.

Two strange things are happening.

  1. I cannot run the Compile command on the .cpp file, either from the open window for the file, or from the context menu in Solution Explorer.

What happens when you do that?  Which WDK did you install?

 

  1. Build / Clean (or Rebuild, which does a Clean first) removes all the files from the project directory, including the project file itself and the .inf file generated by the driver template when I created the project. Fortunately, I put all these files into source control, so I can get them back (although if I have uncommitted changes, I will lose these).

None of that is sensible.  Can you fetch one of the driver samples and
try the same things with it?

Is there something special about a WDM driver project that I should know about?

No.  It should work like any other project.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> Who wrote this? Because it’s entirely untrue. A driver vcxproj is exactly like any other vcxproj. You certainly can build one file at a time.

What you say was the case when people were hacking in Visual Studio support in WDK 7.0 and before, but since WDK 8.0, it is totally integrated.

I am pleased to hear it has been fixed. I worked around it, and haven’t looked back.

It wasn’t fixed per se. Before win8 wdk VS wasn’t supported in anyway and the win7 solution was done by a third party.

As for a single file not building, I have a vague memory that this didn’t work in the win8 wdk integration with VS. I have no idea if it was fixed and has regressed or not fixed at all.

d

Bent from my phone


From: xxxxx@lists.osr.com on behalf of xxxxx@nlited.com
Sent: Wednesday, March 28, 2018 6:40:07 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] Visual Studio project has strange build behavior.

> Who wrote this? Because it’s entirely untrue. A driver vcxproj is exactly like any other vcxproj. You certainly can build one file at a time.

> What you say was the case when people were hacking in Visual Studio support in WDK 7.0 and before, but since WDK 8.0, it is totally integrated.

I am pleased to hear it has been fixed. I worked around it, and haven’t looked back.


NTDEV is sponsored by OSR

Visit the list online at: https:

MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
Details at https:

To unsubscribe, visit the List Server section of OSR Online at https:</https:></https:></https:>

My WDK is 10.0.16299.15.

Building the project shows ‘Building ‘Xxx’ with toolset ‘WindowsKernelModeDriver10.0’ and the ‘Desktop’ target platform.’.

Interestingly, I have three WDM projects. One of them, called Kernel, is a static library referenced by the other two. I can run the Compile command on Kernel.cpp in this project; also, the Clean command does not remove everything.

Kernel and one of the other projects are on my OneDrive.

https://1drv.ms/u/s!ApOT5u2HVnyEg0kXzzCZxoyBnfYI for IBS Ops Driver.vcxproj.
https://1drv.ms/u/s!ApOT5u2HVnyEg0ha8GwcXmLTDTfA for Kernel.vcxproj.

I recreated the IBS project. I started with an empty WDM project in a new folder, then copied the .h and .cpp files and added them, added the reference to Kernel, and changed some compile settings. Now the Clean command works OK, but the Compile command is still unavailable.

Can you find what is wrong with the IBS project file.

Another strangeness is the StampInf step. The command line is '-d “01/01/2018” -a “amd64” -v “1.0” ', but the .inf file reads ‘DriverVer = 03/30/2018,1.0.0.0’. Why does the current date appear here, rather than what was in the -d switch?

I found the problem with the Clean step. I had my Output Directory set to $(SolutionDir), and so Clean removes files from the project dir, which is a subdirectory of the solution dir.
I did this for only one build configuration, because I wanted to have all my driver outputs in the same folder for both of the projects.
I went back to $(SolutionDir)$(Platform)$(ConfigurationName)\ and the Clean works fine.

Although that solved my problem, I’m annoyed that Clean behaves this way. Is there something wrong with MSBuild here, or something else wrong with the project file?

In order to have my .sys and .pdb outputs in the common SolutionDir, I need to make a post-build step to copy these files.

xxxxx@rolle.name wrote:

I found the problem with the Clean step. I had my Output Directory set to $(SolutionDir), and so Clean removes files from the project dir, which is a subdirectory of the solution dir.
I did this for only one build configuration, because I wanted to have all my driver outputs in the same folder for both of the projects.
I went back to $(SolutionDir)$(Platform)$(ConfigurationName)\ and the Clean works fine.

Although that solved my problem, I’m annoyed that Clean behaves this way. Is there something wrong with MSBuild here, or something else wrong with the project file?

That’s what “Clean” does – it clears out the OutputDirectory.  What did
you expect it to do?

In order to have my .sys and .pdb outputs in the common SolutionDir, I need to make a post-build step to copy these files.

Yes, because that’s not a good practice.  You’re going to want separate
binaries for Debug, Release, Debug64, and Release64.  If you don’t
follow something like the recommendation, how will you know what those
binaries are?  How can you build a package with both 32-bit and 64-bit
drivers?


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

xxxxx@rolle.name wrote:

Another strangeness is the StampInf step. The command line is '-d “01/01/2018” -a “amd64” -v “1.0” ', but the .inf file reads ‘DriverVer = 03/30/2018,1.0.0.0’. Why does the current date appear here, rather than what was in the -d switch?

Do you actually see that string in the command line logs?  Your vcxproj
specifies , but the -d parameter comes from
, which you don’t have. Also, you’re specifying
as false, which should skip the -d
parameter altogether.

Why do you want to override this, anyway? “*” is almost always what you
want, so it does put today’s date.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

xxxxx@rolle.name wrote:

I recreated the IBS project. I started with an empty WDM project in a new folder, then copied the .h and .cpp files and added them, added the reference to Kernel,
and changed some compile settings. Now the Clean command works OK, but
the Compile command is still unavailable.

Can you find what is wrong with the IBS project file.

I wonder if it is the spaces in your file names.  As a rule, we
developers tend to avoid blank spaces as if they were poison, because so
many of the tools misbehave.

Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.