How do you install the Roslyn compiler in upgraded Kentico 11 without Visual Studio?

Stephen Price asked on May 10, 2018 18:03

My team is getting ready to upgrade from Kentico 8.2 to Kentico 11. On the 10-11 leg of the upgrade, the Microsoft.CodeDom.Providers.DotNetCompilerPlatform Nuget package needs to be installed. This is the Roslyn compiler package needed to allow the instance to execute C# 6+ code included in the upgrade.

The recommended way to accomplish this is to use Visual Studio. That's fine for a developer testing the upgrade procedure, but when we run this for real it will be on our servers which have limited disk space and no Visual Studio.

Is there a way to install this package using nuget.exe?

For context, ours is an old Website project, not a Web Application. I've tried nuget install ... several times to no avail and I'm not sure if that's because there's some wrinkle in dealing with this scenario I'm not aware of?

Correct Answer

Brenden Kehren answered on May 10, 2018 21:36

To answer your specific question "How do you install the Roslyn compiler in upgraded Kentico 11 without Visual Studio?", the simplest thing to do is create/install a new instance of Kentico 11 code on your local machine. Copy the files from the version 11 instance to the v10 instance.

More specifically:

  1. copy all files in the /CMS/bin/roslyn
  2. Copy the packages.config file from the /cms directory
  3. Update your web.config in the /cms directory to include this node:

<system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" /> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" /> </compilers> </system.codedom>

This should get you by without needing to install anything using Visual Studio. I'm also assuming you are simply FTP'ing the files.

4 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on May 10, 2018 20:09

Check the documentation

if your project is upgraded from Kentico 9 or older, you may be missing the package. In these cases, you need to install the package before applying the upgrade:

  • Open your Kentico solution in Visual Studio.
  • Right-click the main web project in the Solution Explorer and select Manage NuGet Packages.
  • Install the Microsoft.CodeDom.Providers.DotNetCompilerPlatform NuGet package (version 1.0.2 or newer).
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.