4
votes

I'm currently using the new throw expression in C# as such:

_configurator = configurator ?? throw new ArgumentException(nameof(configurator));

It compiles just fine inside Visual Studio 2017 however when deploying to my staging slot from my version control (in this case BitBucket) it fails with:

Repositories\UserRepository.cs(46,45): error CS1525: Invalid expression term 'throw' [D:\home\site\repository\foo\foo.csproj]

This occurs in several places across my project.

How can I set my WebApp to allow compilation of this new throw feature? The only workaround I found right now is to compile it locally and publish manually through Visual Studio. I would like to use the automated deployment option that Azure allows.

I found this error that relates to a local project but I'm not sure how to upgrade the Microsoft.Net.Compilers on the WebApp. My slot is set to .NET 4.6

Thanks,

1
You may also be required to update the MSBuild tools on your server - VMAtm
@VMAtm Adding Microsoft.Net.Compilers per David's answer solved the issue - Aaron Jordan

1 Answers

4
votes

Try adding a reference to the Microsoft.Net.Compilers NuGet package in all the projects in the solution. See https://github.com/projectkudu/kudu/issues/2350 for more details on this.