I have two C# .NET 5 projects, let's call them A and B. Both are executables (not DLLs). Project A references project B. I would like to publish project A as a self-contained executable (though not single-file, if that matters). I'm using this command to kick off the publishing process:
dotnet publish A.csproj -c Release --self-contained -r win-x64 /p:PublishTrimmed=true /p:PublishReadyToRun=true
However, this produces the following error when attempting to build project B (which is required since project A references it):
error NETSDK1031: It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier. You must either specify a RuntimeIdentifier or set SelfContained to false.
But as you can see, I am (I think?) specifying a runtime identifier with -r win-x64
. I'm guessing that the runtime identifier that I've specified on the command-line isn't getting passed through when building project B. How can I fix this without disabling SelfContained?
My dotnet version is:
dotnet --version
5.0.400
EDIT: I do not want to put <RuntimeIdentifier>win-x64</RuntimeIdentifier>
in my project files because I need to build for multiple different runtimes and I want to be able to control that via the command line.