ASP. NET 5 adventure (4): how to upgrade ASP. NET 5 from beta4 to beta5 and beta4beta5
(This article is also published in my public account "dotNET daily excellent article". Welcome to the QR code on the right to follow it .)
Question: the previous article described some changes brought about by ASP. NET 5 Beta. Although the original article finally gave an introduction to upgrading from beta4 to beta5, it was too brief and vague. I will share my experience with you today.
I upgraded my ASP. NET 5 project code from beta 4 to beta5 and followed the basic steps mentioned in the previous article.
1. install or upgrade DNVM.
If you do not have. NET Version Manager (DNVM), you need to install it using the following code (if you have executed the following code, it will be upgraded to the latest Version ):
1: @powershell -NoProfile -ExecutionPolicy unrestricted -Command "&{$Branch='dev';iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.ps1'))}"
Theoretically, execute the above Code to install (or upgrade) The dnvm to "beta6-10395", the obvious difference is that there is an additional "update-self" command.
If you already have a dnvm of beta4, You need to restart the command line window to view the latest dnvm version after running the preceding command. Of course, I also encountered a strange problem, after the above code is executed, you cannot upgrade the Code. In the end, you have to perform the second step (see upgrade DNX runtime) first, then we can see that the dnvm is automatically upgraded to the latest version.
2. Upgrade DNX to run.
If the DNVM is upgraded normally, you do not need to set the "DNX_FEED" environment variable because the default address of the latest DNVM version is "https://www.nuget.org/api/v2 ". Now you only need to execute "dnvm upgrade" to download and install ASP. NET 5 Beta5 Runtime (the default is clr x86), the runtime is automatically set to the activation status and default alias.
Of course, if you have not upgraded DNVM, you can set "DNX_FEED" and then upgrade DNX runtime.
You can also directly execute dnvm upgrade without setting "DNX_FEED" to upgrade to the prerelease version (beta5-12103) of beta5 first ). Upgrading to the prerelease version of beta5 will upgrade dnvm at the same time, and then execute "dnvm upgrade" again to upgrade to the official release version of beta5. (Here we will talk about the special steps mentioned above ).
3. Modify the package reference in project. json.
Open the project of all projects in the solution. for json files, replace all the packages with the suffix "beta4" with "beta5" and save the project. after the json file is created, VS automatically updates the latest beta5 package.
It should be noted that the xunit related package should be changed to reference beta5 compiled version, that is, "xunit": "2.1.0-beta3-build3029", "xunit. runner. dnx ":" 2.1.0-beta3-build99 ".
Modify Configuration-related packages from "Microsoft. Framework. ConfigurationModel" to "Microsoft. Framework. Configuration ".
Change the suffix of "Interfaces" to "invalid actions ".
4. Fix code changes. According to the updates mentioned in the previous article, especially the change list is broken (https://github.com/aspnet/announcements/issues? Q = milestone % 3A1. 0.0-beta5) to modify the problematic code. Major modifications include:
- The Code interface (from attribute to method) is modified in EF7 Migration. To avoid a large amount of code modification, I re-built Migration. If you need to modify, see: https://github.com/aspnet/Announcements/issues/35
- Change the namespace "Microsoft. Framework. ConfigurationModel" to "Microsoft. Framework. Configuration ".
- Modify IConfiguration. GetSubKey to IConfiguration. GetConfigurationSection.
- _ GlobalImport. cshtml is renamed to _ ViewImports. cshtml. After modification, VS2015 may report that the type is not referenced, so ignore it (wait for VSWebTools to be updated)
- The Code "db. Database as SqlServerDatabase" mentioned in the EF data migration article should be changed to "db. Database as RelationalDatabase"
- In a unit test, services. AddLogging () must be explicitly executed ()
The above are some of my experience upgrading to beta5. If you have any questions, you can discuss with me.