Joseph Kingry
Joseph Kingry

Reputation: 8228

MSBuild and C++

If I am content to not support incremental builds, and to code everything via Exec tasks, is there any reason I can't build C++ binaries with an MSBuild script?

I know VS 2010 will actually have support for a true MSBuild based project file, but what I'm trying to do is to integrate an old embedded VC++ 4.0 workspace into an overall larger automated process.

I assume there will be some issues around dependency tracking, but if I'm doing a clean build everytime, is there anything else I should watch out for?

Upvotes: 2

Views: 1392

Answers (2)

KMoraz
KMoraz

Reputation: 14164

You can write your own ITask or simply call the Exec task with arguments, something like this:

<PropertyGroup> 
  <EvcPath>$(programfiles)\Microsoft eMbedded C++ 4.0\Common\EVC\Bin\EVC</EvcPath>  
  <EvcProjectPath>your.vcw</EvcProjectPath>
</PropertyGroup> 
  <PropertyGroup Condition=" '$(CEPlatform)' == 'WCEARM2003SP' "> 
  <EvcBuildConfig>All - Win32 (WCE ARMV4) $(Configuration)</EvcBuildConfig>
<EvcCEConfig>Smartphone 2003 Device</EvcCEConfig>
</PropertyGroup> 
  <PropertyGroup Condition=" '$(CEPlatform)' == 'WCEARM2003' "> 
  <EvcBuildConfig>ALL - Win32 (WCE ARMV4) PPC2003 $(Configuration)<EvcBuildConfig>
  <EvcCEConfig>POCKET PC 2003</EvcCEConfig>
</PropertyGroup> 

<Target Name="BuildEvcProjects">
  <Exec Command="$(EvcPath) %22$(EvcProjectPath)%22 /make %22$(EvcBuildConfig)%22 /CEConfig=%22$(EvcCEConfig)%22"
  IgnoreExitCode="true">
   <Output TaskParameter="ExitCode" PropertyName="EvcExitCode"/>
  </Exec>
  <Error Text="eVC 4.0 build has encountered an error. Exit code=$(EvcExitCode) " Condition="$(EvcExitCode) != 0" />
</Target>

Ultimately you could have the CE definitions and logic in its own .targets file referenced by the main MSBuild project. Another approach would be calling a batch file.

Upvotes: 2

tzenes
tzenes

Reputation: 1709

Let me share with you my build script (VS 2008) perhaps it will be helpful to you. I have this on the windows task scheduler to run every day at noon.

call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"

"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:update /path:"C:\Users\***\Desktop\Project\***" /closeonend:2

chdir c:\Users\**\Desktop\Project\**

rmdir /s /q C:\Users\***\Desktop\Project\***\bin\x86\Debug\app.publish

msbuild

msbuild /target:publish

chdir c:\Users\***\Desktop\Project\***\bin\x86\Debug

"C:\Program Files\WinRaR\Rar.exe" a -r -df -m5  C:\Users\***\Desktop\Project\***\BetaTest.zip app.publish

"C:\Program Files\SSH Communications Security\SSH Secure Shell\scp2.exe" C:\Users\***\Desktop\Project\***\BetaTest.zip ***@***.****:

del /q C:\Users\***\Desktop\Project\***\CCBetaTest.zip

Edit: in further explanation I load the environment variables for vs build, I then perform an svn update. I clean earlier builds. I build twice (because I'm using XNA and it will fail to copy files half the time), I then zip it and scp it to my server (I have RSA keys for my ssh).

I removed my personal information with the ***

Upvotes: 0

Related Questions