0

I want to create a C# app that does things with the powershell. I found many solutions on the internet how to do that like this. The most answeres to this use the Powershell class from 'Microsoft.WSMan.Runtime'. Now when I search this package in nuget and install it, it doesnt show up in the references list in visual studio and also the using statement or the 'quick fix' on a PowerShell object doesnt find it.

Did I install something wrong or do I need something else too?


Edit for more infos:

  • .net Version 4.6.1
  • Tried 'Microsoft.WSMan.Runtime'v 7.0.0 and 7.0.3
  • 'Microsoft.WSMan.Runtime' is downloaded and avaible at './packages/Microsoft.WSMan.Runtime.7.0.0'
  • 'packages.config' does contain the entry for 'Microsoft.WSMan.Runtime'.
1
  • Create a new .net core 3.1 project to consume this package, the package will show up normally then. Commented Sep 17, 2020 at 8:42

1 Answer 1

1

I found the assembly within the package targets .net core 3.1 instead of .net framework 4.6.1. So you can't see the reference in solution explorer.

It's by design of the package author, you can download the package manually, rename the name from xx.nupkg to xx.zip to check the content of the package.

The structure of the package:

enter image description here

And the content of the Microsoft.WSMan.Runtime.nuspec file:

<?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> <metadata> ... <dependencies> <group targetFramework=".NETCoreApp3.1" /> </dependencies> <contentFiles> <files include="**/*" buildAction="None" copyToOutput="true" flatten="false" /> </contentFiles> </metadata> </package> 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.