asp.net-core – Netcore 2.1.1版本导致应用程序无法运行

前端之家收集整理的这篇文章主要介绍了asp.net-core – Netcore 2.1.1版本导致应用程序无法运行前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
似乎突然出现与asp.net核心软件包不同步的东西.

看起来Microsoft.AspNetCore.App 2.1.1在16小时前在nuget.org上发布了,但只下载了158次,显然我是其中一个下载程序.

我的.csproj文件是这样的:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <ProjectReference Include="..\cloudscribe.Web.Navigation\cloudscribe.Web.Navigation.csproj" />
    <ProjectReference Include="..\cloudscribe.Web.SiteMap\cloudscribe.Web.SiteMap.csproj" />
    <ProjectReference Include="..\cloudscribe.Web.SiteMap.FromNavigation\cloudscribe.Web.SiteMap.FromNavigation.csproj" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.*" />
  </ItemGroup>
</Project>

它构建但是当我尝试运行它时,我得到:

It was not possible to find any compatible framework version
The specified framework ‘Microsoft.AspNetCore.App’,version ‘2.1.1’ was not found.
– Check application dependencies and target a framework version installed at:
C:\Program Files\dotnet\
– Installing .NET Core prerequisites might help resolve this problem:
07001
– The .NET Core framework and SDK can be installed from:
07002
– The following versions are installed:
2.1.0 at [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]

如果我将Microsoft.AspNetCore.App的版本更改为2.1.0并执行dotnet恢复,我会得到:

C:_c\cloudscribe.Web.Navigation\src\NavigationDemo.Web\NavigationDemo.Web.csproj : error NU1107: Version conflict detected for Microsoft.AspNetCore.Antiforgery. Reference the package directly from the project to resolve this issue.
C:_c\cloudscribe.Web.Navigation\src\NavigationDemo.Web\NavigationDemo.Web.csproj : error NU1107: NavigationDemo.Web -> cloudscribe.Web.Navigation -> Microsoft.AspNetCore.Mvc.Razor 2.1.1 -> Microsoft.AspNetCore.Mvc.ViewFeatures 2.1.1 -> Microsoft.AspNetCore.Antiforgery (>= 2.1.1)
C:_c\cloudscribe.Web.Navigation\src\NavigationDemo.Web\NavigationDemo.Web.csproj : error NU1107: NavigationDemo.Web -> Microsoft.AspNetCore.App 2.1.0 -> Microsoft.AspNetCore.Antiforgery (= 2.1.0).
Restore Failed in 3.54 sec for C:_c\cloudscribe.Web.Navigation\src\NavigationDemo.Web\NavigationDemo.Web.csproj.

我想这部分是由于我的解决方案中的其他项目具有如下依赖关系:

<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.*" />
<PackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="2.1.*" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="2.1.*" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.*" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.*" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.*" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor" Version="2.1.*" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.1.*" />

似乎没有2.1.1的更新sdk,但GitHub上的Microsoft.AspNetCore.App 2.1.1的可用性似乎对我来说是破坏性的.

解决方法

你的问题是你的csproj的这一行:
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.*" />

*表示要选择该Nuget包的最新2.1版本.对于许多包装,这将是完美的.但是,该软件包的v2.1.1还需要安装匹配的v2.1.1 SDK.截至目前它还没有(it’s currently blocked).

但是,如果你阅读了Migrate from ASP.NET Core 2.0 to 2.1文档,你会看到:

Replace the version specified “Microsoft.AspNetCore.All” package reference with the versionless “Microsoft.AspNetCore.App” package reference.

现在,您正在使用的SDK版本推断该版本.这意味着你的csproj现在应该包含这个:

<PackageReference Include="Microsoft.AspNetCore.App" />

猜你在找的asp.Net相关文章