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.

3
  • Also, Roslyn is just a set of DLLs. The host cannot know or care what they do.
    – SLaks
    Aug 30, 2015 at 1:14
  • 3
    @Slaks IIS trying to execute csc.exe. See edit.
    – Niyoko
    Aug 30, 2015 at 8:22
  • If you're using Plesk, you can disable the 'Dedicated IIS Application Pool for Your Websites' then you don't even need to remove those packages! Nov 25, 2015 at 8:29

6 Answers 6

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

12
  • 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 5, 2016 at 4:51
  • 1) There isn't any affect on product's workflow or logic; but the url (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. Jan 5, 2016 at 5:25
  • 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? Aug 4, 2016 at 8: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, 2016 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 <system.codedom> node of your web.config.
    – Brian
    Dec 7, 2016 at 21:47
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

2
  • 7
    This way you cannot use C#6 features in views.
    – RokX
    Apr 6, 2017 at 14:40
  • I am facing this issue in v3.6.0. Any ideas why?
    – Nitesh
    Feb 13, 2022 at 14:24
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

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

1
  • 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, 2018 at 0: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.

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.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.