【问题标题】:IPrincipal cannot be found in dnxcore50在 dnxcore50 中找不到 IPrincipal
【发布时间】:2016-07-17 12:21:56
【问题描述】:

我尝试在 dnxcore50 中使用 IPrincipal。虽然它在 Windows 上运行良好,但在 OS X 上运行 dotnet restore 时出现以下错误:

无法解析 System.Security.Principal (>= 4.0.1-rc3-23829) 对于 DNXCore,版本=v5.0 (osx.10.11-x64)。

我的project.json 看起来像这样:

{
  "version": "0.1.3-*",

  "compilationOptions": {
    "emitEntryPoint": false
  },  

  "compile": "*.cs",
  "exclude": "Platform/**/*.cs",

  "frameworks": {
    "net45": {
      "include": "Platform/DotNet45/*.cs",
      "frameworkAssemblies": {
        "System.Xml": "4.0.0.0",
        "System.Xml.Linq": "4.0.0.0",
        "System.Xml.XDocument": "4.0.0.0"
      }   
    },  
    "dnxcore50": {
      "include": "Platform/DotNetCore/*.cs",
      "dependencies": {
        "NETStandard.Library": "1.0.0-rc3-23829",
        "System.Security.Principal": "4.0.1-beta-23516",
        "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-23225",
        "System.Security.Cryptography.X509Certificates": "4.0.0-rc3-23829",
        "System.Xml.XDocument": "4.0.11-rc3-23829",
        "System.Xml.XmlSerializer": "4.0.11-rc3-23829"
      }   
    }   
  }
}

似乎 System.Security.Principal 仅在 Windows 平台上可用,但 IPrincipal 的概念对我来说似乎很笼统。 NuGet 页面 (https://www.nuget.org/packages/System.Security.Principal/4.0.1-beta-23516) 也没有将 dnxcore50 列为依赖项,而仅将“旧”.NET 框架列出。

【问题讨论】:

  • 问完这个问题有进展吗?
  • 说实话......我放弃了 CoreCLR,直到事情变得更加稳定。目前,由于不兼容的版本和不同的工具链,这是一个很大的混乱。真可惜,因为 CoreCLR 的想法很棒,但是当前的实现和版本问题让我不得不退出......

标签: dnx iprincipal project.json


【解决方案1】:

您不应再将 IPrincipal 用于 dnxcore50 项目,而应从 ClaimsPrincipal 派生。你可以在这里了解更多信息:https://player.vimeo.com/video/154041158

【讨论】: