如何将ASP.NET Core 2.0应用程序升级至ASP.NET Core 2.1 RC?
Hey there! Upgrading your .NET Core 2.0 project to .NET Core 2.1 RC 1 is straightforward once you follow these steps:
1. Install the .NET Core 2.1 RC 1 SDK
First things first—you need to have the latest RC SDK installed on your machine. This lets you compile and run .NET Core 2.1 projects properly.
2. Update Your Project File (.csproj)
This is the core part of the upgrade. Open your project's .csproj file and make these key changes:
Update the Target Framework
Find the <TargetFramework> element and switch its value from netcoreapp2.0 to netcoreapp2.1:
<!-- Before --> <TargetFramework>netcoreapp2.0</TargetFramework> <!-- After --> <TargetFramework>netcoreapp2.1</TargetFramework>
Update NuGet Package References
If your project uses meta-packages like Microsoft.AspNetCore.App or Microsoft.NETCore.App, update their versions to match the RC release:
<!-- Before --> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.0.*" /> <!-- After --> <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0-rc1-final" />
Alternatively, you can use the .NET CLI to update packages directly:
dotnet add package Microsoft.AspNetCore.App --version 2.1.0-rc1-final
3. Update Global Tools (If Applicable)
If you’re using global tools like dotnet-ef, don’t forget to update them to the RC version too:
dotnet tool update --global dotnet-ef --version 2.1.0-rc1-final
4. Verify the Upgrade
To confirm everything works as expected:
- Run
dotnet --versionin your terminal—you should see the 2.1 RC SDK version (e.g.,2.1.300-rc1-008673) - Run
dotnet buildto compile your project, thendotnet runto test if it launches without errors
内容的提问来源于stack exchange,提问作者Vahid Ghadiri

