如何为 msbuild 构建的 C++ 项目设置输出目录?

Nic*_*icJ 5 msbuild

我有一个 MSBuild .proj 文件,它正在编译 C# 和 C++ 项目的混合体。

C# 项目将输出 (.exe/.dlls) 编译到我指定的 OutputPath,但是当我为 C++ 项目(调用 vcbuild.exe)指定 OutputPath 时,OutputPath 被忽略,而是进入属性页中指定的目录对于 .vcproj。

这是我的 MSBuild 任务:

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

如何指定 C++ 输出文件应与 C# 输出文件 $(ToolsOutputDir) 位于同一目录?

Nic*_*icJ 1

我能够通过执行以下操作来完成这项工作:

1) 安装Microsoft SDC MSBuild 任务库

2) 在 C++ 项目的属性页中,将输出目录设置为$(OutputPath).

OutputPath3)在通过 VCBuild 构建 C++ 项目之前添加 SDC 任务来设置环境变量:

    <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>
Run Code Online (Sandbox Code Playgroud)