From b79df7bdfd73b545ccd7d0454616b94895f0ae8e Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 23 Mar 2019 18:11:19 +0800 Subject: [PATCH 1/2] fix#191 update publish-module to allow exclude files. --- .../functions/Publish-PSArtifactUtility.ps1 | 15 +++++++++++- .../public/psgetfunctions/Publish-Module.ps1 | 23 ++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/src/PowerShellGet/private/functions/Publish-PSArtifactUtility.ps1 b/src/PowerShellGet/private/functions/Publish-PSArtifactUtility.ps1 index 4d93943f..504ae5c0 100644 --- a/src/PowerShellGet/private/functions/Publish-PSArtifactUtility.ps1 +++ b/src/PowerShellGet/private/functions/Publish-PSArtifactUtility.ps1 @@ -63,7 +63,11 @@ function Publish-PSArtifactUtility { [Parameter(ParameterSetName = 'PublishModule')] [Uri] - $ProjectUri + $ProjectUri, + + [Parameter(ParameterSetName = 'PublishModule')] + [string[]] + $Exclude ) Install-NuGetClientBinaries -CallerPSCmdlet $PSCmdlet -BootstrapNuGetExe @@ -203,6 +207,11 @@ function Publish-PSArtifactUtility { } } + $nuspecFiles = "" + if ($Exclude) { + $nuspecFileExcludePattern = $Exclude -Join ";" + $nuspecFiles = @{ src = "**/*.*"; exclude = $nuspecFileExcludePattern } + } # Add PSModule and PSGet format version tags if (-not $Tags) { @@ -368,6 +377,10 @@ function Publish-PSArtifactUtility { Dependencies = $dependencies } + if ($nuspecFiles) { + $params.Add('Files', $nuspecFiles) + } + try { $NuspecFullName = New-NuspecFile @params } diff --git a/src/PowerShellGet/public/psgetfunctions/Publish-Module.ps1 b/src/PowerShellGet/public/psgetfunctions/Publish-Module.ps1 index 4a3d1f4b..8dec0f20 100644 --- a/src/PowerShellGet/public/psgetfunctions/Publish-Module.ps1 +++ b/src/PowerShellGet/public/psgetfunctions/Publish-Module.ps1 @@ -70,6 +70,11 @@ function Publish-Module { [Uri] $ProjectUri, + [Parameter(ParameterSetName = "ModuleNameParameterSet")] + [ValidateNotNullOrEmpty()] + [string[]] + $Exclude, + [Parameter()] [switch] $Force, @@ -137,8 +142,7 @@ function Publish-Module { if (-not $DestinationLocation -or (-not (Microsoft.PowerShell.Management\Test-Path $DestinationLocation) -and - -not (Test-WebUri -uri $DestinationLocation))) - { + -not (Test-WebUri -uri $DestinationLocation))) { $message = $LocalizedData.PSGalleryPublishLocationIsMissing -f ($Repository, $Repository) ThrowError -ExceptionName "System.ArgumentException" ` -ExceptionMessage $message ` @@ -370,12 +374,12 @@ function Publish-Module { # This finds all the items without force (leaving out hidden files and dirs) then copies them Microsoft.PowerShell.Management\Get-ChildItem $Path -recurse | Microsoft.PowerShell.Management\Copy-Item -Force -Confirm:$false -WhatIf:$false -Destination { - if ($_.PSIsContainer) { - Join-Path $tempModulePathForFormatVersion $_.Parent.FullName.substring($path.length) - } - else { - join-path $tempModulePathForFormatVersion $_.FullName.Substring($path.Length) - } + if ($_.PSIsContainer) { + Join-Path $tempModulePathForFormatVersion $_.Parent.FullName.substring($path.length) + } + else { + join-path $tempModulePathForFormatVersion $_.FullName.Substring($path.Length) + } } try { @@ -561,6 +565,9 @@ function Publish-Module { if ($PSBoundParameters.Containskey('Credential')) { $PublishPSArtifactUtility_Params.Add('Credential', $Credential) } + if ($Exclude) { + $PublishPSArtifactUtility_Params.Add('Exclude', $Exclude) + } Publish-PSArtifactUtility @PublishPSArtifactUtility_Params } } From 93670f77799b328888873166f6c17371dd895262 Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 26 Mar 2019 07:47:12 +0800 Subject: [PATCH 2/2] tickle build --- Tests/PSGetPublishModule.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/PSGetPublishModule.Tests.ps1 b/Tests/PSGetPublishModule.Tests.ps1 index c62a12cb..c39dc9ab 100644 --- a/Tests/PSGetPublishModule.Tests.ps1 +++ b/Tests/PSGetPublishModule.Tests.ps1 @@ -134,7 +134,7 @@ Describe PowerShell.PSGet.PublishModuleTests -Tags 'BVT','InnerLoop' { # # Expected Result: should be able to publish a module # - It PublishModuleWithNameForSxSVersion { + It "PublishModuleWithNameForSxSVersion" { $version = "2.0.0.0" $semanticVersion = '2.0.0' RemoveItem "$script:PublishModuleBase\*"