Could not load file or assembly Microsoft.Management.Infrastructure
BlythMeister opened this issue · comments
Chris Blyth commented
Using the example to create a MVP i get
Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. The system cannot find the file specified.
File name: 'Microsoft.Management.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
at Cupboard.Internal.WmiFacts.GetFacts(IRemainingArguments args)+MoveNext()
at Cupboard.Internal.FactBuilder.Build(IRemainingArguments args) in /_/src/Cupboard/Internal/FactBuilder.cs:line 20
at Cupboard.Internal.ExecutionEngine.Run(IRemainingArguments args, IStatusUpdater status, Boolean dryRun) in /_/src/Cupboard/Internal/ExecutionEngine.cs:line 33
at Cupboard.Internal.RunCommand.Run(CommandContext context, Settings settings) in /_/src/Cupboard/Internal/Cli/RunCommand.cs:line 135
at Cupboard.Internal.RunCommand.Execute(CommandContext context, Settings settings) in /_/src/Cupboard/Internal/Cli/RunCommand.cs:line 105
at Spectre.Console.Cli.Command`1.Spectre.Console.Cli.ICommand.Execute(CommandContext context, CommandSettings settings) in /_/src/Spectre.Console/Cli/CommandOfT.cs:line 44
at Spectre.Console.Cli.CommandExecutor.Execute(CommandTree leaf, CommandTree tree, CommandContext context, ITypeResolver resolver, IConfiguration configuration) in /_/src/Spectre.Console/Cli/Internal/CommandExecutor.cs:line 115
at Spectre.Console.Cli.CommandExecutor.Execute(IConfiguration configuration, IEnumerable`1 args) in /_/src/Spectre.Console/Cli/Internal/CommandExecutor.cs:line 84
at Spectre.Console.Cli.CommandApp.RunAsync(IEnumerable`1 args) in /_/src/Spectre.Console/Cli/CommandApp.cs:line 87
at Spectre.Console.Cli.CommandApp.Run(IEnumerable`1 args) in /_/src/Spectre.Console/Cli/CommandApp.cs:line 61
at Spectre.Console.Cli.CommandApp`1.Run(IEnumerable`1 args) in /_/src/Spectre.Console/Cli/CommandAppOfT.cs:line 42
at Cupboard.CupboardHost.Run(String[] args) in /_/src/Cupboard/CupboardHost.cs:line 30
I am running this on Windows. I've attached my csproj & 3 classes as they are tiny.
MachineSetup.zip
Patrik Svensson commented
@BlythMeister Since you're building the project with <SelfContained>true</SelfContained>
, you will need to set the <RuntimeIdentifier>
as well.
You've done this, but instead of win-x64
, you will need to set it to win7-x64
, since Microsoft.Management.Infrastructure
doesn't have portable RIDs.
The following works fine for me:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Cupboard" Version="0.1.1-preview.0.5" />
</ItemGroup>
</Project>
Chris Blyth commented
Ahhhhh I was pretty sure it was me!
Thanks @patriksvensson !