tags:

views:

30

answers:

1

I come from an ant background, and I'm starting to use msbuild. I want to create a .proj file with targets for clean, compile, deploy, etc. In ant, I would expect my user to run ant -project-help to get a list of the targets with their descriptions. There doesn't appear to be anything like this with msbuild, so I was thinking of setting DefaultTargets to "Help" and adding this target:

<Target Name="Help">
  <Message Text="/t:Clean - Remove all bin folders and generated files"/>
  <Message Text="/t:Compile - Generate assembly"/>
  <Message Text="/t:Deploy - Install the assembly"/>
</Target>

When I run msbuild, I see this:

Microsoft (R) Build Engine Version 3.5.30729.1
[Microsoft .NET Framework, Version 2.0.50727.3053]
Copyright (C) Microsoft Corporation 2007. All rights reserved.

Build started 5/13/2010 9:00:00 AM.
Project "C:\MyProject\MyProject.proj" on node 0 (default targets).
  /t:Clean - Remove all bin folders and generated files
  /t:Compile - Generate assembly
  /t:Deploy - Install the assembly
Done Building Project "C:\MyProject\MyProject.proj" (default targets).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.05

My target description are hidden among all the other output.

It feels like I have a paradigm-mismatch here. What's the best way to provide the build functionality I want so that users know where to find each target?

+1  A: 

I'm afraid there is no clean way to do what you want. Creating a default help target is a good idea.

To have a cleaner output, you could set the Importance attribute of Message task to high to have your messages standing out more.

<Target Name="Message">
    <Message Text="/t:Clean - Remove all bin folders and generated files" Importance="high"/>
    <Message Text="/t:Compile - Generate assembly" Importance="high"/>
    <Message Text="/t:Deploy - Install the assembly" Importance="high"/>
</Target>

You could also run MSBuild with the following argument to clean your output :

msbuild [ProjectFile.proj] /v:m /nologo

You'll have this output :

  /t:Clean - Remove all bin folders and generated files
  /t:Compile - Generate assembly
  /t:Deploy - Install the assembly
madgnome