title: Error MSB4018 The "GenerateClsidMap" task failed unexpectedly
body: <p>I am trying to make a class available for Com Interop in Visual Studio 2019 (version 16.10.1). The project is created in .Net 5. During the build I get the error message 'Error MSB4018 The &quot;GenerateClsidMap&quot; task failed unexpectedly'.</p>
  <p>I have the following settings:
  Controller.csproj:</p>
  <pre><code>  &lt;Project Sdk=&quot;Microsoft.NET.Sdk&quot;&gt;
    &lt;PropertyGroup&gt;
      &lt;TargetFramework&gt;net5.0-windows&lt;/TargetFramework&gt;
      &lt;EnableComHosting&gt;true&lt;/EnableComHosting&gt;
      &lt;EnableRegFreeCom&gt;true&lt;/EnableRegFreeCom&gt;
      &lt;Configurations&gt;Debug;Release&lt;/Configurations&gt;
    &lt;/PropertyGroup&gt;
  </code></pre>
  <p>WindowController.cs</p>
  <pre><code>[Guid(&quot;D2B2F7DB-XXXX-XXXX-B015-A0970C3716CB&quot;)]
  [ClassInterface(ClassInterfaceType.None)]
  [ComVisible(true)]
  [ProgId(&quot;XXX.Controller.WindowController&quot;)]
  public class WindowController : IWindowController
  </code></pre>
  <p>IWindowControler.cs</p>
  <pre><code>[Guid(&quot;5EACF76F-XXXX-XXXX-9296-12BE41A02D5B&quot;)]
  [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
  [ComVisible(true)]
  public interface IWindowController
  {
      [DispId(10)]
      string NameParameter { get; set; }
      [DispId(20)]
      int NrParameter { get; set; }
  </code></pre>
  <p>While searching for a solution I found the following sample project:
  <a href="https://github.com/dotnet/samples/tree/main/core/extensions/COMServerDemo" rel="nofollow noreferrer">https://github.com/dotnet/samples/tree/main/core/extensions/COMServerDemo</a></p>
  <p>When I compile this, the same error occurs.</p>
  <p>Does anyone know the problem or can reproduce it? Is there a solution for it?</p>
  <p>Edit: Here is the output when compiling</p>
  <pre><code>1&gt;C:\Program Files\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(537,5): error MSB4018: The &quot;GenerateClsidMap&quot; task failed unexpectedly.
  1&gt;C:\Program Files\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(537,5): error MSB4018: System.MissingMethodException: Method not found: 'Void Microsoft.NET.HostModel.ComHost.ClsidMap.Create(System.Reflection.Metadata.MetadataReader, System.String)'.
  1&gt;C:\Program Files\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(537,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateClsidMap.ExecuteCore()
  1&gt;C:\Program Files\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(537,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute()
  1&gt;C:\Program Files\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(537,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskWithAssemblyResolveHooks.Execute()
  1&gt;C:\Program Files\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(537,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
  1&gt;C:\Program Files\dotnet\sdk\5.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(537,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.&lt;ExecuteInstantiatedTask&gt;d__26.MoveNext()
  </code></pre>