Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
1 like 0 dislike
1.8k views
in PowerShell by 6 7 9

I got this error "Publish-PSArtifactUtility : Failed to publish script 'test': 'nuget.exe failed to push Method not found" when publishing a new script to PowerShell Gallery

Publish-Script -Path D:\publish\test.ps1 -Repository PSGallery -NuGetApiKey o
Publish-PSArtifactUtility : Failed to publish script 'test': 'nuget.exe failed to push Method not
found: 'System.Security.Cryptography.X509Certificates.X509CertificateCollection
System.Net.Http.HttpClientHandler.get_ClientCertificates()'.
'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:11338 char:17
+ ...             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : FailedToPublishTheScript,Publish-PSArtifactUtility

PS C:\Users\Administrator>

Failed to publish script nuget.exe failed to push Method not found

I have already run this command to upgrade TLS protocol to TLS 1.2 but it still not working!

 [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

 


1 Answer

2 like 0 dislike
by 163 204 403
selected by
 
Best answer

Faild to publish script on PowerShell Gallery

Cause

This error "Publish-PSArtifactUtility : Failed to publish script: nuget.exe failed to push Method not found" occurs if the Microsoft .NET Framework 4.7.1 is not currently installed on your machine!

Solution

So to fix this error, you have first to download and install Microsoft .NET Framework 4.7.1 through the offline installer or the web installer as the following:

Steps

  • Download Microsoft .NET Framework 4.7.1 (Offline Installer)
  • Or try to online download the .NET Framework 4.7.1 through this link Download Microsoft .NET Framework 4.7.1 (Web Installer) if you already have an Internet Connection on your machine.
  • After downloading Microsoft .NET Framework 4.7.1, you have to run the downloaded file and follow the installation wizard as shown below:
    download and install .netframework 4.7.1
  • After the Microsoft .NET Framework 4.7.1 installation is completed successfully, Click finish.
    install .netframework 4.7.1 setup
  • Then run the Windows PowerShell as Administrator and run the Publish-Script cmdline that should be working now!
If you don’t ask, the answer is always NO!
...