I have a solution with a number of projects.
The main project’s assembly’s version is inspected in a post-build event and the release notes associated with that version are extracted from Trac RSS and stored as an XML file to be shipped with the application. This is done in a post-build event.
The main assembly’s project’s post-build event:
Powershell -File "$(SolutionDir)scripts\makereleasenotes.ps1" $(TargetPath) $(ProjectDir)
This works fine in VS.
When we build deployments, however, a number of other steps happen and so there is a command-line msbuild which is run from a double-click which does the build and packages up a deployment.
When run from this process, the post-build step doesn’t appear to be running.
This is the command script we use:
set app_main=%CD%
msbuild app.msbuild /target:Release;Cleanup
The app.msbuild has a target which then includes other targets:
<Target Name="Release" DependsOnTargets="CreateDir;BuildRelease;CopyFiles"/>
and:
<Target Name="BuildRelease" >
<MSBuild Projects="App.Web.Application.sln" Properties="Platform=$(Platform);Configuration=Release;
OutDir=$(ReleaseDir)\$(DTResult)\$(ReleaseConfiguration)\"
Targets="Clean;Rebuild">
<Output ItemName ="OutputFiles" TaskParameter="TargetOutputs"/>
</MSBuild>
etc.
So you can see that our external msbuild script delegates to the solution, and there are no individual projects being compiled in our build.
Is a subordinate project’s post-build script supposed to run when a solution is set as a target in an msbuild script?
If so, what is stopping mine from running?
If not, I’m assuming I will have to run it separately, and provide equivalent parameters for the project-level macros (which the powershell script is using to inspect the assembly and write out the release notes XML)?
The problem was caused by spaces in the paths of the builds and the macros (specifically $ProjectDir which ends in a ). The build script set the path to include spaces of the form “yyyy MM dd HH-mm”. This the parameters to the Powershell were invalid when spearated by those spaces.
You cannot just add double quotes to the parameters in the post-build, because the $(ProjectDir) marco expands to DRIVE:\something\something\ and when you put “” around this, you just end up with “DRIVE:\something\something\” which actually expands the trailing \” to ” instead of \ – which completely messes it up.
Ended up just removing the spaces so that the parameters were whole and did not need to figure out how to get the quotes working in the post-build script.