Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

NuGetApiKey is required for nuget based gallery service #463

Open
wants to merge 21 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fd47e15
**DISABLE_SECRET_SCANNING**
alerickson Mar 13, 2019
c00f461
Merge development to master (#440)
alerickson Mar 14, 2019
8004c30
Merge remote-tracking branch 'origin/development'
alerickson Mar 15, 2019
0a2c684
Remove validation on NugetApiKey parameter
Apr 12, 2019
ff40856
Added scopeto Update-Module. Added localized error message (#471)
lwajswaj May 1, 2019
483dada
update tests (#469)
edyoung May 1, 2019
459695a
WIP: localdev publishing (#462)
Benny1007 May 2, 2019
8416d39
Changes to DSC resource PSModule (#450)
johlju May 7, 2019
432b55c
fix#191 update publish-module to allow exclude files. (#453)
Benny1007 May 7, 2019
18a9a98
Add SkipAutomaticTags Parameter to Publish-Module (#452)
awickham10 May 12, 2019
c3e0d7d
Add -Force to Get-ChildItem params (#476)
alerickson May 13, 2019
23797a9
Update module version and changelog (#477)
alerickson May 13, 2019
7de99ee
fix new-nugetpackage to cope with more output from child process (#479)
edyoung May 17, 2019
95eef98
Catch nuget error and diplay localized error instead
May 21, 2019
1aade96
Update version, packagemanagement dependency version, and changelog (…
edyoung May 21, 2019
0f667f2
Dependency update (#483)
alerickson May 21, 2019
bfc5284
Merge development to master (#440)
alerickson Mar 14, 2019
89ff9c5
Remove validation on NugetApiKey parameter
Apr 12, 2019
efe1de6
Catch nuget error and diplay localized error instead
May 21, 2019
ae1c8e0
rebase to match current development branch
May 22, 2019
22aba0c
fix silly rebase problem
May 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ function Publish-PSArtifactUtility
[string]
$Repository,

[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[Parameter(Mandatory=$false)]
[string]
$NugetApiKey,

Expand Down Expand Up @@ -531,16 +530,21 @@ $CsprojContent = @"
$ArgumentList += 'push'
$ArgumentList += "`"$NupkgPath`""
$ArgumentList += @('--source', "`"$($Destination.TrimEnd('\'))`"")
$ArgumentList += @('--api-key', "`"$NugetApiKey`"")

if ($PSBoundParameters.Containskey('NugetApiKey')) {
$ArgumentList += @('--api-key', "`"$NugetApiKey`"")
}
}
elseif($script:NuGetExePath) {
$StartProcess_params['FilePath'] = $script:NuGetExePath

$ArgumentList = @('push')
$ArgumentList += "`"$NupkgPath`""
$ArgumentList += @('-source', "`"$($Destination.TrimEnd('\'))`"")
$ArgumentList += @('-apikey', "`"$NugetApiKey`"")
$ArgumentList += '-NonInteractive'
if ($PSBoundParameters.Containskey('NugetApiKey')) {
$ArgumentList += @('--api-key', "`"$NugetApiKey`"")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nuget.exe doesn't have an argument --api-key, stick with -apikey

}
}
$StartProcess_params['ArgumentList'] = $ArgumentList

Expand Down
19 changes: 3 additions & 16 deletions src/PowerShellGet/public/psgetfunctions/Publish-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ function Publish-Module {
$RequiredVersion,

[Parameter()]
[ValidateNotNullOrEmpty()]
[string]
$NuGetApiKey,

Expand Down Expand Up @@ -151,20 +150,6 @@ function Publish-Module {
$message = $LocalizedData.PublishLocation -f ($DestinationLocation)
Write-Verbose -Message $message

if (-not $NuGetApiKey.Trim()) {
if (Microsoft.PowerShell.Management\Test-Path -Path $DestinationLocation) {
$NuGetApiKey = "$(Get-Random)"
}
else {
$message = $LocalizedData.NuGetApiKeyIsRequiredForNuGetBasedGalleryService -f ($Repository, $DestinationLocation)
ThrowError -ExceptionName "System.ArgumentException" `
-ExceptionMessage $message `
-ErrorId "NuGetApiKeyIsRequiredForNuGetBasedGalleryService" `
-CallerPSCmdlet $PSCmdlet `
-ErrorCategory InvalidArgument
}
}

$providerName = Get-ProviderName -PSCustomObject $moduleSource
if ($providerName -ne $script:NuGetProviderName) {
$message = $LocalizedData.PublishModuleSupportsOnlyNuGetBasedPublishLocations -f ($moduleSource.PublishLocation, $Repository, $Repository)
Expand Down Expand Up @@ -543,7 +528,6 @@ function Publish-Module {
$PublishPSArtifactUtility_Params = @{
PSModuleInfo = $moduleInfo
ManifestPath = $manifestPath
NugetApiKey = $NuGetApiKey
Destination = $DestinationLocation
Repository = $Repository
NugetPackageRoot = $tempModulePath
Expand All @@ -561,6 +545,9 @@ function Publish-Module {
if ($PSBoundParameters.Containskey('Credential')) {
$PublishPSArtifactUtility_Params.Add('Credential', $Credential)
}
if ($PSBoundParameters.Containskey('NugetApiKey')) {
$PublishPSArtifactUtility_Params.Add('NugetApiKey', $NuGetApiKey)
}
Publish-PSArtifactUtility @PublishPSArtifactUtility_Params
}
}
Expand Down