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

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

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

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

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


当前回答

以我为例,在尝试任何其他解决方案之前,我切换到“发布”配置,重新创建(文件夹被创建),然后切换回“调试”,而文件夹保持不变。

这是从旧解决方案的源代码控制中签出的,显然原始(自动)包恢复和构建项目并没有在bin目录中创建该文件夹。

注意,在撰写本文时,被指责的组件已经达到v.2。

其他回答

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

TL;博士

在包管理器控制台中运行:

更新- package Microsoft.CodeDom.Providers.DotNetCompilerPlatform -r

更多的信息

这个问题与Visual Studio本身无关,因此建议添加构建步骤来复制文件的答案是一种变通方法。与手动向项目添加编译器二进制文件相同。

Roslyn编译器来自一个NuGet包,在该包的某些版本中有/曾经有一个bug(我不知道具体是哪些版本)。解决方案是重新安装/升级该包到无bug的版本。最初,在我写回2015年的答案之前,我通过在特定版本安装以下包来修复它:

Microsoft net.compilers 1.1.1 Microsoft. CodeDom. Will the DotNetCompilerPlatform 1.0.1

然后我查看了.csproj,并确保包的路径是正确的(在我的情况下..\..\packages\*.*)在标签<ImportProject>在顶部和<Target>与名称“EnsureNuGetPackageBuildImports”在底部。这是在MVC 5和。net Framework 4.5.2上。

这是Microsoft.CodeDom.Providers.DotNetCompilerPlatform 1.0.6的一个已知问题。降级到1.0.5为我解决了这个问题。

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

<MvcBuildViews>false</MvcBuildViews>

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

我有一个项目在VS2019中运行,然后我第一次打开(在VS2019中)另一个项目,我得到了上述问题。我所做的如下:

我关闭正在运行的项目, 清理并重新构建新项目

只有一点没有。2号不适合我。