Skip to content

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

Closed

Description

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

Activity

  1. added
    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get a
    on Sep 16, 2016
  2. mirichmo commented on Sep 16, 2016

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

  3. vors commented on Sep 16, 2016

    @vors
    Collaborator

    Hi Don.

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

  4. concentrateddon commented on Sep 16, 2016

    @concentrateddon
    Author

    Perfect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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