sdk: The "CreateAppHost" task failed unexpectedly. (Version 16.4.5)

Hi,

Microsoft Visual Studio Community 2019 Version 16.4.5 Randomly getting the bellow error. I have added my root folder to the antivirus exclusion list.

Error	MSB4018	The "CreateAppHost" task failed unexpectedly.
Microsoft.NET.HostModel.HResultException: 8007006E
   at Microsoft.NET.HostModel.ResourceUpdater.Update()
   at Microsoft.NET.HostModel.AppHost.HostWriter.<>c__DisplayClass2_0.<CreateAppHost>g__UpdateResources|1()
   at Microsoft.NET.HostModel.RetryUtil.RetryOnWin32Error(Action func)
   at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResorcesFrom)
   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore()
   at Microsoft.NET.Build.Tasks.TaskBase.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()	EyezServices.Client	C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets	393	

Thanks

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 6
  • Comments: 41 (5 by maintainers)

Most upvoted comments

This is a nightmare… nothing helps

Closing VS Code (running on WSL) solved the issue for me. Also worth mentioning that both VS and VS Code were using the same working dir

curious… Are you running multiple VS instances or VS Code. Anything in that manner?

Also, have you tried running Visual Studio in Administrator (ADMIN) mode? “Run as Administrator”

Closing VS Code (running on WSL) solved the issue for me. Also worth mentioning that both VS and VS Code were using the same working dir

Me too!

Same here. This issue for me was caused by WSL locking. I had to shutdown WSL completely to have it working, and in addition I observed (not measured) that the speed of VS 2019 is way better with WSL shutdown.

Solved it upgrading to VS 16.6.0, I never had it again

The fix to perform more retries on the AppHost update will be in 3.1.4, scheduled for next week. Hope this will help alleviate the problem in most cases.

Same here. Using net core 3.1, single or multiple VS instance(s) makes no different, running on localhost:5000. Very random, it happens on rebuild, run and and I’ve seen it happening on IIS once published. I could run/debug the api for a half a day with no problem, then it happens again.

Hi. It is running as administrator. Its a multiple startup web projects. Running on docker .

I think only one instance of vs2019 is running.

I use to kill the docker containers to solve this issue. But since i updated vs 2019 to the latest version this does not help anymore… Clean rebuild sometime helps but its very very long…

Vs code is running react project in the background from a different folder. Thanks

I created a SignalR (but otherwise pretty much blank-slate) web app in VS 16.8.2 with linux-docker checked as an empty project option, build the nearly empty solution with no issues and attach a debugger on Startup.cs. I then decide to detach the debugger (“stop debugging”) and rebuild. It gave me a permission denied error, so I went in and manually killed and removed the pertaining docker images. Rebuilding after doing that is creating the following stack trace

1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: The “CreateAppHost” task failed unexpectedly. 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: System.IO.IOException: Incorrect function. 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite, Boolean checkHost) 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: at Microsoft.NET.HostModel.AppHost.BinaryUtils.CopyFile(String sourcePath, String destinationPath) 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResorcesFrom) 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore() 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 1>C:\Program Files\dotnet\sdk\5.0.103\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(460,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

Restarting my computer seems to fix the issue. But that’s hardly a good solution since I’m frequently debugging. Not sure what’s going on with docker, but it seems to be the culprit in this scenario. I’m updating VS to see if this resolves it.

edit: Updated. Also made a new blank project w/o docker. Issue is now persisting even after a restart. Have no idea what’s going on. It’s very strange. I will try .netcore3.0 and see what’s up.

edit edit: IT admin reached out. I was flagged for anti-virus on apphost.exe, that explains it. So it’s the same issue. (webroot antivirus)

@swaroop-sridhar ok. no matter what update I made it is still happening. the one thing that helped is updating visual studio to the most recent: 16.6.0 Thanks for helping out. Avi

That’s a workaround, not a resolution, @AlbertoBN . I tried to do the same, but the specific Trend Micro product installed on my machine explicitly doesn’t support wildcards on exclusion paths, so I ended up having them completely disable TM. Now I’m stuck without a working antivirus. In the end, a code build process should not be hindered by antivirus. exclusions aside. We can blame the AV vendors, but I don’t recall having this problem with any .NET build component in the last 18 years I’ve been using .NET.

Running into this issue a lot as wel… Just running a simple project with 2 docker containers, the docker-compose is my startup and it is the only VS2019 instance running.

What helps me is just to clean to solution, after that I can debug untill it occurs again.

For me, cleaning the solution in VS 2019 16.4.5 and SDK 3.1.101 fixed this build error. EDIT: Later in the day, it happened again (while I had another VS open), and I had to restart VS to fix it again. The solution files were in my Dropbox folder.

This is a dup of https://github.com/dotnet/runtime/issues/3832. A fix for this issue was checked into the master branch: https://github.com/dotnet/runtime/pull/32347

This fix is approved for servicing: https://github.com/dotnet/core-setup/pull/9012 It’ll be released in an upcoming servicing fix.