title: How to public sign a project with MSBuild
body: <p>I have a C# .NET Framework project which I sign using a <code>.pfx</code> file on my local system. In the <code>.csproj</code> file the following properties are set:</p>
  <pre><code>&lt;PropertyGroup&gt;
    &lt;SignAssembly&gt;true&lt;/SignAssembly&gt;
  &lt;/PropertyGroup&gt;
  &lt;PropertyGroup&gt;
    &lt;AssemblyOriginatorKeyFile&gt;keyfile.pfx&lt;/AssemblyOriginatorKeyFile&gt;
  &lt;/PropertyGroup&gt;
  </code></pre>
  <p>This file is part of an open source project. I'm trying to create a pipeline which runs on certain commits. When I commit something, the original <code>*.pfx</code> can be installed using the password which is stored as a GitHub secret. The problem is that when forked repos make a pull request, the pipeline fails, because the GitHub secrets are not available to them.</p>
  <p>Long story short, I found out that I can use <a href="https://github.com/dotnet/runtime/blob/main/docs/project/public-signing.md" rel="nofollow noreferrer">public signing</a> for this purpose. However, when I try to build my project using</p>
  <pre><code>msbuild src\TcBlackCore\TcBlackCore.csproj -t:Rebuild -p:DelaySign=false -p:PublicSign=true -p:Configuration=Release -p:Platform=AnyCPU -p:TreatWarningsAsErrors=true
  </code></pre>
  <p>I get the following error:</p>
  <blockquote>
  <p>CS7102: Compilation options 'PublicSign' and 'CryptoKeyContainer' can't both be specified at the same time</p>
  </blockquote>
  <p>I couldn't find any information on this error code except for <a href="https://github.com/dotnet/roslyn/issues/23326" rel="nofollow noreferrer">one GitHub issue</a> which mentions:</p>
  <blockquote>
  <p>ERR_MutuallyExclusiveOptions  CS7102</p>
  </blockquote>
  <p>What are the mutually exclusive options here? The <code>DelaySign</code> should be set to the <a href="https://github.com/dotnet/runtime/blob/main/docs/project/public-signing.md#msbuild-and-compiler-tooling-support" rel="nofollow noreferrer">docs</a>. And what should I do to get the public signing to work such that forked repos can be build?</p>
  <pre><code>&gt; msbuild -version
  Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
  </code></pre>