Recently I've tried to use some C# 6 new feature (interpolated strings) in my ASP.NET MVC (5) .cshtml view, but when running got an error message complaining about the $
. It is clear the compiler in C# 5 compatibility mode, or worst it is a C# 5 compiler.
When in editor a popup warning warns me (I do not know it is VS or ReSharper) Feature 'Interpolated strings' is not available in C# 5. Please use language version 6 or greater.
The project itself was set to C# 6, and I can use C# 6 features in my build time compiled code like controllers etc.
Q: Where should I set page compiler version, and will this C# 6 compiler available when I deploy my web app to Azure there?
Navigate to Properties -> Build -> Advanced, select “C# latest minor version(latest)” to pick latest installed minor version. The C# latest major version is the default language version set, and choosing the “C# latest minor version” it will always refer to latest C# version, in this case it will refer to C# 7.2.
If you're using the latest version of Visual Studio 2019, C#, you may not see the option to change the C# language version of your project. This is a new change in Visual Studio 2019/. NET Core 3.0. The new C# compiler chooses the default version based on your .
Razor Pages is a newer, simplified web application programming model. It removes much of the ceremony of ASP.NET MVC by adopting a file-based routing approach. Each Razor Pages file found under the Pages directory equates to an endpoint.
Get C# Version using Command Prompt Using Visual studio Command prompt: csc /langversion:? C# compiler determines a default language version based on your project's target framework. The target project when built gets the highest compatible language version by default as per this versioning semantics.
From String interpolation in a Razor view?:
This only works in MVC6. Alternatively, also from a comment on this link, you'll need to add the roslyn code dom package from ASP.Net.
<div>
@($"Hello {this.Model.SomeProperty}")
</div>
As far as Azure is concerned, please see this link. http://azure.microsoft.com/blog/2015/08/11/update-on-net-framework-4-6-and-azure/
With great power… The tooling, framework and Azure platform teams want to ensure the powerful tools we give you to help build your dream is matched by the responsibility we recognize we have to keep it running in the cloud. At the time of the Visual Studio and Azure SDK 2.7 releases, Framework 4.6 wasn’t supported broadly throughout Azure. This is due in large part to the fact that just as many teams (or more) are responsible for the ongoing development and stability of the Azure platform.
For now, we have an update on the availability of .NET Framework 4.6 for Azure App Service and an article demonstrating how to get .NET Framework 4.6 working in your Cloud Service roles.
Azure IaaS For customers using Azure’s Infrastructure as a Service (IaaS) services, installation of .NET Framework 4.6 is manual. To install .NET Framework 4.6 on an Azure IaaS virtual machine, the process is as simple as logging into the virtual machine using Remote Desktop. Once on the machine, the .NET Framework 4.6 installer can be downloaded and installed directly onto the virtual machine. Customers using Azure Automation could also choose to automate the installation onto Azure virtual machines using PowerShell.
Azure App Service Update The Azure App Service team is nearing the end of the testing phase for .NET Framework 4.6 and planning the deployment to the environments. Currently, the plan is to roll out the updates to Azure App Service during August 2015.
Azure Cloud Services Saurabh Bhatia authored an article in the Azure documentation center outlining how to install the .NET Framework in a Cloud Service Role. The content has been recently updated to include commentary specific to .NET Framework 4.6. You can find the updated article here on the Azure documentation center.
For me installing the Microsoft.CodeDom.Providers.DotNetCompilerPlatform
NuGet package solved the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With