title: How to publish a self-contained C# executable that references another executable?
body: <p>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:</p>
  <p><code>dotnet publish A.csproj -c Release --self-contained -r win-x64 /p:PublishTrimmed=true /p:PublishReadyToRun=true</code></p>
  <p>However, this produces the following error when attempting to build project B (which is required since project A references it):</p>
  <p><code>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.</code></p>
  <p>But as you can see, I <em>am</em> (I think?) specifying a runtime identifier with <code>-r win-x64</code>. 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 <em>without</em> disabling SelfContained?</p>
  <p>My dotnet version is:</p>
  <pre><code>dotnet --version
  5.0.400
  </code></pre>
  <p>EDIT: I do not want to put <code>&lt;RuntimeIdentifier&gt;win-x64&lt;/RuntimeIdentifier&gt;</code> 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.</p>