The. NET Core 2.1 has finally been released, so get an upgrade.
I. Installing the SDK
Start now and install the SDK (64-bit)
After installation, if you see a new item, you will already have 2.1 options.
Two. Update existing 2.0 items to 2.11. Modify the project version
Right-click the project in the Solution Manager and select Edit project name. csproj
Will <targetframework>netcoreapp2. 0</TargetFramework> in 2.0 to 2.1, save.
2. Replace the reference Microsoft.AspNetCore.All with the MICROSOFT.ASPNETCORE.APP
Find Microsoft.AspNetCore.All in Project dependencies, remove it, search and install in nugget Microsoft.AspNetCore.App
Note: The following content is still included in the Microsoft.AspNetCore.All , and the Microsoft.AspNetCore.App does not exist
-
Microsoft.AspNetCore.ApplicationInsights.HostingStartup
-
Microsoft.AspNetCore.AzureAppServices.HostingStartup
-
Microsoft.AspNetCore.AzureAppServicesIntegration
-
Microsoft.AspNetCore.DataProtection.AzureKeyVault
-
Microsoft.AspNetCore.DataProtection.AzureStorage
-
MICROSOFT.ASPNETCORE.SERVER.KESTREL.TRANSPORT.LIBUV
-
Microsoft.AspNetCore.SignalR.Redis
-
Microsoft.Data.Sqlite
-
Microsoft.Data.Sqlite.Core
-
Microsoft.EntityFrameworkCore.Sqlite
-
Microsoft.EntityFrameworkCore.Sqlite.Core
-
Microsoft.Extensions.Caching.Redis
-
Microsoft.Extensions.Configuration.AzureKeyVault
-
Microsoft.Extensions.Logging.AzureAppServices
-
Microsoft.VisualStudio.Web.BrowserLink
So if you need to use this content in your project, you can refer to them separately, rather than recommending the overall reference Microsoft.AspNetCore.All
3. Modifying other references
Open the *.csproj file again and you can see that the corresponding Microsoft.AspNetCore.All has been replaced with Microsoft.AspNetCore.App .
Remove various <dotnetclitoolreference include="********" version="2.0.3 " /> For example: <dotnetclitoolreference include=" Microsoft.EntityFrameworkCore.Tools.DotNet "version="2.0.3 "/ >
Eventually this *.csproj file looks like this
<project sdk="Microsoft.NET.Sdk.Web"> <PropertyGroup> <targetframework>netcoreapp2.1</TargetFramework> <usersecretsid>aspnet-{project name}-{guid}</usersecretsid> </ propertygroup> <ItemGroup> <packagereference include="Microsoft.AspNetCore.App"/> <packagereference include="Microsoft.VisualStudio.Web.CodeGeneration.Design"version="2.1.0"privateassets=" All"/> </ItemGroup></Project>
4. Modify Program.cs
Modify the Main method and the Buildwebhost method, the result is as follows
Public class program { publicstaticvoid Main (string[] args) { Createwebhostbuilder (args). Build (). Run (); } Public Static Iwebhostbuilder Createwebhostbuilder (string[] args) = webhost.createdefaultbuilder (args) . Usestartup<Startup>(); }
5. Modify Startup
The modified code example below, mainly new lines, delete Usebrowserlink, see the following code color callout
usingMicrosoft.AspNetCore.Builder;usingMicrosoft.AspNetCore.Hosting;using microsoft.aspnetcore.http;using Microsoft.AspNetCore.Mvc;usingMicrosoft.Extensions.Configuration;usingMicrosoft.Extensions.DependencyInjection;namespacewebapp1{ Public classStartup { PublicStartup (iconfiguration configuration) {Configuration=configuration; } PublicIConfiguration Configuration {Get; } Public voidconfigureservices (iservicecollection services) { services. Configure <CookiePolicyOptions> (Options + =//This lambda determines whether user consent F or non-essential cookies are needed for a given request. Options. checkconsentneeded = Context = true; Options. Minimumsamesitepolicy = Samesitemode.none; }); Services. ADDMVC () . Setcompatibilityversion (compatibilityversion.version_2_1); } Public voidConfigure (Iapplicationbuilder app, Ihostingenvironment env) {if(Env. Isdevelopment ()) {
//app. Usebrowserlink (); Delete this line app. Usedeveloperexceptionpage (); } Else{app. Useexceptionhandler ("/error"); app. Usehsts (); } App. Usehttpsredirection (); App. Usestaticfiles (); app. Usecookiepolicy (); App. Usemvc (); } }}
Three. Other changes
- A new file was added to the shared folder _cookieconsentpartial.cshtml, referenced in the _layout file <partial name=" _cookieconsentpartial " />
- The jquery.validate.js version in the _validationscriptspartial.cshtml file has been upgraded to 1.17.0
- jquery upgrade from 2.2.0 to 3.3.1
Four. A little depressing thing
See 2.1 release, first did not go to download the SDK instead of to see if there is an update, I would like to update vs when the SDK can be updated by the way. The current version 15.7.1, the official documentation prompted a few days ago 15.7.2 release, vs in check update has not been.
Download the SDK after the installation, finally the top right corner of the small flag on the prompt for updates, all kinds of retries are not moving no download progress.
Finally, no matter what it finds, it starts the update in a weird way ...
ASP. NET Core 2.1:10. Upgrading existing Core2.0 projects to 2.1