3232$Script :TraceVerboseTimer = New-Object System.Diagnostics.Stopwatch
3333$Script :TraceVerboseTimer.Start ()
3434
35-
3635$ErrorActionPreference = " Stop"
3736Set-StrictMode - Version Latest
3837
@@ -44,55 +43,55 @@ function init {
4443 param ()
4544
4645 # Calculate Paths
47- # The output path is just a temporary output and logging location
48- $Script :OutputPath = Join-Path $Path output
46+ # The output path is just a temporary output and logging location
47+ $Script :OutputPath = Join-Path $Path output
4948
50- if (Test-Path $OutputPath - PathType Leaf) {
51- throw " Cannot create folder for Configuration because there's a file in the way at '$OutputPath '"
52- }
53- if (! (Test-Path $OutputPath - PathType Container)) {
54- $null = New-Item $OutputPath - Type Directory - Force
55- }
49+ if (Test-Path $OutputPath - PathType Leaf) {
50+ throw " Cannot create folder for Configuration because there's a file in the way at '$OutputPath '"
51+ }
52+ if (! (Test-Path $OutputPath - PathType Container)) {
53+ $null = New-Item $OutputPath - Type Directory - Force
54+ }
5655
57- # We expect the source for the module in a subdirectory called one of three things:
58- $Script :SourcePath = " src" , " source" , ${ModuleName} | ForEach-Object { Join-Path $Path $_ - Resolve - ErrorAction Ignore } | Select-Object - First 1
59- if (! $SourcePath ) {
60- Write-Warning " This Build script expects a 'Source' or '$ModuleName ' folder to be alongside it."
61- throw " Can't find module source folder."
62- }
56+ # We expect the source for the module in a subdirectory called one of three things:
57+ $Script :SourcePath = " src" , " source" , ${ModuleName} | ForEach-Object { Join-Path $Path $_ - Resolve - ErrorAction Ignore } | Select-Object - First 1
58+ if (! $SourcePath ) {
59+ Write-Warning " This Build script expects a 'Source' or '$ModuleName ' folder to be alongside it."
60+ throw " Can't find module source folder."
61+ }
6362
64- $Script :ManifestPath = Join-Path $SourcePath " ${ModuleName} .psd1" - Resolve - ErrorAction Ignore
65- if (! $ManifestPath ) {
66- Write-Warning " This Build script expects a '${ModuleName} .psd1' in the '$SourcePath ' folder."
67- throw " Can't find module source files"
68- }
69- $Script :TestPath = " Tests" , " Specs" | ForEach-Object { Join-Path $Path $_ - Resolve - ErrorAction Ignore } | Select-Object - First 1
70- if (! $TestPath ) {
71- Write-Warning " This Build script expects a 'Tests' or 'Specs' folder to contain tests."
72- }
73- # Calculate Version here, because we need it for the release path
74- [Version ]$Script :Version = Get-Metadata $ManifestPath - PropertyName ModuleVersion
75-
76- # If the RevisionNumber is specified as ZERO, this is a release build ...
77- # If the RevisionNumber is not specified, this is a dev box build
78- # If the RevisionNumber is specified, we assume this is a CI build
79- if ($Script :RevisionNumber -ge 0 ) {
80- # For CI builds we don't increment the build number
81- $Script :Build = if ($Version.Build -le 0 ) { 0 } else { $Version.Build }
82- } else {
83- # For dev builds, assume we're working on the NEXT release
84- $Script :Build = if ($Version.Build -le 0 ) { 1 } else { $Version.Build + 1 }
85- }
63+ $Script :ManifestPath = Join-Path $SourcePath " ${ModuleName} .psd1" - Resolve - ErrorAction Ignore
64+ if (! $ManifestPath ) {
65+ Write-Warning " This Build script expects a '${ModuleName} .psd1' in the '$SourcePath ' folder."
66+ throw " Can't find module source files"
67+ }
68+ $Script :TestPath = " Tests" , " Specs" | ForEach-Object { Join-Path $Path $_ - Resolve - ErrorAction Ignore } | Select-Object - First 1
69+ if (! $TestPath ) {
70+ Write-Warning " This Build script expects a 'Tests' or 'Specs' folder to contain tests."
71+ }
72+ # Calculate Version here, because we need it for the release path
73+ [Version ]$Script :Version = Get-Metadata $ManifestPath - PropertyName ModuleVersion
74+
75+ # If the RevisionNumber is specified as ZERO, this is a release build ...
76+ # If the RevisionNumber is not specified, this is a dev box build
77+ # If the RevisionNumber is specified, we assume this is a CI build
78+ if ($Script :RevisionNumber -ge 0 ) {
79+ # For CI builds we don't increment the build number
80+ $Script :Build = if ($Version.Build -le 0 ) { 0 } else { $Version.Build }
81+ } else {
82+ # For dev builds, assume we're working on the NEXT release
83+ $Script :Build = if ($Version.Build -le 0 ) { 1 } else { $Version.Build + 1 }
84+ }
8685
87- if ([string ]::IsNullOrEmpty($RevisionNumber ) -or $RevisionNumber -eq 0 ) {
88- $Script :Version = New-Object Version $Version.Major , $Version.Minor , $Build
89- } else {
90- $Script :Version = New-Object Version $Version.Major , $Version.Minor , $Build , $RevisionNumber
91- }
86+ if ([string ]::IsNullOrEmpty($RevisionNumber ) -or $RevisionNumber -eq 0 ) {
87+ $Script :Version = New-Object Version $Version.Major , $Version.Minor , $Build
88+ } else {
89+ $Script :Version = New-Object Version $Version.Major , $Version.Minor , $Build , $RevisionNumber
90+ }
9291
93- # The release path is where the final module goes
94- $Script :ReleasePath = Join-Path $Path $Version
95- $Script :ReleaseManifest = Join-Path $ReleasePath " ${ModuleName} .psd1"
92+ # The release path is where the final module goes
93+ $Script :ReleasePath = Join-Path $Path $Version
94+ $Script :ReleaseManifest = Join-Path $ReleasePath " ${ModuleName} .psd1"
9695
9796}
9897
0 commit comments