asp.net core 1.1 项目升级至 asp.net core 2.0 preview 2
2021-06-11 23:05
标签:onchange settings sync figure issue epo doc test group 这两天把一个 asp.net core 1.1 的项目迁移到了 asp.net core 2.0 preview 2 ,在这篇随笔中记录一下。 如果项目在有 global.json 文件,需要删除或修改为 .net 2.0 preview 2 的 sdk 版本号。 对于类库项目的 .csproj,需要把 TagetFramework 改为 netstandard2.0 ,比如 改为 对于单元测试项目,TargetFramework 需要改为 netcoreapp2.0 ,比如 改为 对于 web 项目,需要该动的地方很多。除了把 TargetFramework 改为 netcoreapp2.0 ,比如 改为 还需要: 1)移除所有对 Microsoft.AspNetCore 的引用 添加 Microsoft.AspNetCore 的引用 2)修改 Authentication 相关的代码 3) 针对 BundlerMinifier 的修改 在 asp.net core 2.0 preview 2 的 docker 容器中 build 项目,在执行 dotnet bundle 时出现下面的错误 这是由于 nuget 包 BundlerMinifier.Core 不支持 .net core 2.0 。github 上签出 BundlerMinifier 的源码(已增加了对.net core 2.0的支持),自己打包。 升级时不仅要升级 PackageReference 中的 BundlerMinifier.Core ,还要升级 DotNetCliToolReference 中的 BundlerMinifier.Core 。 4)针对 DataProtection 的修改 Microsoft.AspNetCore.DataProtection.Redis 的 PersistKeysToRedis() 方法不起作用,需要改用临时解决方法: 详见 PersistKeysToRedis not working in .NET Core 2.0 Preview 2 with Redis 0.1.2 5)Startup 的修改 6)Program 的修改 完成 web 项目升级后,升级所有 NuGet 包,删除所有 AssemblyInfo.cs 文件,整个升级就完成了。 asp.net core 1.1 项目升级至 asp.net core 2.0 preview 2 标签:onchange settings sync figure issue epo doc test group 原文地址:http://www.cnblogs.com/dudu/p/7266134.htmlPropertyGroup>
TargetFramework>netstandard1.6TargetFramework>
AssemblyName>CNBlogs.Identity.ServiceAgentAssemblyName>
PackageId>CNBlogs.Identity.ServiceAgentPackageId>
NetStandardImplicitPackageVersion>1.6.1NetStandardImplicitPackageVersion>
GenerateAssemblyConfigurationAttribute>falseGenerateAssemblyConfigurationAttribute>
GenerateAssemblyCompanyAttribute>falseGenerateAssemblyCompanyAttribute>
GenerateAssemblyProductAttribute>falseGenerateAssemblyProductAttribute>
PropertyGroup>
PropertyGroup>
TargetFramework>netstandard2.0TargetFramework>
PropertyGroup>
PropertyGroup>
TargetFramework>netcoreapp1.1TargetFramework>
AssemblyName>CNBlogs.Identity.UnitTestsAssemblyName>
PackageId>CNBlogs.Identity.UnitTestsPackageId>
GenerateRuntimeConfigurationFiles>trueGenerateRuntimeConfigurationFiles>
RuntimeFrameworkVersion>1.1.1RuntimeFrameworkVersion>
GenerateAssemblyConfigurationAttribute>falseGenerateAssemblyConfigurationAttribute>
GenerateAssemblyCompanyAttribute>falseGenerateAssemblyCompanyAttribute>
GenerateAssemblyProductAttribute>falseGenerateAssemblyProductAttribute>
PropertyGroup>
PropertyGroup>
TargetFramework>netcoreapp2.0TargetFramework>
PropertyGroup>
PropertyGroup>
TargetFramework>netcoreapp1.1TargetFramework>
PreserveCompilationContext>truePreserveCompilationContext>
AssemblyName>CNBlogs.Identity.WebAssemblyName>
OutputType>ExeOutputType>
PackageId>CNBlogs.Identity.WebPackageId>
RuntimeIdentifiers>win10-x64;win8-x64;osx.10.12-x64;ubuntu.14.04-x64RuntimeIdentifiers>
PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net45+win10PackageTargetFallback>
RuntimeFrameworkVersion>1.1.1RuntimeFrameworkVersion>
PropertyGroup>
PropertyGroup>
TargetFramework>netcoreapp2.0TargetFramework>
PropertyGroup>
PackageReference Include="Microsoft.AspNetCore.Authentication" Version="1.1.2" />
PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.2" />
PackageReference Include="Microsoft.AspNetCore.DataProtection.Extensions" Version="1.1.2" />
PackageReference Include="Microsoft.AspNetCore.DataProtection.Redis" Version="0.1.2" />
PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.2" />
PackageReference Include="Microsoft.AspNetCore.Hosting" Version="1.1.2" />
PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.ViewCompilation" Version="1.1.1" />
PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.2" />
PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.2" />
PackageReference Include="Microsoft.AspNetCore.Session" Version="1.1.2" />
PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />
It was not possible to find any compatible framework version
The specified framework ‘Microsoft.NETCore.App‘, version ‘1.1.0‘ was not found.
- Check application dependencies and target a framework version installed at:
/
- Alternatively, install the framework version ‘1.1.0‘.
services.Configure
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
builder.AddEnvironmentVariables();
Configuration = builder.Build();
loggerFactory.AddSerilog();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; set; }
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.ConfigureLogging((context, logging) =>
{
logging.AddSerilog();
})
.UseStartup
上一篇:jQuery获取动态生成的元素
下一篇:二、angularjs上传图片
文章标题:asp.net core 1.1 项目升级至 asp.net core 2.0 preview 2
文章链接:http://soscw.com/essay/93746.html