Mohammad Nadeem
Mohammad Nadeem

Reputation: 9392

Post build event not working with msbuild.exe

I have a post build event which is writing to a text file. It is working fine when I am building the project from Visual Studio. But when I am using msbuild.exe the Post build event is not writing to the file. I am using msbuild with 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 post build event looks like:

  <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>

Upvotes: 7

Views: 7325

Answers (1)

Mohammad Nadeem
Mohammad Nadeem

Reputation: 9392

I have got it fixed by changing the Task to

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

Upvotes: 4

Related Questions