dotnet build runtime parameter does not work

The dotnet runtime parameter does not work as expected GitHub issue #14281

dotnet build --runtime <RUNTIME_IDENTIFIER>

error NETSDK1134: Building a solution with a specific RuntimeIdentifier is not supported. If you would like to publish for a single RID, specifiy the RID at the individual project level instead. 

As workaround, define a custom RuntimeIdentifier in Directory.Build.props, and pass it as parameter to each command.

<PropertyGroup>
    <RuntimeIdentifier Condition="'$(MyRuntimeIdentifier)' != ''">$(MyRuntimeIdentifier)</RuntimeIdentifier>
</PropertyGroup>
dotnet restore -p:MyRuntimeIdentifier=linux-x64
dotnet build -p:MyRuntimeIdentifier=linux-x64
dotnet publish App.csproj -p:MyRuntimeIdentifier=linux-x64