我尝试在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的概念似乎也很通用(https://www.nuget.org/packages/System.Security.Principal/4.0.1-beta-23516)也没有将dnxcore50列为依赖项,只列出"旧".NET框架。
您不应该再为dnxcore50项目使用IPrincipal,而是从ClaimsPrincipal派生。您可以在此处了解更多信息:https://player.vimeo.com/video/154041158