.Net报错Could not find a part of the path bin\roslyn\csc.exe
维护一个老网站,用vs2022打开后build能成功,但是在IIS里运行的时候会报错:
Server Error in '/' Application.
Could not find a part of the path '...\bin\roslyn\csc.exe'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.DirectoryNotFoundException: Could not find a part of the path '...\bin\roslyn\csc.exe'.
在build的时候尝试找到\bin\roslyn\csc.exe,因为项目添加了
Microsoft.CodeDom.Providers.DotNetCompilerPlatform
Microsoft.Net.Compilers
这两个包,可以在packages.config里找到他们。
什么是Roslyn?谁在项目中添加了它们?
如果您使用 .net Framework 4.5.2 使用 VS2015 创建项目,您可能已经注意到项目模板默认使用 Roslyn。 实际上,Roslyn 是 Microsoft 的 .NET 语言的开源编译器之一。
如果你的项目有 Roslyn 引用并且您有兴趣将其部署在服务器上,你会在网站上收到不必要的错误,因为许多托管服务提供商仍未升级其服务器,因此不支持 Roslyn。 要解决此问题,需要从项目模板中删除 Roslyn 编译器。
所以我们不需要使用Roslyn,我们就可以删除它们。
在Package Manager Console里执行命令删除package:
PM> Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform
PM> Uninstall-package Microsoft.Net.Compilers
对于我的项目我只添加过第一个个包所以只需要执行第一条就可以了。删除包后网站可以正常运行了。
更新于:4天前相关文章
- ASP.NET Core 2.1中的ActionResult<T>
- .NET Core 3.0创建一个单独的可执行文件
- 在ASP.NET Core 2.1中使用HttpClientFactory的3种方法
- .NET Core MVC应用程序创建教程
- .NET Core中的File和PhysicalFile
- .NET Core 读取配置文件方法
- .NET Core 管道模型中间件及管道模拟实现
- ASP.NET Core多环境配置
- .NET Core 日志配置,NLog配置示例
- .NET Core SkiaSharp替代System.Drawing的用法
- .NET Core 3.X路由中间件和终结点中间件
- IIS中.NET Core报错HTTP Error 500.31 - ANCM Failed to Find Native Dependencies
- .NET Core分部视图PartialView用法
- .NET Core 视图组件Component用法
- ASP.NET Core的三种部署方式
- .NET Core中使用System.Drawing处理图像
- .NET Core Razor Page ajax请求返回400 Bad request
- .NET Core上传文件报Access xxx.tmp is denied错误
- ASP.NET Core 使用Razor code blocks替代@helper
- .NET Core Razor page/MVC 返回json忽略空属性