发布没有 Roslyn 的网站

我正在尝试使用 Visual Studio 2015和.NET 4.5.1创建 Web 应用程序。 当我发布网站,视觉工作室创建名为 roslyn文件夹。

enter image description here

我知道它是用来动态编译代码的,但不幸的是,我的托管提供商不允许我在他们的服务器上执行编译器。

如何像以前版本的 VisualStudio 一样发布没有 roslyn的网站?

编辑: 当我试图访问我的网站时,我得到了这个错误。

enter image description here

似乎 IIS 试图执行 roslyn\csc.exe,但我的用户帐户没有这样做的权限。在以前版本的 VisualStudio 中,此错误不会显示。

59583 次浏览

I've just faced the same problem. When you create a new web project, two nuget packages automatically added to your project. If you remove them, your problem should be solved. Package names are: "Microsoft.CodeDom.Providers.DotNetCompilerPlatform" and "Microsoft.Net.Compilers".

After searching the same issued I face, I just came here. I read the above answer which is right.

I give the answer, because of Here is the good article to explain :

  1. Why the publish code have this exe as well as development environment ?
  2. What is the benefit and how to remove?

This is also the very good article, about the history of this exe

I had the same issue. Followed the steps from here. Basically:

  1. Uninstall the package

    Uninstall-package Microsoft.CodeDom.Providers.DotNetCompilerPlatform <Your Web API project name>
    
  2. In your publish profile settings, uncheck "Allow precompiled site to be updatable". You can find this under Settings > Precompile during publishing > configure

I have had the same issue in Sept2016 when I took over an existing ASP.NET program. I found that there were multiple versions of the two compiler packages mentioned by Kemal installed in different projects of the solution.

So firstly I updated to get them the same. VS doesn't tell you that updates are available in this scenario (or maybe I missed them ?)

I then had to restart VS2015 for the packages to clean up properly.

After countless effort....and according to this website. I find that you can use /p:UseWPP_CopyWebApplication=true /p:PipelineDependsOnBuild=false in MSBuild to transform web.config, this also include the roslyn compiler in the build. The output is same as what you get by publishing in Visual Studio into file system

There is an open bug on the roslyn repository about this issue.

In my case all I had to do was to downgrade the dll Microsoft.CodeDom.Providers.DotNetCompilerPlatform from version 1.0.6 to 1.0.5.