2009-01-14 139 views
3

我有一個正在編譯C#和C++項目混合的MSBuild .proj文件。如何爲由msbuild構建的C++項目設置輸出目錄?

C#項目編譯輸出(.exe/.dlls)到我指定的OutputPath,但是當我爲C++項目指定OutputPath(調用vcbuild.exe)時,OutputPath被忽略,而是進入指定的目錄在.vcproj的屬性頁中。

這裏是我的MSBuild任務:

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

我怎麼可以指定C++輸出文件應到同一目錄C#輸出文件$(ToolsOutputDir)?

回答

1

我能夠這樣做,使這項工作如下:

1)安裝Microsoft SDC MSBuild Tasks Library

2)在屬性頁的C++項目,輸出目錄設置爲$(OutputPath)

3)添加SDC任務經由VCBuild構建C++項目之前設置環境變量OutputPath

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