Publish website without roslyn
Asked Answered
N

6

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.

Nerva answered 29/8, 2015 at 5:2 Comment(3)
Also, Roslyn is just a set of DLLs. The host cannot know or care what they do.Tensor
@Slaks IIS trying to execute csc.exe. See edit.Nerva
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!Hebe
G
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".

Gutow answered 30/8, 2015 at 9:30 Comment(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?Rutherfordium
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.Gutow
i removed it from reference path and also from package.config file but still it compiled with roslyn. Now what should i do ?Curet
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.Gutow
helped me a lot: blog.gldraphael.com/…Seoul
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?Waxy
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.Hosey
@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.Sheehy
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...Bloomington
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.Bipropellant
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.Doggett
if we remove this dll from bin folder then possible to occur this problem may be it happened? https://mcmap.net/q/127066/-the-codedom-provider-type-quot-microsoft-codedom-providers-dotnetcompilerplatform-csharpcodeprovider-quot-could-not-be-located/9163169Sealskin
M
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

Mien answered 26/11, 2015 at 23:15 Comment(2)
This way you cannot use C#6 features in views.Lalalalage
I am facing this issue in v3.6.0. Any ideas why?Cinnabar
P
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

Proposal answered 24/11, 2015 at 6:13 Comment(0)
P
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

Perse answered 27/3, 2017 at 10:15 Comment(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. ThanksAssignment
A
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.

Attract answered 15/8, 2017 at 13:57 Comment(0)
C
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.

Cohen answered 10/9, 2016 at 5:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.