简体   繁体   English

ASP.NET Core Web API和OpenIddict

[英]ASP.NET Core Web API and OpenIddict

I'm trying to use OpenIddict to my asp.net core web api project. 我正在尝试对我的asp.net core web api项目使用OpenIddict I have followed the instructions written here but when i try to build the project i get the following error 我已按照此处编写的说明进行操作但是当我尝试构建项目时出现以下错误

Unable to resolve 'OpenIddict.Mvc (>= 1.0.0)' for '.NETCoreApp,Version=v1.1'. 无法为'.NETCoreApp,Version = v1.1'解析'OpenIddict.Mvc(> = 1.0.0)'。

I have created the project through Visual Studio 2017 (I suppose i have the latest .NET Core tooling installed by default). 我已经通过Visual Studio 2017创建了该项目(我想默认情况下安装了最新的.NET Core工具)。 Any ideas? 有任何想法吗?

UPDATE: The 1st step of the instructions says that you have to update your packages to reference the ASP.NET Core RTM packages. 更新:说明的第一步说,您必须更新程序包才能引用ASP.NET Core RTM程序包。 What that means? 那是什么意思?

And my .csproj file 还有我的.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>

I have also tried with Version="1.0.0-*" 我也尝试过使用Version="1.0.0-*"

Add the missing OpenIddictVersion / AspNetContribOpenIdExtensionsVersion properties in your .csproj and it should work: 在.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>

Alternatively, you can also directly hardcode the right version: 另外,您也可以直接硬编码正确的版本:

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM