File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2808,6 +2808,45 @@ assembly
28082808 }
28092809}
28102810
2811+ # Save PSOptions to be restored by Restore-PSOptions
2812+ function Save-PSOptions {
2813+ param (
2814+ [ValidateScript ({$parent = Split-Path $_ ;if ($parent ){Test-Path $parent }else {return $true }})]
2815+ [ValidateNotNullOrEmpty ()]
2816+ [string ]
2817+ $PSOptionsPath = (Join-Path - Path $PSScriptRoot - ChildPath ' psoptions.json' ),
2818+
2819+ [ValidateNotNullOrEmpty ()]
2820+ [object ]
2821+ $Options = (Get-PSOptions - DefaultToNew)
2822+ )
2823+
2824+ $Options | ConvertTo-Json - Depth 3 | Out-File - Encoding utf8 - FilePath $PSOptionsPath
2825+ }
2826+
2827+ # Restore PSOptions
2828+ # Optionally remove the PSOptions file
2829+ function Restore-PSOptions {
2830+ param (
2831+ [ValidateScript ({Test-Path $_ })]
2832+ [string ]
2833+ $PSOptionsPath = (Join-Path - Path $PSScriptRoot - ChildPath ' psoptions.json' ),
2834+ [switch ]
2835+ $Remove
2836+ )
2837+
2838+ $options = Get-Content - Path $PSOptionsPath | ConvertFrom-Json
2839+
2840+ if ($Remove )
2841+ {
2842+ # Remove PSOptions.
2843+ # The file is only used to set the PSOptions.
2844+ Remove-Item - Path $psOptionsPath
2845+ }
2846+
2847+ Set-PSOptions - Options $options
2848+ }
2849+
28112850$script :RESX_TEMPLATE = @'
28122851<?xml version="1.0" encoding="utf-8"?>
28132852<root>
Original file line number Diff line number Diff line change @@ -180,7 +180,7 @@ function Start-PSPackage {
180180 # Zip symbols.zip to the root package
181181 $zipSource = Join-Path $symbolsSource - ChildPath ' *'
182182 $zipPath = Join-Path - Path $Source - ChildPath ' symbols.zip'
183- $ Script :Options | ConvertTo-Json - Depth 3 | Out-File - Encoding utf8 - FilePath (Join-Path - Path $source - ChildPath ' psoptions.json' )
183+ Save-PSOptions - PSOptionsPath (Join-Path - Path $source - ChildPath ' psoptions.json' ) - Options $ Script :Options
184184 Compress-Archive - Path $zipSource - DestinationPath $zipPath
185185 }
186186 finally
@@ -493,11 +493,9 @@ function Expand-PSSignedBuild
493493 Restore-PSModuleToBuild - PublishPath $buildPath
494494
495495 $psOptionsPath = Join-Path $buildPath - ChildPath ' psoptions.json'
496- $options = Get-Content - Path $psOptionsPath | ConvertFrom-Json
496+ Restore-PSOptions - PSOptionsPath $psOptionsPath - Remove
497497
498- # Remove PSOptions.
499- # The file is only used to set the PSOptions.
500- Remove-Item - Path $psOptionsPath
498+ $options = Get-PSOptions
501499
502500 $options.PSModuleRestore = $true
503501
Original file line number Diff line number Diff line change 1414# VSTS passes it as 'refs/heads/release-v6.0.2'
1515
1616$branchOnly = $Branch -replace ' ^refs/heads/' ;
17+ $branchOnly = $branchOnly -replace ' [_\-]'
1718
1819if ($ReleaseTag -eq ' fromBranch' -or ! $ReleaseTag )
1920{
You can’t perform that action at this time.
0 commit comments