如果我嘗試從 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