Post build event does not work with msbuild.exe

I have a post build event that writes to a text file. It works great when I create a project from Visual Studio. But when I use msbuild.exe, the Post build event is not written to the file. I am using msbuild with the following parameters:

msbuild.exe TestProj.Web.csproj /p:Configuration=Release /p:OutDir=C:\TestProj\bin\ /p:WebProjectOutputDir=C:\TestProj\ /p:DebugSymbols=false /p:DebugType=None 

The event after the build is as follows:

  <PropertyGroup Condition="'$(BUILD_NUMBER)'==''"> <COMPUTERNAME>None</COMPUTERNAME> <BRANCH>None</BRANCH> <BUILD_NUMBER>None</BUILD_NUMBER> </PropertyGroup> <Target Name="AfterBuild"> <WriteLinesToFile File="$(ProjectDir)$(OutputPath)\VersionInfo.txt" Overwrite="true" Lines="Project&#xD;&#xA;Created On $(COMPUTERNAME)&#xD;&#xA;Branch is $(BRANCH)&#xD;&#xA;Version Is $(BUILD_NUMBER)" /> </Target> 
+7
source share
1 answer

I fixed this by changing the task to

 <WriteLinesToFile File="$(OutDir)\VersionInfo.txt" ...... /> 
+4
source

All Articles