Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Referencing System.Management.Automation in .NET Core / VS Code #2284

Closed
concentrateddon opened this issue Sep 16, 2016 · 3 comments
Closed
Labels
Area-Maintainers-Build specific to affecting the build Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a

Comments

@concentrateddon
Copy link

What's the correct way to reference System.Management.Automation? E.g., this snippet from project.json:

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "Microsoft.AspNetCore.Routing": "1.0.0",
    "System.Security.Cryptography.Algorithms": "4.2.0",
    "System.Management.Automation": "6.1.7601.17514"
  },

Works when you run dotnet restore in that it finds and claims to install the System.Management.Automation dependency (noting that .17515 isn't compatible with .NET Core). But you can't simply add a using in the code, or it says:

The type or namespace name 'Management' does not exist in the namespace 'System'

The intent here is to programmatically instantiate PowerShell in the code, but .NET Core is a bit restrictive in how it wants references handled...

@mirichmo mirichmo added Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a Area-Maintainers-Build specific to affecting the build labels Sep 16, 2016
@mirichmo
Copy link
Member

This is a known issue for NuGet that we are trying to resolve. There are a number of rogue System.Management.Automation packages that external people have posted. Those packages are all "FullCLR" assemblies and are not compatible with PowerShell Core.

The current way to consume the PowerShell Core version of System.Management.Automation is to copy the technique used by this project. Our nuget.config file points to the correct version that is posted to MyGet. powershell-win-core\project.json shows how to consume it within your project.json.

@vors
Copy link
Collaborator

vors commented Sep 16, 2016

Hi Don.

There are few things about dotnet cli that may help you sort it out.

@concentrateddon
Copy link
Author

Perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Maintainers-Build specific to affecting the build Issue-Question ideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
Projects
None yet
Development

No branches or pull requests

3 participants