MSBuild - How to build a .NET solution file (in an XML task script) from pre-written command line commands

Posted by Devtron on Stack Overflow See other posts from Stack Overflow or by Devtron
Published on 2011-02-25T16:39:13Z Indexed on 2011/02/26 7:25 UTC
Read the original article Hit count: 158

Filed under:
|
|
|
|

Hello.

I have been studying MSBuild as I have the need to automate my development shop's builds. I was able to easily write a .BAT file that invokes the VS command prompt and passes my MSBuild commands to it. This works rather well and is kinda nifty.

Here is the contents of my .BAT build file:

call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat"
cd  C:\Sandbox\Solution
msbuild MyTopSecretApplication.sln /p:OutputPath=c:\TESTMSBUILDOUTPUT /p:Configuration=Release,Platform=x86
pause

^ This works well but I now have the need to use the MSBuild task for TeamCity CI. I have tried to write a few MSBuild scripts but I cannot get them to work the same. What is the equivalent build script to the command I am using in my .BAT file? Any ideas?

I have tried using something like this, but no success (I know this is wrong):

<?xml version="1.0"?>
<project name="Hello Build World" default="run" basedir=".">

<target name="build">
    <mkdir dir="mybin" />
    <echo>Made mybin directory!</echo>

  <csc target="exe" output="c:\TESTMSBUILDOUTPUT">
    <sources>
      <include name="MyTopSecretApplication.sln"/>
    </sources>
  </csc>
  <echo>MyTopSecretApplication.exe was built!</echo>
</target>

<target name="clean">
    <delete dir="mybin" failonerror="false"/>
</target>

<target name="run" depends="build">
  <exec program="mybin\MyTopSecretApplication.exe"/>
</target>

What I simply need is an MSBuild XML build script that compiles a single solution for Release mode to a specified output directory. Any help?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about .net-4.0