运行期望状态配置命令:
Start-DSCConfiguration -ComputerName localhost -Path ./CsharpExample -Verbose -Wait -Force
我们收到以下错误:
InvalidOperation: 导入模块cSharpDSCResource时失败,错误为-无法加载文件或程序集“System.Management.Automation,Version=7.1.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35”或其某个依赖项。系统找不到指定的文件。
dll的目录结构:
"C:\Program Files\WindowsPowerShell\Modules\cSharpDSCResource\DSCResources\cSharpDSCResource\cSharpDSCResource.dll"
[appdomain] :: CurrentDomain.GetAssemblies() | Sort-Object -Property FullName | Select-Object -Property FullName; 从$PSVersionTable.PSVersion 5提示返回:
System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[appdomain] :: CurrentDomain.GetAssemblies() | Sort-Object -Property FullName | Select-Object -Property FullName; 从$PSVersionTable.PSVersion 7提示返回:
System.Management.Automation, Version=7.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
我们无法弄清楚为什么它找不到或加载System.Management.Automation 7.1.0.0
Get-DSCResource返回:
Binary cSharpDSCResource cSharpDSCResource 0.0.1 {Path, Content, DependsOn, Ensure...}
我们正在使用的是Windows Management Framework:
Microsoft Net SDK 5.0.101
Visual Studio Code中项目的代码:
cSharpDSCresource.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.Management.Automation" Version="7.1.0" />
</ItemGroup>
Start-DSCConfiguration
? - Panagiotis Kanavos