Dai Bok
Dai Bok

Reputation: 3616

Publish-Module fails with NuGet.Build.Tasks.Pack.targets(198,5) error : Index was outside the bounds of the array

I've upgraded to dotnet sdk version 3.1 and am trying to publish my powershell module. I am using powershell 5.1.

I run the command:

Publish-Module -Path "C:\sources\myModules\InstallationUtils\" -NuGetApiKey "xxxxxxx" -Repository internal.packages.org" 

and get the error:

[C:\Users\xxxxxx\AppData\Local\Temp\469d7c83-6e1a-4366-b948-6a415b0279be\Temp.csproj]
  Successfully created package
'C:\Users\xxxxxx\AppData\Local\Temp\158464074\myModules\InstallationUtils\InstallationUtils.1.4.8.nupkg'.
C:\Program Files\dotnet\sdk\3.1.201\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): error :
Index was outside the bounds of the array.
[C:\Users\xxxxxx\AppData\Local\Temp\469d7c83-6e1a-4366-b948-6a415b0279be\Temp.csproj]
'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.1\PSModule.psm1:10944 char:17
+ ...             Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], WriteErrorException
       + FullyQualifiedErrorId : FailedToCreateCompressedModule,Publish-PSArtifactUtility

Is anyone have similar issues and managed to fix it? thanks

Upvotes: 1

Views: 477

Answers (1)

Dai Bok
Dai Bok

Reputation: 3616

I have a work around, which involves replacing the old version of version nuget.exe in

C:\Users\xxxxx\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\

with the latest version of nuget.exe .

I found the work around on SQLDBAWithABeard but I am hoping that there is a better solution than this?

Upvotes: 0

Related Questions