将项目升级到.Net Core3.1后,部分自己写类库也需要升级,由于类库中要用到Microsoft.NETCore.App这个.net core2.1下的类库在3.1下无法引用通过nuget也无法安装,后来查了网上的方法,只要对.prj项目文件打开编辑
<Project Sdk="Microsoft.NET.Sdk.Web">--此处做下修改<PropertyGroup><TargetFramework>netcoreapp3.1</TargetFramework><OutputType>Library</OutputType>--增加此句话</PropertyGroup><ItemGroup><Compile Remove="Autofac\**" /><Compile Remove="Net\**" /><EmbeddedResource Remove="Autofac\**" /><EmbeddedResource Remove="Net\**" /><None Remove="Autofac\**" /><None Remove="Net\**" /></ItemGroup><ItemGroup><PackageReference Include="Autofac" Version="4.9.4" /><PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" /><PackageReference Include="CHTCHSConv" Version="1.0.0" /><PackageReference Include="log4net" Version="2.0.8" /><PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" /><PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" /><PackageReference Include="StackExchange.Redis" Version="2.0.601" /><PackageReference Include="System.Data.SqlClient" Version="4.8.2" /><PackageReference Include="ZKWeb.System.Drawing" Version="4.0.1" /></ItemGroup></Project>
<Project Sdk="Microsoft.NET.Sdk.Web">--此处做下修改
<OutputType>Library</OutputType>--增加此句话
主要就是这两点修改下,就自动能引用Microsoft.NETCore.App下的相关命名空间了.
如果无法打包还需增加
<IsPackable>true</IsPackable>