我的 Portable-Class-Library 项目一切正常,直到 我更新了所有已安装的可移植库。 它已停止编译。为安装的 nuget 库抛出以下错误。
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference
"System.Threading.Tasks"
could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile104". To resolve this problem, either remove the reference "System.Threading.Tasks" or retarget your application to a framework version which contains "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a".1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference
"System.Net.Http.Extensions"
could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile104". To resolve this problem, either remove the reference "System.Net.Http.Extensions" or retarget your application to a framework version which contains "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a".1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference
"Microsoft.Threading.Tasks.Extensions"
could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile104". To resolve this problem, either remove the reference "Microsoft.Threading.Tasks.Extensions" or retarget your application to a framework version which contains "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a".1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference
"PCLStorage"
could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile104". To resolve this problem, either remove the reference "PCLStorage" or retarget your application to a framework version which contains "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a".1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference
"Microsoft.Threading.Tasks"
could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile104". To resolve this problem, either remove the reference "Microsoft.Threading.Tasks" or retarget your application to a framework version which contains "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a".1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference
"System.Net.Http"
could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile104". To resolve this problem, either remove the reference "System.Net.Http" or retarget your application to a framework version which contains "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a".1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3268: The primary reference
"PCLStorage.Abstractions"
could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile104". To resolve this problem, either remove the reference "PCLStorage.Abstractions" or retarget your application to a framework version which contains "System.Runtime, Version=2.6.3.0, Culture=neutral, PublicKeyToken=b03f5f7fd11d50a3a".
如何指向 System.Runtime
版本 2.6.3.0?
最佳答案
解决了问题。
PCL 项目的 app.config 指向 2.6.3.0 版本的 System.Runtime
。我将其更改为指向 1.5.11.0,即之前的版本,并且编译正常。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
// <!-- <bindingRedirect oldVersion="0.0.0.0-2.6.3.0" newVersion="2.6.3.0" /> -->
<bindingRedirect oldVersion="0.0.0.0-1.5.11.0" newVersion="1.5.11.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
关于c# - 更新所有已安装的 NuGet 可移植库后,PCL 项目未编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20196552/