-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-AnsweredThe question is answered.The question is answered.
Description
I mention PowerShell.SDK, but it is maybe related to System.Management.Automation dependencies.
Let's see how to reproduce.
Steps to reproduce
- create a new dotnetcore 2.0 project
- install PowerShell.SDK nuget package
dotnet add package Microsoft.PowerShell.SDK --version 6.0.0-rc --source https://powershell.myget.org/F/powershell-core/api/v3/index.json
using System;
using System.Management.Automation.Runspaces;
namespace test_powershell
{
class Program
{
static void Main(string[] args)
{
var runspace = RunspaceFactory.CreateRunspace();
}
}
}This code throws an exception of type: System.Management.Automation.Runspaces.PSSnapInException
Cannot load PowerShell snap-in Microsoft.PowerShell.Diagnostics because of the following error: Could not load file or assembly 'E:\dev\perso\git\test_powershell\Microsoft.PowerShell.Commands'. The system cannot find the file specified.
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault()
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(PSHost host)
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace()
at test_powershell.Program.Main(String[] args) in E:\dev\perso\git\test_powershell\Program.cs:line 10} System.Management.Automation.Runspaces.PSSnapInException
Expected behavior
Should not throw any exception.
How-to fix it
Install manually 2 another packages:
- Microsoft.PowerShell.Commands.Diagnostics
- Microsoft.WSMan.Management
Regarding the nuspec definition in Microsoft.PowerShell.SDK, those 2 packages are not listed as a dependency. Neither in System.Management.Automation.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>Microsoft.PowerShell.SDK</id>
<version>6.0.0-rc</version>
<authors>Microsoft.PowerShell.SDK</authors>
<owners>Microsoft.PowerShell.SDK</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>PowerShell SDK metapackage</description>
<copyright>(c) Microsoft Corporation. All rights reserved.</copyright>
<dependencies>
<group targetFramework=".NETCoreApp2.0">
<dependency id="Microsoft.PowerShell.Commands.Management" version="6.0.0-rc" exclude="Build,Analyzers" />
<dependency id="Microsoft.PowerShell.Commands.Utility" version="6.0.0-rc" exclude="Build,Analyzers" />
<dependency id="Microsoft.PowerShell.ConsoleHost" version="6.0.0-rc" exclude="Build,Analyzers" />
<dependency id="Microsoft.PowerShell.Security" version="6.0.0-rc" exclude="Build,Analyzers" />
<dependency id="System.Management.Automation" version="6.0.0-rc" exclude="Build,Analyzers" />
<dependency id="System.Data.SqlClient" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.IO.Packaging" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.Net.Http.WinHttpHandler" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.ServiceModel.Duplex" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.ServiceModel.Http" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.ServiceModel.NetTcp" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.ServiceModel.Primitives" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.ServiceModel.Security" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.Text.Encodings.Web" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.Threading.AccessControl" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.Private.ServiceModel" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.NETCore.Windows.ApiSets" version="1.0.1" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
</package>Maybe those 2 packages should be listed as dependencies of system.Management.Automation
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>System.Management.Automation</id>
<version>6.0.0-rc</version>
<authors>System.Management.Automation</authors>
<owners>System.Management.Automation</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>PowerShell Core's System.Management.Automation project</description>
<copyright>(c) Microsoft Corporation. All rights reserved.</copyright>
<dependencies>
<group targetFramework=".NETCoreApp2.0">
<dependency id="Microsoft.PowerShell.CoreCLR.Eventing" version="6.0.0-rc" exclude="Build,Analyzers" />
<dependency id="Microsoft.Win32.Registry.AccessControl" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="Newtonsoft.Json" version="10.0.3" exclude="Build,Analyzers" />
<dependency id="System.IO.FileSystem.AccessControl" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.Security.AccessControl" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.Security.Cryptography.Pkcs" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.Security.Permissions" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="System.Text.Encoding.CodePages" version="4.4.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.Management.Infrastructure" version="1.0.0-alpha07" exclude="Build,Analyzers" />
<dependency id="PowerShell.Core.Instrumentation" version="6.0.0-beta.10" exclude="Build,Analyzers" />
</group>
</dependencies>
</metadata>
</package>mkArtak, Halkcyon, nickmkk and RaphiStein
Metadata
Metadata
Assignees
Labels
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-AnsweredThe question is answered.The question is answered.