我在netstandard1.5
上有一个类库,我的project.json
在下面。 运行dotnet build
时出现如下错误:
The type 'Exception' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.
The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.
The type 'Uri' is defined in an assembly that is not referenced. You must add a reference to assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.
The type 'Stream' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.
在 RC1 包中,我可以引用System.Runtime
并且这将得到修复。 但是现在 RC2 和我引用NETStandard.Library
那个包。
我完全不知道为什么会出现这些错误。
项目.json
{
"version": "1.0.0-*",
"dependencies": {
},
"frameworks": {
"netstandard1.5": {
"imports": [ "dnxcore50", "portable-net45+win8+wp8+wpa81" ],
"dependencies": {
"Enums": { "target": "project" },
"VQViewModels": { "target": "project" },
"NovellLdap2": { "target": "project" },
"DDay": {"target": "project"},
"NETStandard.Library": "1.5.0-rc2-24027",
"System.Xml.XmlSerializer": "4.0.11-rc2-24027",
"System.Data.Common": "4.0.1-rc2-24027",
"System.Diagnostics.TraceSource": "4.0.0-rc2-24027",
"System.Net.Requests": "4.0.11-rc2-24027",
"System.Xml.XmlDocument": "4.0.1-rc2-24027",
"System.Xml.XPath.XmlDocument": "4.0.1-rc2-24027",
"System.Collections.Specialized": "4.0.1-rc2-24027",
"System.Data.SqlClient": "4.1.0-rc2-24027",
"System.Threading.Thread": "4.0.0-rc2-24027",
"System.Collections.NonGeneric": "4.0.1-rc2-24027",
"System.Diagnostics.TextWriterTraceListener": "4.0.0-rc2-24027",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Dapper": "1.50.0-rc2",
"FubarCoder.RestSharp.Portable.HttpClient": "3.2.0",
"MailKit": "1.3.0-beta7",
"Npgsql": "3.1.0"
}
}
}
}
我试图隔离,但我无法复制它。 项目引用只是带有如下类的库,没有逻辑或依赖项
public class Person
{
}
您的其中一个软件包是引入了基于 mscorlib 的 PCL(可能是由于您使用了"imports":"portable-net45+win8+wp8+wpa81"
)。 要解决这个问题,您需要参考“Microsoft.NETCore.Portable.Compatibility”:“1.0.1-rc2-24027”。 该软件包支持与基于 mscorlib 的 PCL 兼容。
感谢那个包做到了,在与@davidfowl交谈后,我们强调它是FubarCoder.RestSharp.Portable.HttpClient
和imports
带来了 BCL。
最有用的评论
您的其中一个软件包是引入了基于 mscorlib 的 PCL(可能是由于您使用了
"imports":"portable-net45+win8+wp8+wpa81"
)。 要解决这个问题,您需要参考“Microsoft.NETCore.Portable.Compatibility”:“1.0.1-rc2-24027”。 该软件包支持与基于 mscorlib 的 PCL 兼容。