Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the Output directory for a C++ project built by msbuild?

Tags:

msbuild

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)?

like image 987
NicJ Avatar asked Nov 15 '22 16:11

NicJ


1 Answers

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>
like image 119
NicJ Avatar answered Mar 01 '23 23:03

NicJ