0

win64 と osx-x64 の両方で net6 アプリケーションを開発しており、OutputPath をカスタム パスに設定したいと考えています。

私はwin64バージョンのみから始めました。x64 ソリューション構成を使用しています

これが私の csproj でした:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <AssemblyName>XXX</AssemblyName>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <OutputPath>$(SolutionDir)..\output\debug64\</OutputPath>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <OutputPath>$(SolutionDir)..\output\release64\</OutputPath>
  </PropertyGroup>

次に、osx バージョンを追加して、次のようにします。

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <RuntimeIdentifiers>osx-x64;win-x64</RuntimeIdentifiers>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <AssemblyName>XXX</AssemblyName>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
    <OutputPath>$(SolutionDir)..\output\debug64\</OutputPath>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
    <OutputPath>$(SolutionDir)..\output\release64\</OutputPath>
  </PropertyGroup>

これを使用して、Mac でコンパイルまたは公開すると、OutputPath が正しく設定されず、公開時に bin/Release/net6/ または bin/Release/net6/osx-x64/publish に移動します (osx-x64 を使用)。

私はこれをcsprojに追加しようとしましたが、運が悪かったです:

<PropertyGroup Condition="'$(Configuration)|$(Platform)|$(RuntimeIdentifier)'=='Debug|x64|osx-x64'">
    <OutputPath>$(SolutionDir)..\output\osx\debug64\</OutputPath>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform|$(RuntimeIdentifier)'=='Release|x64|osx-x64'">
    <OutputPath>$(SolutionDir)..\output\osx\release64\</OutputPath>
</PropertyGroup>

さらに悪いことに、Windows では、プロジェクトのデバッグを開始できません。「アクティブなソリューション構成に一致するプロジェクト構成がありません」というメッセージが表示されます。ソリューションの構成マネージャーで、プロジェクトは現在 x64 ではなくプラットフォームとして AnyCPU にあります。

x64 をプラットフォーム (win および osx 用) として保持し、指定されている場合、RuntimeIdentifier に基づいて出力パスを設定できますか?

4

0 に答える 0