-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
ASP.NET core 2.0 app.
.csproj:
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.PowerShell.Commands.Diagnostics" Version="6.0.0-beta.8" />
<PackageReference Include="Microsoft.PowerShell.SDK" Version="6.0.0-beta.8" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.WSMan.Management" Version="6.0.0-beta.8" />
controller code:
using (PowerShell ps = PowerShell.Create())
{
var result = ps.AddScript(@"New-Item -Path 'C:\Programming\' -Type Directory -Name TestFolder").Invoke();
}
Results in an exeption:
System.Management.Automation.RuntimeException: The following errors occurred when updating the assembly list for the runspace:
Could not load file or assembly 'C:\Programming\Intranet\Intranet\Microsoft.PowerShell.Commands'. The system cannot find the file specified.
Could not load file or assembly 'C:\Programming\Intranet\Intranet\Microsoft.PowerShell'. The system cannot find the file specified.
Could not load file or assembly 'C:\Programming\Intranet\Intranet\Microsoft.PowerShell.Commands'. The system cannot find the file specified.
Could not load file or assembly 'C:\Programming\Intranet\Intranet\Microsoft.PowerShell.Commands'. The system cannot find the file specified.
Could not load file or assembly 'C:\Programming\Intranet\Intranet\Microsoft.PowerShell'. The system cannot find the file specified.
Could not load file or assembly 'C:\Programming\Intranet\Intranet\Microsoft.WSMan'. The system cannot find the file specified..at System.Management.Automation.ExecutionContext.UpdateAssemblyCache()
at System.Management.Automation.Runspaces.RunspaceConfigurationEntryCollection`1.Update(Boolean force)
at System.Management.Automation.Runspaces.RunspaceConfiguration.Bind(ExecutionContext executionContext)
at System.Management.Automation.AutomationEngine..ctor(PSHost hostInterface, RunspaceConfiguration runspaceConfiguration, InitialSessionState iss)
at System.Management.Automation.Runspaces.LocalRunspace.DoOpenHelper()
at System.Management.Automation.Runspaces.LocalRunspace.OpenHelper(Boolean syncCall)
at System.Management.Automation.Runspaces.RunspaceBase.CoreOpen(Boolean syncCall)
at System.Management.Automation.Runspaces.RunspaceBase.Open()
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection
1 input, PSDataCollection
1 output, PSInvocationSettings settings)at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection
1 input, PSDataCollection
1 output, PSInvocationSettings settings)at System.Management.Automation.PowerShell.CoreInvoke[TOutput](IEnumerable input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke()
at Intranet.Controllers.PowershellController.Test() in C:\Programming\Intranet\Intranet\Controllers\PowershellController.cs:line 30