tags:

views:

1183

answers:

1

I have a MSBuild .proj file that is compiling a mixture of C# and C++ projects.

The C# projects compile output (.exe/.dlls) to the OutputPath I specify, but when I specify OutputPath for the C++ projects (which calls vcbuild.exe), the OutputPath is ignored and instead goes into the directory specified in the Property Pages for the .vcproj.

Here's my MSBuild task:

    <MSBuild Projects="$(SourceFolder)\$(NativeSolutionName)"
             Targets="$(BuildTargets)"
             Properties="Configuration=$(Configuration);PlatformName=Win32;OutputPath=$(ToolsOutputDir)">
    </MSBuild>

How can I specify that the C++ output files should go to the same directory as the C# output files $(ToolsOutputDir)?

+1  A: 

I was able to make this work by doing the following:

1) Installing the Microsoft SDC MSBuild Tasks Library

2) In the property pages for the C++ projects, setting the output directory to $(OutputPath).

3) Adding a SDC task to set the environment variable OutputPath before building the C++ projects via VCBuild:

    <Microsoft.Sdc.Tasks.SetEnvironmentVariable Variable="OutputPath" Value="$(ToolsOutputDir)" Target="Process"/>

    <!-- Build any CPP code x86 -->
    <MSBuild Projects="$(SourceFolder)\$(NativeSolutionName)"
             Targets="$(BuildTargets)"
             Properties="Configuration=$(Configuration);PlatformName=Win32;OutputPath=$(ToolsOutputDir)">
    </MSBuild>
NicJ