【问题标题】:VS2012 How to set output directory for C#'s AnyCPU configuration to x86 and x64 folders for respective solution configs?VS2012 如何将 C# 的 AnyCPU 配置的输出目录设置为相应解决方案配置的 x86 和 x64 文件夹?
【发布时间】:2014-01-31 06:48:09
【问题描述】:

我有一个包含两个 C++ 和两个 C# 项目的解决方案。对于解决方案,我有一个 Win32 配置,其中有两个 C++ 文件为Win32,两个 C# 文件为AnyCPU。 x64 解决方案的 C++ 为 x64,C# 为 AnyCPU。

对于 Win32 解决方案,C++ 文件构建在 /x86/Release/ 文件夹中,我已将 C# 文件设置为输出到同一文件夹。但是,由于它设置为 AnyCPU,x64 解决方案也将 C# 输出到 /x84/Release/ 文件夹。

我希望 VS2012 中会有某种宏允许我选择解决方案的配置,以便我可以将输出设置为 $(SolnConfig)/Release,但似乎没有任何类似的东西。

有什么方法可以(相对)直接将AnyCPU 的输出设置为相应解决方案的 x86 和 x64 目录?

【问题讨论】:

    标签: c# c++ visual-studio-2012 output anycpu


    【解决方案1】:

    您可以创建自定义配置并在该配置下为每个项目定义单独的输出目录。 查看here 了解如何设置的详细信息。

    然后您可以制作一个批处理文件,该文件将根据一些自定义逻辑放置垃圾箱,如下所示:

    set msBuildExe=%WINDIR%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
    
    set configName=%1
    
    set pluginReportsDir=..\..\..\..\Wcf\Plugins\PluginReports
    
    echo ---
    echo Backup common PluginReports reports
    rem Since this is a post build event, the Common PluginReports is already built
    echo ---------------------------
    robocopy %pluginReportsDir%\bin\%configName%\ %pluginReportsDir%\bin\ PluginReports.dll PluginReports.pdb
    
    echo ---
    echo PluginReports for Site 3
    echo ---------------------------
    call %msBuildExe% %pluginReportsDir%\PluginReports.csproj /p:Configuration=%configName%Plugins_Site3 /t:Rebuild /noconsolelogger
    move /y %pluginReportsDir%\bin\%configName%\PluginReports.dll %pluginReportsDir%\bin\PluginReports_Site3.dll
    move /y %pluginReportsDir%\bin\%configName%\PluginReports.pdb %pluginReportsDir%\bin\PluginReports_Site3.pdb
    

    将批处理文件指定为构建后事件,它将复制文件。如果需要,它还可以执行过度构建。

    【讨论】:

      【解决方案2】:

      看起来有三个平台设置:解决方案平台、项目平台和平台目标。我试图从项目平台级别设置 AnyCPU,这导致在解决方案平台级别具有相同的 Win32 和 x64 输出目录的混淆。

      答案:在配置管理器中将解决方案平台设置为 Win32,将项目平台设置为 x86,并从项目属性中将 C# 文件的平台目标设置为 AnyCPU。对 x64 重复此操作。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多