Skip to content

Instantly share code, notes, and snippets.

@trondhindenes
Created December 18, 2015 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save trondhindenes/75c7f7f6674fdd685785 to your computer and use it in GitHub Desktop.
Save trondhindenes/75c7f7f6674fdd685785 to your computer and use it in GitHub Desktop.
#Module PowerShellGet
#File PSModule.psm1
#Bug causes publish-module to fail if user has a profile with spaces in it ("C:\users\sam smith")
#Replace line 6817 with the following:
Microsoft.PowerShell.Management\Start-Process -FilePath "$script:NuGetExePath" `
-ArgumentList ('push "' + $NupkgPath + '"' + " -source $Destination -NonInteractive -ApiKey $NugetApiKey") `
-RedirectStandardError $tempErrorFile `
-RedirectStandardOutput $tempOutputFile `
-NoNewWindow `
-Wait
@dlwyatt
Copy link

dlwyatt commented Dec 18, 2015

Odd practice there. ArgumentList is an array, so shouldn't they have just done this instead?

-ArgumentList @('push', $NupkgPath, '-source', $Destination, '-NonInteractive', '-ApiKey', $NugetApiKey)

If for some reason the manual string construction is needed, then all variables should be quoted (even $NugetApiKey), for safety.

@trondhindenes
Copy link
Author

I had to push and update in the shortest amount of time possible, so I just tweakted it in the debugger so that it would go thru. But I completely agree, it should be made more robust. My point was to show that the call may fail if $NupkgPath isn't quoted as it may contain spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment