1

我正在尝试使用OpenIddict我的asp.net core web api项目。我已按照此处编写的说明进行操作,但是当我尝试构建项目时,出现以下错误

无法为“.NETCoreApp,Version=v1.1”解析“OpenIddict.Mvc (>= 1.0.0)”。

我已经通过 Visual Studio 2017 创建了项目(我想我默认安装了最新的 .NET Core 工具)。有任何想法吗?

更新: 说明的第一步说您必须更新您的包以引用 ASP.NET Core RTM 包。那是什么意思?

还有我的 .csproj 文件

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
    <PackageReference Include="AspNet.Security.OAuth.Validation" Version="$(AspNetContribOpenIdExtensionsVersion)" />
    <PackageReference Include="OpenIddict" Version="$(OpenIddictVersion)" />
    <PackageReference Include="OpenIddict.EntityFrameworkCore" Version="$(OpenIddictVersion)" />
    <PackageReference Include="OpenIddict.Mvc" Version="$(OpenIddictVersion)" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\iBoard.Repositories\iBoard.Repositories.csproj" />
  </ItemGroup>

</Project>

我也试过Version="1.0.0-*"

4

1 回答 1

2

在 .csproj 中添加缺少的OpenIddictVersion/属性,它应该可以工作:AspNetContribOpenIdExtensionsVersion

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <AspNetContribOpenIdExtensionsVersion>1.0.0-*</AspNetContribOpenIdExtensionsVersion>
    <OpenIddictVersion>1.0.0-*</OpenIddictVersion>
  </PropertyGroup>

</Project>

或者,您也可以直接硬编码正确的版本:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <ItemGroup>
    <PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0-*" />
    <PackageReference Include="OpenIddict" Version="1.0.0-*" />
    <PackageReference Include="OpenIddict.EntityFrameworkCore" Version="1.0.0-*" />
    <PackageReference Include="OpenIddict.Mvc" Version="1.0.0-*" />
  </ItemGroup>

</Project>
于 2017-04-25T20:15:44.070 回答