Powershell 发布模块失败

Powershell 发布模块失败

如果我尝试从 powershell (7.1.3) 发布模块,我会收到此错误:

> Publish-Module -Name GreatDismal -NuGetApiKey [...]

Write-Error: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:10990
 Line |
10990 |  …             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param …
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | Failed to generate the compressed file for module 'C:\Program Files\dotnet\dotnet.exe failed to pack: error Microsoft (R) Build Engine
      | version 16.9.0+57a23d249 for .NET Copyright (C) Microsoft Corporation. All rights reserved.    Determining projects to restore...
      | C:\Program Files\dotnet\sdk\5.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning
      | NETSDK1138: The target framework 'netcoreapp2.0' is out of support and will not receive security updates in the future. Please refer
      | to https://aka.ms/dotnet-core-support for more information about the support policy.
      | [C:\Users\sdixon\AppData\Local\Temp\49504ccb-87a6-43db-9133-46ffdc798eb9\Temp.csproj] C:\Program
      | Files\dotnet\sdk\5.0.202\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.EolTargetFrameworks.targets(28,5): warning NETSDK1138: The
      | target framework 'netcoreapp2.0' is out of support and will not receive security updates in the future. Please refer to
      | https://aka.ms/dotnet-core-support for more information about the support policy.
      | [C:\Users\sdixon\AppData\Local\Temp\49504ccb-87a6-43db-9133-46ffdc798eb9\Temp.csproj]
      | C:\Users\sdixon\AppData\Local\Temp\49504ccb-87a6-43db-9133-46ffdc798eb9\Temp.csproj : error NU1100: Unable to resolve
      | 'Microsoft.NETCore.App (>= 2.0.0)' for '.NETCoreApp,Version=v2.0'.   Failed to restore
      | C:\Users\sdixon\AppData\Local\Temp\49504ccb-87a6-43db-9133-46ffdc798eb9\Temp.csproj (in 94 ms).  '.

我尝试重新安装 dotnet-sdk 和 dotnetcore,但没有成功,就这样了。有什么想法吗?

答案1

我不知道为什么这有效,但它似乎解决了这个问题:

Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-PackageProvider -Name PowerShellGet -Force -Scope CurrentUser

在此处的错误报告中找到了针对此问题的解决方案:https://github.com/PowerShell/PowerShellGetv2/issues/303

相关内容