Question

I'm using Visual Studio 2013. I am writing some MSBuild by hand. Inside I have something like this:

<PropertyGroup>
  <MyProperty>(complicated function)</MyProperty>
<PropertyGroup>

I load my project. I'd like some command, perhaps that I can execute in the immediate window, to print the value of "MyProperty".

What is the normal way of achieving this?

Edit: I discovered that I can make a <Target> that prints the value of all my properties with the <Message> task, but I can't find an easy way to execute this target from within the environment. I can set it as the DefaultTarget on the <Project>, but then I have to unload the project and edit the file again to get back to a state where I can actually compile.

Supposedly I could do this using msbuild.exe /t from the command line, but it doesn't seem to work because the properties, and also the <Target> itself, are defined in a file which is included via an <Import> statement, and for some reason msbuild.exe /t doesn't seem to like that.

Was it helpful?

Solution

MSBuild allows you to debug the script in Visual Studio,

http://blogs.msdn.com/b/visualstudio/archive/2010/07/06/debugging-msbuild-script-with-visual-studio.aspx

You can also force verbose logging, by adding /v:diag to your MSBuild command line, where in the log all such variables can be easily analyzed.

There is really no need to do what you plan to do.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top