gpt4 book ai didi

visual-studio - 通过 MSBuild 构建不同平台的 Visual Studio 项目

转载 作者:行者123 更新时间:2023-12-04 23:26:21 24 4
gpt4 key购买 nike

我有 3 个带有配置的项目:

  • 项目 A:调试|AnyCPU,发布|AnyCPU
  • 项目 B:调试|AnyCPU,发布|AnyCPU
  • 项目 C:调试|x86、调试|x64、发布|x86、发布|x64

  • 项目 C 的依赖项中有 B,而 B 的依赖项中有 A。 (A <- B <- C)

    我使用 *.bat 文件从命令行构建它:
    msbuild A.csproj /target:Build /property:Configuration=Debug;Platform=AnyCPU /verbosity:minimal
    msbuild A.csproj /target:Build /property:Configuration=Release;Platform=AnyCPU /verbosity:minimal<br/>
    msbuild B.csproj /target:Build /property:Configuration=Debug;Platform=AnyCPU /verbosity:minimal
    msbuild B.csproj /target:Build /property:Configuration=Release;Platform=AnyCPU /verbosity:minimal
    msbuild C.csproj /target:Build /property:Configuration=Debug;Platform=x86 /verbosity:minimal
    msbuild C.csproj /target:Build /property:Configuration=Release;Platform=x86 /verbosity:minimal
    msbuild C.csproj /target:Build /property:Configuration=Debug;Platform=x64 /verbosity:minimal
    msbuild C.csproj /target:Build /property:Configuration=Release;Platform=x64 /verbosity:minimal

    并收到错误:

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(609,5): error : The OutputPath property is not set for project 'A.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x86'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [A.csproj] C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(609,5): error : The OutputPath property is not set for project 'B.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='x86'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project. [B.csproj]

    最佳答案

    我找到了解决我的问题的方法。
    使用 *.csproj 文件中的选择元素通过 Visual Studio 或 MSBuild 检测构建,并使用 Reference(而不是 ProjectReference)进行 MSBuild。

    <Choose>
    <When Condition="'$(BuildingInsideVisualStudio)' == 'true'">
    <ItemGroup>
    <ProjectReference Include="A.csproj">
    <Project>{AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA}</Project>
    <Name>A</Name>
    <Private>True</Private>
    </ProjectReference>
    <ProjectReference Include="B.csproj">
    <Project>{BBBBBBBB-BBBB-BBBB-BBBB-BBBBBBBBBBBB}</Project>
    <Name>B</Name>
    <Private>True</Private>
    </ProjectReference>
    </ItemGroup>
    </When>
    <Otherwise>
    <ItemGroup>
    <Reference Include="A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
    <HintPath>A.dll</HintPath>
    <Private>True</Private>
    </Reference>
    <Reference Include="B, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
    <HintPath>B.dll</HintPath>
    <Private>True</Private>
    </Reference>
    </ItemGroup>
    </Otherwise>
    </Choose>

    关于visual-studio - 通过 MSBuild 构建不同平台的 Visual Studio 项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12348645/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com