CreateAppHost runs and fails during VS design time build if project isn't already built
See original GitHub issueRepro steps
- Install .NET Core 3.0 SDK (I had 3.0.100-alpha1-009697)
dotnet new wpf
- Open VS.
- Open the project created in 2.
Result
Error MSB4018 The "CreateAppHost" task failed unexpectedly.
Microsoft.NET.Build.Tasks.ResourceUpdater+HResultException: 80070002
at Microsoft.NET.Build.Tasks.ResourceUpdater.AddResourcesFromPEImage(String peFile)
at Microsoft.NET.Build.Tasks.AppHost.Create(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String intermediateAssembly, Logger log)
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()
(from C:\Program Files\dotnet\sdk\3.0.100-alpha1-009697\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets Line 293)
Expected
We probably shouldn’t run this target if the assemblies it’s going to work on don’t exist.
Issue Analytics
- State:
- Created 5 years ago
- Comments:68 (39 by maintainers)
Top Results From Across the Web
The CreateAppHost task failed unexpectedly. MSB4018
This was caused by using VSCode as admin. Apparently after I build solution with VSCode as admin, some gets messed up resulting with...
Read more >The "CreateAppHost" task failed unexpectedly.
I am using C# and a console application with a lot of formatting statements. Visual Stuio is up to date. Visual Studiowindows 10.0visual...
Read more >How To fix visual studio 16.8.2, 16.8.3 ASPNETCORE Build ...
This video solves these Errors RazorTagHelper - DOTNET_HOST_PATH is not set - Error MSB4018, Error MSB4018 The "RazorGenerate" task failed ...
Read more >MSB4018: The task failed unexpectedly - Microsoft Q&A
Hello I have a problem in VS 2022 .net 6 The problem is: MSB4018: The task ... Error MSB4018 The "CreateAppHost" task failed...
Read more >MSBuild forum - RSSing.com
I got following error when compiling the c++ project with Build Tools 2017 in Windows container "windowservercore". Running Code Analysis for C/C++.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Figured it out. For anyone viewing this thread, the culprit was Windows Security. I was getting the above error about 40% of the time I did a build (F5 and Control-F5). The fix:
I didn’t see this specific fix anywhere else on the web, so hopefully this helps someone.
Hi Nick, thanks for writing that.
I’m not frustrated, in fact I think you are doing a great job by doing this in the open, which is certainly not easy. And I am sorry if that comment felt like stressing you, I actually didn’t think about that. I really wanted to prevent something I had experienced, like issue x was fixed but it wasn’t clear in which build it arrives. I have no problems at all waiting much longer for a fix, especially if this gives you time to improve the build pipeline and maybe even make something like rudimentary release notes. And there are probably issues which deserve a higher priority!
I know what it means to run alpha or beta software, I wouldn’t be doing this if it doesn’t bring something. This makes it possible to adapt my product way quicker than to wait until it’s released. It also gives me a possibility to influence the framework with some of my experiences, and learn something while doing this. For instance: I actually learned today that there is no such thing as an “Any Cpu” .exe, it’s a .NET Framework thing. I should bring this up with Daniel. It’s a mystery why I didn’t know… but not having this this does complicate my product and a lot of others.
I actually got most of the foundation code for Greenshot running on dotnet core 3.0, it might still have a few small quirks, but this is really amazing work in such a short time!!! Just seeing the shear amount of APIs that you guy processed, is mind boggling. I hope to have a running Greenshot soon, much sooner as I expected!