将 PowerShell 包添加到 .netstandard2.0 class 库

Add PowerShell package to .netstandard2.0 class library

我正在尝试将我之前构建的以 .NET Framework v4.5 为目标的 C# class 库迁移到 .NET Standard 2.0。

我尝试了很多包以在我的库中包含 PowerShell 支持,但每次我包含一个包时,我都会收到一条警告,指出该包是使用不同于 .NET Standard 2.0 的目标框架包含的。

例如,使用 System.Management.Automation_PowerShell_3.0` 包时,我收到以下错误消息

Le package 'System.Management.Automation_PowerShell_3.0 6.3.9600.17400' a été restauré en utilisant '.NETFramework,Version=v4.6.1' au lieu du framework cible du projet '.NETStandard,Version=v2.0'. Ce package n'est peut-être pas totalement compatible avec votre projet.

粗略翻译成英文为

The package 'System.Management.Automation_PowerShell_3.0 6.3.9600.17400' was restored using '.NETFramework,Version=v4.6.1' instead of the projet's target framework '.NETStandard,Version=v2.0'. This package may not be completely compatible with the target project.

由于主要原因,我尝试将我的库移植到 .NET Standard 是为了同时支持 .NET Framework 和 .NET Core 目标,其中一个包是 .NET Framework 特定的违背了端口的目的。

我有什么解决方法吗?是否有我错过的针对 .NET Standard 2.0 的 PowerShell 包(我在此处发布之前尝试了 VS17 NuGet 资源管理器中打包的大约 10 个与 PowerShell 相关的包)?

对于某些背景,我使用 PowerShell 从我的 C# 库中 运行 node.exe。

据我所知,没有任何解决办法。原因是该包是使用 .NETFramework 构建的,因此在创建者将他们的包移植到 .NETStandard 之前,它只能从 .NETFramework 应用程序中使用,因为从理论上讲,该包可以使用不在 .NETStandard.

中的库