带有 ADAL 的 .Net Core 1.1:无法解析依赖项 NetStandard.Library >= 1.6.0

.Net Core 1.1 with ADAL: The dependency NetStandard.Library >= 1.6.0 could not be resolved

我正在尝试在我的 NetCore 1.1 项目中使用 ActiveDirectory 客户端。项目恢复正常,但无法构建。构建时我得到一个指向 Microsoft.IdentityModel.Clients.ActiveDirectory

的错误 The dependency NetStandard.Library >= 1.6.0 could not be resolved

为什么这个依赖不能满足?从 NetCore 1.0.1

升级之前,库曾经工作

这是我的project.json(其中包含很多试图解决问题的额外内容):

{

  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.1.0",
    "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
    "Microsoft.IdentityModel.Clients.ActiveDirectory": "3.13.7",
    "NETStandard.Library": "1.6.1",
    "Microsoft.AspNetCore.Authentication.OpenIdConnect": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.AspNetCore.Localization": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools.DotNet": {
      "version": "1.1.0-preview4-final",
      "imports": [
        "portable-net45+win8"
      ]
    },
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
    "Microsoft.Extensions.Localization": "1.1.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    "Microsoft.AspNetCore.Session": "1.1.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Core": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.EntityFrameworkCore": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Utils": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Templating": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration": "1.1.0-preview4-final"
  },

  "tools": {
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }

  },
  "runtimes": {
    "win10-x64": {},
    "win8-x64": {},
    "win7-x64": {}
  },
  "frameworks": {

    "netcoreapp1.1": {
      "type": "platform",
      "version": "1.0.1",

      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }

  },

  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },


}

我也能重现这个问题。似乎这个包没有正确部署到 Nuget。

当我在 Microsoft.IdentityModel.Clients.ActiveDirectory.nuspec 文件中评论以下行时,问题可能会得到解决:

<!--<dependency id="NetStandard.Library" version="1.6.0" />-->

但是,我在使用这个版本包的时候还是出现了异常。我也在尝试提交这个问题。

作为一种变通方法,您可以将此软件包降级到适合我的版本 3.13.6。

显然,将 nuspec 文件中“NetStandard”名称的大小写更改为“NETStandard”也可以修复它。

"ADAL 3.13.7 requires "NetStandard" library and in the applications common import, the application reuiqres NETStandard, i.e. a casing issue."

So the fix here is to update the adal's nuspec with correct casing i.e. NETStandard.

在此处查看讨论:https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/issues/559#issuecomment-261768339