Visual Studio 2019 编译.Net Core Console项目出现【MSB4018 The "CreateAppHost" task failed unexpectedly】 错误

需要测试一个小东东,使用Visual Studio 2019新建了一个.Net Core的Console程序,但是在编译的时候一直报错,死活编译不通过。

错误信息:

Severity Code Description Project File Line Suppression State
Error   MSB4018 The "CreateAppHost" task failed unexpectedly.
System.AggregateException: One or more errors occurred. ---> 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)
   --- End of inner exception stack trace ---
   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()
---> (Inner Exception #0) 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)<---

---> (Inner Exception #1) System.UnauthorizedAccessException: Access to the path 'D:\VS2019Code\Projects\ConsoleApp9\ConsoleApp9\obj\Debug\netcoreapp3.1\ConsoleApp9.exe' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalDelete(String path, Boolean checkHost)
   at System.IO.File.Delete(String path)
   at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResorcesFrom)<---
    ConsoleApp9 C:\Program Files\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets    393

网上的方案有如下,也都进行了尝试:

  • 重启Visual Studio
  • 以管理员身份运行Visual Studio
  • 清理解决方案
  • 删除bin目录下的所有文件

然鹅,均无效,无奈之下继续寻找解决方案,发现用Process Monitor来监控到底是谁在搞鬼。

点击下载 Process Monitor.

终于发现了罪魁祸首。

原来是你,让我花了我一个上午的时间在折腾。

立马干掉

果然,一切编译正常,大功告成。

原文地址:https://www.cnblogs.com/hand/p/12112647.html

时间: 2024-08-30 06:18:06

Visual Studio 2019 编译.Net Core Console项目出现【MSB4018 The "CreateAppHost" task failed unexpectedly】 错误的相关文章

Visual Studio 2019尝鲜----新建空项目体验

等待一个中午的时间终于下载安装完成,vs版本Enterprise 2019  16.0.4 官方可直接下载安装引导程序:  https://visualstudio.microsoft.com/zh-hans/downloads/ 网上找了个Visual Studio 2019(VS2019) 企业版 Enterprise版密钥试了下OK:BF8Y8-GN2QH-T84XB-QVY3B-RC4DF 建几个空项目瞧瞧有什么变化: 1.建个.net core控制台应用: 下一步,编辑项目名称: 代码

Visual Studio 2015在.NET Core RC2项目中的一个错误。

更新了.NET Core RC2 之后,VS的Web Tools更新为“Preview 1”了. 这个版本有一个问题,害我折腾了一个下午. 就是在项目界面的“依赖项 - NPM”上面错误地显示了不必要的“未安装”. 当时我看见这个大叹号和“未安装”三个字,就开始各种折腾,清空.更新NPM.逐个删除包,后来就定位到webpack这个包,把它去掉,就显示正常了. 但是让人纳闷的是,npm的安装日志里并没有什么错误,当时webpack都已经安装成功了啊,而且都能用的. 再后来就发现webpack依赖的

Visual Studio 2019 preview中体验C# 8.0新语法

准备工作: Visual Studio 2019 Preview版本中并没有包含所有的C# 8.0的新功能,但目前也有一些可以试用了.在开始之前,需要进行入两项设置: 将Framework设置为.net core 3.0 将C#语法设置为8.0 也可以直接编辑.csproj文件,修改TargetFramework和LangVersion为如下形式: <TargetFramework>netcoreapp3.0</TargetFramework>     <LangVersio

第二章 指南(2)用 Visual Studio 和 ASP.NET Core MVC 创建首个 Web API

小分享:我有几张阿里云优惠券,用券购买或者升级阿里云相应产品最多可以优惠五折!领券地址:https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=ohmepe03 原文:Building Your First Web API with ASP.NET Core MVC and Visual Studio 作者:Mike Wasson 和 Rick Anderson 翻译:谢炀(kiler) 校对:何镇汐.

使用Visual Studio Code开发.NET Core看这篇就够了

原文:使用Visual Studio Code开发.NET Core看这篇就够了 作者:依乐祝 原文地址:https://www.cnblogs.com/yilezhu/p/9926078.html 在本文中,我将带着大家一步一步的通过图文的形式来演示如何在Visual Studio Code中进行.NET Core程序的开发,测试以及调试.尽管Visual Studio Code的部分功能还达不到Visual Studio的水平,但它实际上已经足够强大来满足我们的日常开发.而且其轻量化,插件化

【译】Visual Studio 2019 中 WPF &amp; UWP 的 XAML 开发工具新特性

原文 | Dmitry 翻译 | 郑子铭 自Visual Studio 2019推出以来,我们为使用WPF或UWP桌面应用程序的XAML开发人员发布了许多新功能.在本周的 Visual Studio 2019 版本 16.4 和 16.5 Preview 1中,我们希望借此机会回顾一下全年的新变化.如果您错过了我们以前的版本,或者只是没有机会赶上,那么此博客文章将是您可以看到我们在整个2019年所做的每项重大改进的地方. XAML实时调试工具: XAML C# Edit & Continue 现

【广州.NET社区推荐】【译】Visual Studio 2019 中 WPF &amp; UWP 的 XAML 开发工具新特性

原文 | Dmitry 翻译 | 郑子铭 自Visual Studio 2019推出以来,我们为使用WPF或UWP桌面应用程序的XAML开发人员发布了许多新功能.在本周的 Visual Studio 2019 版本 16.4 和 16.5 Preview 1中,我们希望借此机会回顾一下全年的新变化.如果您错过了我们以前的版本,或者只是没有机会赶上,那么此博客文章将是您可以看到我们在整个2019年所做的每项重大改进的地方. XAML实时调试工具: XAML C# Edit & Continue 现

【突发】【WinForm】Visual Studio 2019 16.4.6 更新之后的意外之喜

正文 ? 今天下班回家的路上,在群里发现群友说Visual Studio 2019更新了,貌似支持了WinFrom的designer文件.回家之后,打开心爱的小本本,将Visual Studio 2019完之后,去巨硬的官方看了一下更新公告. 发现并没有列出此项作为更新项.又失望的以为群友在晃点我.然后,建立了一个测试工程.发现沙雕群友竟然没有晃点我~ 让我们来看看这次更新带来的意外之喜吧~ 建立项目 打开VS2019,点击创建新项目,选择模板的时候.选择Windows Forms App(.N

Visual Studio 2010编译时总是提示&quot;调用目标发生了异常&quot;的解决

现象: 无论建立的是Win32 Console的解决方案,还是MFC的解决方案,重新打开Visual Studio 2010之后,编译时总是提示“调用的目标发生了异常” 解决: 1. 关闭Visual Studio 2. 找到.sln所在目录,用文本编辑器打开sln文件,发现有如下的定义 GlobalSection(PowerDesigner) = preSolution HasSWS = 1 EndGlobalSection     剁了这三行 3.  删除.suo文件 4.  重新打开Vis