Customising csproj build scripts

Customising csproj build scripts

Here’s an item I need to blog about because in a few months I will have forgotten the details.

First, the verbosity of Visual Studio MSBuild messages. Go to Tools > Options > Project and Solutions > Build and Run. Set the build output verbosity to Normal. Would appear that the VS install default is Minimal.

Now you’ve done that, you can edit your csproj file to add some custom targets where you’ll actually see any messages in the output window, for example:-

<Target Name="BeforeBuild">
    <Message Text="My Before Build message…" />
</Target>

Finally, I found this post enhancing the AfterClean target which I thought was most helpful.
http://www.ademiller.com/blogs/tech/2007/12/deep-clean-your-build/

  <Target Name="AfterClean">
    <Message Text="Deep cleaning…" />
    <CreateItem Include="$(OutDir)*.*;$(IntermediateOutputPath)**\*.*">
        <Output TaskParameter="Include" ItemName="Clean_FilesToDelete"/>
    </CreateItem>
    <Delete Files="@(Clean_FilesToDelete)" />
    <RemoveDir Directories="$(OutDir);$(OutDir)..\;$(IntermediateOutputPath);$(IntermediateOutputPath)..\" />
  </Target>

have fun!
John

Comments are closed.