Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>
like image 856
Mohammad Nadeem Avatar asked Feb 21 '13 09:02

Mohammad Nadeem


People also ask

How do I run MSBuild EXE?

To run MSBuild at a command prompt, pass a project file to MSBuild.exe, together with the appropriate command-line options. Command-line options let you set properties, execute specific targets, and set other options that control the build process.

Can I use MSBuild without Visual Studio?

To install MSBuild on a system that doesn't have Visual Studio, go to Build Tools for Visual Studio 2019, or install the . NET SDK. If you have Visual Studio, then you already have MSBuild installed. With Visual Studio 2022, it's installed under the Visual Studio installation folder.

What is MSBuild EXE?

MSBuild, or the Microsoft Build Engine platform, is a collection of tools used to build applications using Microsoft and third-party compilers like Intel and NVIDIA CUDA.

How do I run MSBuild target?

To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.


1 Answers

I have got it fixed by changing the Task to

<WriteLinesToFile File="$(OutDir)\VersionInfo.txt" ...... />
like image 74
Mohammad Nadeem Avatar answered Sep 23 '22 11:09

Mohammad Nadeem