我正在尝试运行ASP。NET MVC(模型-视图-控制器)项目从TFS (Team Foundation Server)源代码控制检索。我已经添加了所有程序集引用,我能够成功地构建和编译,没有任何错误或警告。

但是我在浏览器中得到以下错误:

找不到路径的一部分 “C: \ B8akWorkspace \ B8akProject \ B8akSolution \ B8AK.Portal \ bin \ roslyn \ csc.exe”。

以下是错误页面的完整截图。

经过几天的研究,我了解到Roslyn是一个提供高级编译特性的. net编译器平台。但是,我不明白为什么我的构建试图找到\bin\roslyn\csc.exe,因为我没有配置任何与roslyn相关的东西。我也没打算让罗斯林参与我的项目。


当前回答

The answer for this is different for Website project and Web application Project. The underlying issue is same that NuGet package is behaving differently on different machine. It may be rights issue or some execution policy which stops it from copying to Bin folder As you know Roslyn is new compiler. you should have it in Bin folder for these Projects Go to your website NuGet Packages check this Folder Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0 \code\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0 Do you see it ? Can you see code\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\tools\RoslynLatest in it Now as part of compiling this Folder should get copied to your website under bin like this. \code\WebSite1\Bin\Roslyn some how that is not happening for you . Try running Visual studio as Admin . Copy Roslyn folder manually. Try uninstall and install of NuGet Package. Remember this package compile your folder and if its not there you cannot compile anything and so you cannot add anything too. Try copying this package to offline version tools -> options-> nuget package Manager->Package source-> Microsoft Visual Studio Offline Packages C:\Program Files (x86)\Microsoft SDKs\NuGetPackages

其他回答

在我的情况下,当我同时运行两个visual studio IDE时,我就遇到了这个问题。因此,解决方案是清理项目并关闭另一个实例。

我不得不改变WebAPI和MVC项目文件,不构建视图:

<MvcBuildViews>false</MvcBuildViews>

这解决了我的TFS 2015构建服务器错误与罗斯林。仍然不确定为什么csc.exe被复制到\bin\csc.exe,但发布进程正在寻找\bin\Roslyn\csc.exe…找不到导致这种差异的变换。

重新启动Windows。

这是唯一的解决方案,工作后,我尝试重建,删除bin和重建的内容,重新启动Visual Studio。

这是c# /有多糟糕的另一个例子。NET构建工具。

我认为(在阅读了许多答案后),总的结论是,这个问题的原因和解决方案在很大程度上取决于设置和项目,所以如果一个答案不起作用,就尝试另一个。尝试非侵入性/破坏性的解决方案,如重新启动Visual Studio,重新启动,重建等,首先,在乱动NuGet包或重新安装开发工具之前。好运!

(注意:使用Visual Studio 2019,项目文件最初是在Visual Studio 2015中创建的。也许这有助于某人调查这个问题)

(编辑:这可能是由于安装/修改Visual Studio安装后没有重新启动或当安装程序提示重新启动时更新Visual Studio造成的吗?)

打开项目文件,用Import project ="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0....删除所有引用

开放网络。配置并删除所有系统。代码dom编译器属性

其他的答案都对我没用。在做了一个文件夹比较之前/之后与我预期提交的文件,我发现GIT忽略了一个必需的文件夹。如果跟踪存储库中的编译器,请确保跟踪BUILD文件夹。如果不是,编译器将永远不会被构建,并将在发布后抛出这个确切的错误。我在我的.gitignore文件中添加了这一行:

!**/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1/build/

现在它可以正确地部署到其他计算机上。