Can't resolve System.Management.Automation from GAC for net451 project
See original GitHub issueI’m having trouble creating a desktop .NET 4.5.1 console application that references the PowerShell API DLL System.Management.Automation. When I set my frameworkAssemblies
to refer to this DLL I get a compiler error. I also notice that Visual Studio’s completion results don’t contain this DLL:
What am I doing wrong?
Steps to reproduce
- Create a new console app project using
dotnet new
. - Update project.json to the contents below
- Run
dotnet restore
- Run
dotnet compile
project.json
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"frameworks": {
"net451": {
"frameworkAssemblies": {
"System.Management.Automation": ""
}
}
}
}
Expected behavior
Code compiles successfully, resolves System.Management.Automation.dll.
Actual behavior
Compile error:
PS> dotnet compile
Compiling dotnetrepro for .NETFramework,Version=v4.5.1
C:\dev\dotnetrepro\project.json(10,45): error NU1001: The dependency System.Management.Automation could not be resolved.
Compilation failed.
0 Warning(s)
1 Error(s)
Time elapsed 00:00:02.3045736
Environment data
dotnet --version
output:
Runtime Environment:
OS Name: Windows
OS Version: 10.0.11082
OS Platform: Windows
Runtime Id: win10-x64
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Can't resolve System.Management.Automation from GAC ...
I'm having trouble creating a desktop .NET 4.5.1 console application that references the PowerShell API DLL System.Management.Automation.
Read more >Import-Module : Could not load file or assembly 'System. ...
I'm unable to run PnP PowerShell commands using PowerShell ISE in administrative mode. Getting following error PS C:\WINDOWS\system32> ...
Read more >Cannot find reference for System.Management.Automation ...
1 Answer 1 ... For downloading Microsoft.PowerShell.5.ReferenceAssemblies in visual studio, you could try this download method (right click on the ...
Read more >Downloading and Installing WinSCP .NET Assembly
NET assembly is available in a package named WinSCP-X.X.X-Automation.zip on WinSCP download page. Follow the .NET assembly/COM library link.
Read more >Pro NuGet
NuGet, in essence, is a Visual Studio extension that comes bundled with Visual Studio 2012 or newer. A lot of value comes from...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m referring to the NuGet packages we released which contain reference assemblies (only metadata):
If you compile a .NET 4.5.x app against one of those NuGet packages then the PowerShell assemblies from the GAC will be loaded in your app at runtime. However, you’ll need to compile against the reference assemblies for the version of PowerShell used on the target machine otherwise you might get MissingMethodExceptions, etc. I’d recommend using the PowerShell 5 package if you’re targeting Windows 10 machines.
@daviwil I have the same question. What packages does “compiling against our official reference assembly packages” refer to? Presumably not the ancient ones that turn up in nuget when searching for “System.Management.Automation”…