Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging Visual Studio .props files

While trying to debug Visual Studio 2019 configuration problems, I often find myself in a situation where I need to display debug strings in the build output window:

Sometimes I can display a debug string in the build output window by inserting a "one-liner" into a .props file, like this:

...
  <Target Name="ValidateDriverProperties" BeforeTargets="PrepareForBuild">
  <Message  Importance="high" Text="MyDebugMessage: '$(WDKContentRoot)'" />
...

The code fragment above is from: C:\Program Files (x86)\Windows Kits\10\build\WindowsDriver.Common.targets with WDK v10.0.19041.0 installed.

However, when I try to insert my "one-liner" debug message into another .props file, I get an error like this:
error MSB4066: The attribute "Importance" in element <Message> is unrecognized.

...
  <MatchingWdkPresent Condition="Exists('$(WDKContentRoot)\Include\$(TargetPlatformVersion)\km\ntddk.h')">true</MatchingWdkPresent>
  <Message  Importance="high" Text="MyDebugMessage: '$(WDKContentRoot)'" />
...

The code fragment above is from: C:\Program Files (x86)\Windows Kits\10\build\WindowsDriver.Default.props with WDK v10.0.19041.0 installed.

Question: How to reliably display a debug string in the VS build output window from an arbitrary .props file ?

My question is not about the particular problem outlined below, but it might serve as a context:
The $(WDKContentRoot) variable has a trailing backslash and the code: $(WDKContentRoot)\Include\$(TargetPlatformVersion)\km\ntddk.h generates a bad path with double backslash like this: C:\Program Files (x86)\Windows Kits\10\\Include\x64\km\ntddk.h

like image 498
Pavel Stepanek Avatar asked Jun 22 '26 01:06

Pavel Stepanek


1 Answers

In case anyone else bumps into this, you get this error if you try to put a Message element in a PropertyGroup... which you can't do. To resolve, move the Message outside the property group (presumably inside some Target block).

The error message is very misleading here...

like image 185
James Crosswell Avatar answered Jun 24 '26 16:06

James Crosswell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!