Anyone Successfully Using C# 6.0 on Azure?

I'm getting a System.Web.HttpCompileException when my module is compiled dynamically on Azure. I recently added C# 6.0 syntax and it seems that the compiler being used in Azure doesn't support it yet. I found this:


where it says the issue has been resolved. I also tried adding the workaround they mentioned, namely adding the following App Setting in the Azure portal:


That didn't work either... should I be able to compile C# 6.0 in Azure?

Error is below:

System.Web.HttpCompileException (0x80004005): d:\home\site\wwwroot\Modules...\MyClass.cs(13): error CS1002: ; expected

I checked this file and it is, in fact, a new C# 6.0 syntax causing the issue.

Re: Anyone Successfully Using C# 6.0 on Azure?

I found the following from MS support in response to my very simple repro case (I'd taken Orchard out of the picture entirely to just get any C# 6 compiling and just had a single aspx file with some inline C# 6.0 and a web.config file):

In web.config, within the <configuration> </configuration> tags, add the following section: <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701"/> </compilers> </system.codedom>

Create a Bin folder under your application root, and then add the following (which should be generated when building a VS project):

Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll and the "Roslyn" folder

When I did the above it started working. Now I'd like to take this fix and hopefully get my Orchard app compiling as well. However, I have another issue to work out first. I figured I'd upgrade from 1.9.1 to 1.10.1 as part of this update and I can't seem to get Orchard 1.10.1 to even build at all in Azure (without my C# 6.0 code even present).

Anyway hopefully the above helps someone and if I figure out the rest I'll post details.

Wednesday, May 4, 2016 4:06:25 AM byBrent
  • Brent
  • Lv. 01 Rookie
  • Total EXP: 6

Re: Anyone Successfully Using C# 6.0 on Azure?

Ok, great, thanks! I'll check out those GitHub issues.

I assumed 1.10.1 was the latest stable release (wasn't sure what 1.10.x was exactly but assumed it was the active/unstable work on 1.10.2).

Anyway, I forked Orchard and then set 1.10.1 full source from that fork as the deployment source for a new deployment slot in Azure. It failed with all kinds of warnings and errors after a few minutes.

Warnings were things like:

2016-05-03T22:03:06.9178801Z,D:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1819,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Autofac, Version=, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\home\site\repository\src\Orchard\Orchard.Framework.csproj],,0


2016-05-03T22:03:07.2147548Z,D:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.CSharp.CurrentVersion.targets(133,9): warning MSB3884: Could not find rule set file "AllRules.ruleset". [D:\home\site\repository\src\Orchard\Orchard.Framework.csproj],,0

The first error lines was:

2016-05-03T22:03:25.8865109Z,Mvc\Html\LinkExtensions.cs(5,18): error CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) [D:\home\site\repository\src\Orchard\Orchard.Framework.csproj],,0

I followed the exact same steps with 1.9.1 and it worked. It took almost 40 minutes, which made me question if this is the best deployment model (especially when I have small updates to my modules), but at least it worked. Maybe this isn't the best way to deploy and maybe I should be using pre-compiled or something but I wanted to get something to work where I could work locally against the full source (for debugging/understanding purposes) and just check my code in, including any custom modules, and have it auto-deploy to an Azure slot.

Saturday, May 7, 2016 4:11:15 PM byBrent
  • Brent
  • Lv. 01 Rookie
  • Total EXP: 6

Post a reply

You need to be signed in to post a reply.

Sign In