1 year ago

#122546

test-img

Whiletrue

RuntimeIdentifiers and custom output path in a net6 multi-platform application

I develop a net6 application for both win64 and osx-x64 and I would like to set the OutputPath to a custom path.

I started with only the win64 version. I use the x64 solution configuration

Here was my 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>

Then I add the osx version turning into this :

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

Using this, when I compile or publish on the Mac, the OutputPath is not set correctly, it goes to bin/Release/net6/ or bin/Release/net6/osx-x64/publish when I publish (using osx-x64).

I tried to add this in the csproj without luck :

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

and worse, on Windows, I can't start debugging the project, there are a message saying "There is no project configuration matching the active solution configuration". in the configuration manager of the solution, project is now on AnyCPU as platform instead of x64

Can I keep x64 as platform (for win and osx) and set the output path based on the RuntimeIdentifier if specified ?

c#

.net-6.0

multiplatform

avaloniaui

avalonia

0 Answers

Your Answer

Accepted video resources