我刚离开一个项目很长一段时间(可能超过一年),在将VS2017更新到15.7.5版本后,我在尝试重新构建该项目时遇到了许多问题。第一个问题是nuget依赖项抱怨说,对于OpenIddict程序集,请求的是"1.0.0.-*“,但收到的却是"1.0.0-rtm-1063”。这些错误对我来说毫无意义,但我修改了我的.csproj文件,如下所示:
<!-- OpenIdDict -->
<!-- 1.0.0.-* changed to 1.0.0.-rtm-1063 -->
<PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.1" />
<PackageReference Include="OpenIddict" Version="1.0.0-rtm-1063" />
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="1.0.0-rtm-1063" />
<PackageReference Include="OpenIddict.Mvc" Version="1.0.0-rtm-1063" />这显然不是一个好的永久解决方案(正确的解决方案是什么?)此外,这导致了一系列其他问题,这些问题通过替换
using OpenIddict.Models;使用
using OpenIddict.EntityFrameworkCore.Models;这给我留下了两个我找不到解决方案的问题。
services.AddOpenIddict().AddEntityFrameworkCoreStores<ApplicationDbContext>()未定义。
Configure()方法中对app.UseOpenIddict()的调用报告UseOpenIddict未定义。
如果有人能为我指出解决这些问题的正确方向,我将不胜感激。
此外,这个项目正在使用.NET Core1.1,据我所知,它已经被.NET Core2.1所取代。我不清楚如何升级项目以使用.NET Core2.1。VS2017图形用户界面中的下拉列表仅包含1.0和1.1以及“安装其他框架...”但是,即使在安装了最新的2.1SDK和运行时之后,.NET核心2.1的下拉列表中仍然没有选项。我做错了什么?
发布于 2018-07-31 22:38:25
您应该删除<PackageReference Include="AspNet.Security.OAuth.Validation" Version="1.0.0" />,因为它现在被OpenIddict元包传递引用。
在RC3中,语法发生了一些变化,因此services.AddOpenIddict().AddEntityFrameworkCoreStores<ApplicationDbContext>()现在不再有效:
// In OpenIddict RC2, all the options used to be grouped.
services.AddOpenIddict(options =>
{
options.AddEntityFrameworkCoreStores<ApplicationDbContext>();
options.AddMvcBinders();
options.EnableAuthorizationEndpoint("/connect/authorize")
.EnableLogoutEndpoint("/connect/logout")
.EnableTokenEndpoint("/connect/token")
.EnableUserinfoEndpoint("/api/userinfo");
options.AllowAuthorizationCodeFlow()
.AllowPasswordFlow()
.AllowRefreshTokenFlow();
options.RegisterScopes(OpenIdConnectConstants.Scopes.Email,
OpenIdConnectConstants.Scopes.Profile,
OpenIddictConstants.Scopes.Roles);
options.RequireClientIdentification();
options.EnableRequestCaching();
options.EnableScopeValidation();
options.DisableHttpsRequirement();
});
// In OpenIddict RC3, the options are now split into 3 categories:
// the core services, the server services and the validation services.
services.AddOpenIddict()
.AddCore(options =>
{
// AddEntityFrameworkCoreStores() is now UseEntityFrameworkCore().
options.UseEntityFrameworkCore()
.UseDbContext<ApplicationDbContext>();
})
.AddServer(options =>
{
// AddMvcBinders() is now UseMvc().
options.UseMvc();
options.EnableAuthorizationEndpoint("/connect/authorize")
.EnableLogoutEndpoint("/connect/logout")
.EnableTokenEndpoint("/connect/token")
.EnableUserinfoEndpoint("/api/userinfo");
options.AllowAuthorizationCodeFlow()
.AllowPasswordFlow()
.AllowRefreshTokenFlow();
options.RegisterScopes(OpenIdConnectConstants.Scopes.Email,
OpenIdConnectConstants.Scopes.Profile,
OpenIddictConstants.Scopes.Roles);
// This API was removed as client identification is now
// required by default. You can remove or comment this line.
//
// options.RequireClientIdentification();
options.EnableRequestCaching();
// This API was removed as scope validation is now enforced
// by default. You can safely remove or comment this line.
//
// options.EnableScopeValidation();
options.DisableHttpsRequirement();
});https://stackoverflow.com/questions/51575439
复制相似问题