94

I am trying to create web application using Visual Studio 2015 and .NET 4.5.1. When I publish the website, visual studio create folder named roslyn.

enter image description here

I know it's used to compile code on the fly, but unfortunately my hosting provider doesn't allow me to execute the compiler on their server.

How to publish the website without roslyn like previous version of Visual Studio?

EDIT: I got this error when trying to acces my website.

enter image description here

It seems IIS trying to execute roslyn\csc.exe but my user account doesn't have permission to do that. With previous version of Visual Studio, this error doesn't show up.

Niyoko
  • 7,512
  • 4
  • 32
  • 59

6 Answers6

188

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".

Kemal Kefeli
  • 2,276
  • 2
  • 18
  • 22
  • This worked and is apt with third party web-hosting providers. Have two queries on this- 1) Can removal of these Nuget packages affect the product in any way? 2) Can these packages be removed from the project template itself to avoid this exercise everytime? – nura Jan 05 '16 at 04:51
  • 1) There isn't any affect on product's workflow or logic; but the url (http://www.itorian.com/2015/09/roslyn-cscexe-and-vbcexe-deployment-on.html), which is provided by @Ajay2707, says this package affects page load time. 2) I don't know how can you do this, but if you can there sohuldn't be any problem. – Kemal Kefeli Jan 05 '16 at 05:25
  • i removed it from reference path and also from package.config file but still it compiled with roslyn. Now what should i do ? – Kushal Jain Apr 01 '16 at 04:33
  • Try this, right click to solution and select **manage nuget packages for solution**. Then find two packages as mentioned above and uninstall them from all projects. – Kemal Kefeli Apr 01 '16 at 18:15
  • helped me a lot: http://blog.gldraphael.com/removing-roslyn-from-asp-net-4-5-2-project-template/ – Yonatan Ayalon Jul 21 '16 at 05:20
  • 3
    Removed both NuGet packages. Removed config declaration. Still this folder is being created while compilation or publish.. Only NuGet package my application is using is "Newtonsoft.Json". Do I need to uninstall it too? – Ranjan Kumar Aug 04 '16 at 08:50
  • 8
    Keep in mind that removing these packages will break the use of C# 6 features. This could be solved by unchecking ""Allow precompiled site to be updatable" which pre-compiles the views ect. – Rutix Nov 15 '16 at 12:38
  • 10
    @RanjanKumar: Open your csproj file in a text editor and remove the nodes corresponding to the NuGet packages described in Kemal's answer. This might include `Import` nodes, `Target` nodes (EnsureNugetPackageBuildImports), and `Reference` nodes. Also remove the `` node of your web.config. – Brian Dec 07 '16 at 21:47
  • I'm trying to understand IF I need this Roslyn compiler or not. I have a .NET WebAPI2 project and it seems to include it by default. However, my CI process (using BitBucket Pipelines) uses MONO and it throws this error: " Error building target IncludeRoslynCompilerFilesToItemGroup: Item has already been added. Key in dictionary: 'Link' Key being added: 'Link'" . I remove them and my API project works fine (I am using Angular2, NOT MVC)). I don't fully understand WHY I would need it or if this is a good move... – Rodney Feb 12 '17 at 17:24
  • After VS 2017 and a increase in Roslyn caused problems, I have made it a mandatory step in any VS project to remove Rosly, the newest bump on the road can be that VBCSCompiler.exe is running after a build, effectively locking the last few remnants of the roslyn dll. – Christopher Bonitz Sep 27 '17 at 16:17
  • Wow! Thanks for this. Thought I was going crazy as I had older sites and had been publishing weekly to beanstalk for a year with no issues. I created a simple site with same framework and could not. I can't help but think this may deter people from using aws over azure. Seems very suspect. – RandallTo Apr 12 '18 at 20:34
  • if we remove this dll from bin folder then possible to occur this problem may be it happened? https://stackoverflow.com/q/33319675/9163169 – Brijesh Mavani Oct 17 '18 at 11:10
18

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

Alexei - check Codidact
  • 22,016
  • 16
  • 145
  • 164
Midas
  • 189
  • 1
  • 2
2

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

Ajay2707
  • 5,690
  • 6
  • 40
  • 58
2

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

code4j
  • 4,208
  • 5
  • 34
  • 51
  • Can't understand the article on the website link, but following your advice to add that build parameters in MSBuild works.. Like you said, the output is the same as when we publishing into file system. Thanks – Bruce Oct 18 '18 at 00:31
2

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.

Felipe Miosso
  • 7,309
  • 6
  • 44
  • 55
0

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.