sdk: .NET 6: The "CreateAppHost" task failed unexpectedly.

Error when building.

error MSB4018: The "CreateAppHost" task failed unexpectedly.
error MSB4018: System.IO.FileLoadException: Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
error MSB4018: File name: 'System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A)
error MSB4018: The Zone of the assembly that failed was:
error MSB4018: MyComputer
error MSB4018:    at Microsoft.NET.HostModel.AppHost.MachOUtils.RemoveSignature(String filePath)
error MSB4018:    at Microsoft.NET.HostModel.AppHost.HostWriter.<>c__DisplayClass2_0.<CreateAppHost>g__RemoveSignatureIfMachO|2()
error MSB4018:    at Microsoft.NET.HostModel.RetryUtil.RetryOnIOError(Action func)
error MSB4018:    at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResorcesFrom)
error MSB4018:    at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore()
error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute()
error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
error MSB4018: 
error MSB4018:

VS: 2019 16.9 Preview 2 .NET SDK: 6.0.100-alpha.1.21057.4

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 8
  • Comments: 24 (15 by maintainers)

Most upvoted comments

@rseanhall I unlocked it. Looks like that happened because the bot locked it when it was closed but didn’t unlock when it was reopened. I’ll follow up with the bot owner on that behavior.

@ericstj I found what I think is the latest build from this page: https://github.com/dotnet/installer#installers-and-binaries dotnet-sdk-6.0.100-preview.3.21123.4-win-x64 Getting different errors now at least which is unrelated to this issue.

For us it was caused by the virus scanner blocking access to tmp files being generated during build.

I assume you mean something like this? While the summary is the same (CreateAppHost task failed unexpectedly) the stack trace and message details are different though.

Anyways, the workaround above fixes the problem when trying to run the WinForms main branch in the Visual Studio debugger so I don’t think this is antivirus related.