小编Dav*_*von的帖子

使用 nuget 包时,有没有办法避免使用网络标准程序集以支持 PCL?

我有一个桌面应用程序和一个针对 .Net 框架 4.6.2 的简单类库。最近我注意到,当我在 VS 2017 (15.6.3) 中更新我的 nuget 包时,其中一个开始引入一些较新的 netstandard2.0 程序集。

我渴望有一天能构建 netstandard 库。但是现在我更喜欢将相应的 PCL(在同一个 nuget 包中可用)作为依赖项而不是 netstandard 程序集引入我的项目。我所追求的 nuget PCL 程序集针对“portable-net45+win8+wp8+wpa81”。

我不想要 netstandard2.0 程序集的原因是因为它会导致一堆垫片程序集出现在输出目录中,鉴于我的应用程序类库本身不针对 netstandard2.0,这太过分了。发生的另一件事是 VS 开始为不相关的包(如 System.ValueTuple)生成一堆版本冲突(编译器输出中的警告)。这似乎也与垫片有关(垫片可能来自路径C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\lib )

下面是我开始看到的版本冲突示例。

在“Reference:System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL”和“Reference:System.ValueTuple”之间遇到冲突。选择“Reference:System.ValueTuple”是因为文件版本“4.6.26011.1”大于“4.6.25519.3”。

我希望这些只是警告,尽管非常可怕。我相信这些只是文件版本问题(与程序集版本无关),并且认为它们不会导致需要绑定重定向。即便如此,我会更高兴再次回到我的 PCL 并避免所有这些东西。我想一旦 .Net Framework 4.7.2 发布,我会更渴望使用和构建 netstandard 程序集。

我正在为 nuget 使用老式的 csproj 格式和 packages.config。似乎引入 netstandard2.0 位的 nuget 依赖项是 System.Composition。

System.Composition  1.1.0
System.Composition.AttributedModel  1.1.0
System.Composition.Convention   1.1.0
System.Composition.Hosting  1.1.0
System.Composition.Runtime  1.1.0
System.Composition.TypedParts   1.1.0
System.ValueTuple   4.4.0
Run Code Online (Sandbox Code Playgroud)

希望这很清楚。我此时的解决方法是创建另一个面向 .Net 4.5 …

printer-control-language package nuget visual-studio-2017 .net-standard-2.0

5
推荐指数
1
解决办法
1284
查看次数