我正在将现有平台从.Net Core 1.1升级到.Net Core 2.0。 我升级了与之关联的框架和Nuget包。
我的控制器不再继承Controller类。
但是,我的项目不再构建并使用消息抛出cs0012: 您必须添加对程序集&net; netstandard,Version = 2.0.0.0,Culture = neutral,publicKeyToken = cc7b13ffcd2ddd51"的引用。
这是我的cs.project
<PropertyGroup>
<AssemblyTitle>Demand1</AssemblyTitle>
<TargetFramework>netcoreapp2.0</TargetFramework>
<DebugType>portable</DebugType>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>OnDemand</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>OnDemand</PackageId>
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Rewrite" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.0.0" />
<PackageReference Include="Moq" Version="4.7.10" />
<PackageReference Include="OctoPack" Version="3.6.1" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="1.0.0" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="2.0.0" />
<PackageReference Include="StackifyMiddleware" Version="2.0.3" />
我按照这里的建议: Solution 1和Another One
在花了一整天尝试解决之后,有没有人能指出我正确的方向。 我还以为.net core 2实现了.net标准2.0.0。如果我在这里完全错了,请纠正我。
答案 0 :(得分:0)
您需要删除
<RuntimeFrameworkVersion>1.1.1</RuntimeFrameworkVersion>
来自.csproj
文件的。这会将runtimeconfig.json
文件中的目标版本设置为使用.NET Core 1.1.1而不是.NET Core 2.0。