Where to configure Razor page language version to C# 6? - c#

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?

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.

Related

.NET Desktop Runtime is required before installation

I've developed an application in .NET 5.0, also, I've a Setup Project to install this application in my clients.
My steps are:
1.- Publish the .NET 5.0 Application.
2.- Compile the Setup project.
3.- Install the setup.exe generated in "2" in the client.
But when I try to install the program in my client, windows says "This installation requires the 5.0.0(x64) version of .NET Desktop Runtime... So I've to download and install the SDK in every client.
My question is: There is some way to avoid this SDK installation? Can I embeed the .NET Desktop Runtime in the .NET 5.0 App or in the Setup Project?
Thanks in advance.
See .NET application publishing overview, specifically publishing a self-contained application. That way all necessary framework files will be included in your application, and you will not the framework to be installed. This will increase the disk requirement a bit if .Net 5 is already installed, since some files will be duplicated.
The alternative is to bundle the the .Net framework installer in your installation script. This will cause the setup-file to be quite a bit larger, unless the script downloads the framework on demand. But it may save some disk space in case there are multiple applications that use .Net 5.
Go on projet Menu/ projetct properties / publish / require components / uncheck you frameWork .

Which NET version takes priority when running an app System or Contained App

I am working on an app for NET 5 and because NET 5 isn’t released built into windows the main suggestion I have found is to create a contained app with the NET 5 runtimes. The issue with this as I understand it is that this can lead to security issues if new releases are not made and there are issues in NET 5.
So the question is which version would take priority.
A. The App contained NET5 runtimes.
Or
B. Newer Version NET5 runtimes installed in the Windows System separately.
For apps with self contained deployment, the only runtime version being used is the one bundled with the app itself. In that way, the apps are well isolated and side by side (3.1 apps can live nicely with 6.0 apps without breaking each other).
If you want an app to use the common runtime installed, you have to publish it with framework dependent deployment.
If your goal is to resolve vulnerabilities in self contained deployment, make sure that,
Your app can auto update itself
You publish new releases of your app whenever (likely to be monthly) Microsoft publishes a new runtime version.

Azure Mobile Apps Server on .NET 5

What is with this stuff? As of today, there is no support to write a backend in C#/Net.
The Repo is super old and does not contain anything but .NET Framework examples. The packages produced are obviously not NET 5 compatible, although this is not listed in the Nuget browser.
This seems to be the current site, but the server example in ASP.NET is broken and even the quickstart documentation for the client code refers to a deployment of the NodeJs server.
You can get the server example to compile by rewiring some dependencies to the Datasync projects in the Repo, however I wasn't able to run it (probably due to my lacking knowledge of Azure configuration stuff).
Any news?
ASP.NET Framework SDK for Azure Mobile Apps
Create an Azure Mobile Apps ASP.NET Framework backend
Download and initialize the SDK
select Manage NuGet Packages...., Install
Microsoft.Azure.Mobile.Server
Microsoft.Azure.Mobile.Server.Quickstart
Microsoft.Owin.Host.SystemWeb
Initialize the server project
Add Startup class
Include Microsoft SDK extensions
Microsoft.Azure.Mobile.Server.Quickstart, Microsoft.Azure.Mobile.Server.Home,
Microsoft.Azure.Mobile.Server.Tables, Microsoft.Azure.Mobile.Server.Entity,
Microsoft.Azure.Mobile.Server.Authentication,
Microsoft.Azure.Mobile.Server.Notifications,
Microsoft.Azure.Mobile.Server.CrossDomain,Microsoft.Azure.Mobile.Server.Login
Publish the server project in Azure
Please follow the ASP.NET Framework SDK for Azure Mobile Apps for reference.

How to Pick which Framework Version to Build app for C# Visualstudio

I am very new to C# development. Like Youtube tutorial new. I am trying to build a console app to install services to our servers. Is there a way to pick which .Net version you want to use to build the application? So that I the writer can tell the user which .Net version they should have in their system for the console app to run?
I am using Visual Studio 2019
Thanks to #David Browne's comment under my original post all you need to do is make sure to select .Net Framework version of the Console Application template in Visual Studio project template. Not .Net Core. I wasn't aware there was a difference:
"You set the Target Framework in the Project Properties. But the Project Type determines whether you're targeting .NET Framework or .NET Core"
You have 2 options to get started
.NET Framework - Apps build using .NET framework can only run on Windows. This is an years old proven and secure stable, mature eco system
.NET Core - Apps build using .NET Core can run on Windows, Linux and Mac. It's cross platform and open source. Latest is v5.0.
I recommend you to use the latest .NET Core v5 for your new projects. It's stable and Microsoft is well supporting it. .NET Core much is powerful, faster and optimized.
You can create different kinds of apps using .NET Core. You can create simple console apps, libraries or asp.net core web apps. MVC and WebAPI are supported. As you mentioned, if you want to create a service, There is "Worker Service" project available for .NET Core.
If you create a Worker Service it can run as a Windows Service in Windows machines and a Linux Deamon in Linux machines.
Visual Studio 2019 got well with .NET Core and it's features.
If you need to run a .NET Core project in Windows, Linux or Mac machine, you also need to setup the deployment machine installed with .NET Core runtime. It's available free from Microsoft website. Download.. Install.. Run. That simple

How to take care of the application before or after .Net framework upgrade in Azure App service

I have few applications developed using different .Net framework and deployed in Azure app service as web app and function app.
The applications developed using Visual Studio 2013 ( I think, .net 4.5.1) and Visual Studio 2019 (.Net 4.6) and deployed in Azure. The application type is ASP.Net MVC, Web app using .Net core and Azure function app.
Very recently MS announced that they are upgrading the .Net framework in Azure App service ( or basically in Azure platform). I think, Which is going to effect after 14 July 2020.
My Questions are, [considering very less time we have and applications are developed in old versions of Visual Studios] ;
will all these application work perfectly in Azure app service, after MS upgrade the framework?
I hope, the old versions of the .Net framework will still be exists in Azure/Azure app service along with the newly .Net versions?
The development PC does not have .net 4.8 version installed, installing, upgrading application's framework and testing the applications in very less time is quite impossible, is there any quick ways to do testing of entire application?
Is there any chance that application functionality will not work during this upgrade and there will be a downtime? Any one faced similar issues?
These applications are interaction with other enterprise application, what actions to be taken care?
Is there any step by steps guideline given by Microsoft those needs to followed?
Is there anyone facing similar issues? What is the best practice/ways to manage this in very less time ? Please let me know. Thanks
This is the announcement:
https://azure.github.io/AppService/2020/06/09/NET-Framework-4.8-is-coming-to-App-Service.html
The .NET Framework 4.8 update is a non-breaking in-place upgrade on App Service. No updates are required to existing applications.
All frameworks are installed, so you will have no issues. There should not be an extra amount of downtime for the upgrade.

Categories