Skip to content

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

@concentrateddon

Description

@concentrateddon

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aWG-Maintainers-Buildspecific to affecting the build

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions