'build project for multiple runtime in dot net

I tried to build a project for multiple targets. I using net 5 framework, and I want to build app for win64 and linux64 runtimes.

The problem

Missing linux 64 folder

The csproj file :

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
    ...
  <TargetFrameworks>net48;net5.0</TargetFrameworks>
  <RuntimeIdentifiers>linux-x64;win-x64</RuntimeIdentifiers>
</PropertyGroup>

then I ran cli command:

dotnet build "projectPath"

Result in folder: enter image description here

Expected folder in results (when running with --runtime linux64)

enter image description here



Solution 1:[1]

After looking on MSDN enter link description here

dotnet publish section, I understand that the dotnet build/publish process is framework depended to make the output executable targeted to the requested framework so with the configuration i mentioned above, the build resolves all availables targets and run them, but will not make the publish directory for each configured target

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Michael Gabbay