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