我一直在做我的第一个PS模块,我想在PSGallery上与社区分享我工作的开始。
在PowerShell 7下运行Publish-Module
时,我收到以下错误:
Publish-Module -Path "C:\Users\Douda\Projects\PSSymantecCloud\Output\PSSymantecCloud\" -NuGetApiKey $ApiKey -Verbose
错误:
Write-Error: Failed to generate the compressed file for module 'C:\Program Files\dotnet\dotnet.exe failed to pack: error MSBuild version 17.3.2+561848881 for .NET Determining projects to restore... C:\Program
Files\dotnet\sdk\6.0.403\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\XXXX\AppData\Local\Temp\981e0c61-cd9d-434f-a47b-f706deca98c4\Temp.csproj] C:\Program
Files\dotnet\sdk\6.0.403\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\XXXX\AppData\Local\Temp\981e0c61-cd9d-434f-a47b-f706deca98c4\Temp.csproj]
C:\Users\XXXX\AppData\Local\Temp\981e0c61-cd9d-434f-a47b-f706deca98c4\Temp.csproj : error NU1100: Unable to resolve 'Microsoft.NETCore.App (>= 2.0.0)' for '.NETCoreApp,Version=v2.0'. Failed to restore
C:\Users\XXXX\AppData\Local\Temp\981e0c61-cd9d-434f-a47b-f706deca98c4\Temp.csproj (in 83 ms). '.
似乎是一个编译问题,由于不支持.NET框架,但我没有安装任何东西,并会假设我的默认Windows 11 + PS7是不够的?
我错过了什么?
已在PS 5.1上尝试,但出现不同的错误
Publish-PSArtifactUtility : Failed to publish module 'PSSymantecCloud': 'The underlying connection was closed: An unexpected error occurred on a send.
'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1227 char:17
+ Publish-PSArtifactUtility -PSModuleInfo $moduleInfo
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : FailedToPublishTheModule,Publish-PSArtifactUtility
1条答案
按热度按时间ix0qys7i1#
PowerShellGet也遇到了同样的问题,必须手动更新其
.psm1
更改:到
net6
(在我的例子中):这种情况会一直发生,直到他们决定修复他们的问题:
因此,暂时可以使用此代码自动更新受影响的文件,以正确的.NET版本为目标(请注意,我将替换为
net6
,请使用正确的版本,可能是net6
,但不能确定)。另请注意,运行此代码需要提升的会话,否则将出现“拒绝访问”错误。