1

I'm trying to migrate a C# class library that I previously built which was targeting .NET Framework v4.5 to .NET Standard 2.0.

I tried many packages to include PowerShell support in my library but every time I include a package I get a warning saying that the package was included using a target framework different from the .NET Standard 2.0.

For example, with the System.Management.Automation_PowerShell_3.0` package I get the following error message

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.

which would be roughly translated to English as

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.

Since the main reason, I'm trying to port my library to .NET Standard is to support both the .NET Framework and the .NET Core targets, having a package one of the packages be .NET Framework-specific defeats the purpose of the port.

Do I have any workaround? Is there a PowerShell package that targets .NET Standard 2.0 that I missed (I tried about 10 PowerShell-related packaged in the VS17 NuGet explorer before posting here)?

For some background, I use PowerShell to run node.exe from my C# library.

Vijayanath Viswanathan
  • 8,027
  • 3
  • 25
  • 43
Mathieu VIALES
  • 4,526
  • 3
  • 31
  • 48
  • Why do you need powershell to launch node.exe? – tolanj Oct 02 '17 at 15:14
  • PowerShell for Linux isn't quite ready for prime time yet (6.0 isn't out of beta). Until it is, there's little point to making a .NET Standard package, since your code could only ever run on Windows anyway -- in which case having to run on the .NET Framework is no great impediment. If it *does* take off, it seems probable a .NET Standard package will be in the works, eventually. Even then you'd be requiring people to have PowerShell installed. – Jeroen Mostert Oct 02 '17 at 15:14
  • I couldn't figure any other way to start it ... Considering your question, I may have missed something about the different available options to run node ... – Mathieu VIALES Oct 02 '17 at 15:15
  • System.Diagnostics.Process IS available for standard at least according to accepted answer of https://stackoverflow.com/questions/44151911/porting-net-framework-code-to-net-standard-using-process-registrykey YMMV – tolanj Oct 02 '17 at 15:18
  • oh .. oh ! node.**exe** ... IT'S AN EXECUTABLE sometimes i wonder why i ever was hired as developer ... -_- Thank you good sir – Mathieu VIALES Oct 02 '17 at 15:20

1 Answers1

3

As far as I know there isn't any way around this. The reason for that is the package is built using the .NETFramework so until the creators port their package to the .NETStandard, it will only be usable from .NETFramework apps since, in theory, that package could use libraries that are not in the .NETStandard.

GBreen12
  • 1,832
  • 2
  • 20
  • 38
  • 1
    But more than that a powershell wrapper is exactly something it makes little sense / may be impossible to port to .Net Standard, Powershell Core perhaps but not Windows Powershell – tolanj Oct 02 '17 at 15:16