Building non-MSBuild projects is possible. For example you have to build VS2003, Installer, C++, Delphi projects etc. How can you do it? It's simple.
The MSBuild has a built-in task: Exec task. This task calls cmd.exe instead of directly invoking a process and runs the specified program or command with the specified arguments. You can use it in order to build non-MSBuild projects.
For example, in order to build a Visual Studio 2003 Project you should modify the MSBuild file as:
1: <PropertyGroup>
2: <VS2003_Devenv>$(ProgramFiles)\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.com</VS2003_Devenv>
3: <VS2003_SolutionName>$(SolutionRoot)\vs2003\VS2003Application\VS2003SLN.sln</VS2003_SolutionName>
4: <VS2003_Configuration>Debug</VS2003_Configuration>
5: </PropertyGroup>
6:
7:
8: <Target Name="AfterCompile">
9: <Exec Command=""$(VS2003_Devenv)" "$(VS2003_SolutionName)" /build $(VS2003_Configuration)"/>
10:
11: <MakeDir
12: Directories="$(BinariesRoot)\$(VS2003_Configuration)"
13: Condition="!Exists('$(BinariesRoot)\$(VS2003_Configuration)')" />
14:
15: <Copy
16: SourceFiles="$(SolutionRoot)\vs2003\VS2003Application\bin\$(VS2003_Configuration)\**\*.*"
17: DestinationFiles="$(SolutionRoot)\vs2003\VS2003Application\bin\$(VS2003_Configuration)\**\*.* ->'$(BinariesRoot)\$(VS2003_Configuration)\%(RecursiveDir)%(Filename)%(Extension)')"
18: />
19: </Target>
Read here for more information about the target names and the MSBuild configuration file.
First declare some variables to use them during the build. (Lines 1 - 5) . Next in the AfterCompile target, use the MSBuild Exec task to build the VS2003 project by invoking the devenv.com program (Lines 9 -10). After that make a directory (using MakeDir task) for the output (if not exists) (Lines 11 - 13). Finally copy (using the Copy task)the output files to the build binaries root (Lines 15 - 18).
Notice that this assumes VS 2003 is installed on the build machine.
Good Luck!
No comments:
Post a Comment