Skip to content

Commit 6c3ca68

Browse files
Ticket ## : Fix build CI
1 parent 879bd4b commit 6c3ca68

25 files changed

+392
-116
lines changed

default.ps1

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ task compile -depends clean {
5555
task pack -depends compile {
5656
exec { dotnet pack $source_dir\CaseManagement.BPMN\CaseManagement.BPMN.csproj -c $config --no-build $versionSuffix --output $result_dir }
5757
exec { dotnet pack $source_dir\CaseManagement.BPMN.AspNetCore\CaseManagement.BPMN.AspNetCore.csproj -c $config --no-build $versionSuffix --output $result_dir }
58-
exec { dotnet pack $source_dir\CaseManagement.BPMN.Common\CaseManagement.BPMN.Common.csproj -c $config --no-build $versionSuffix --output $result_dir }
5958
exec { dotnet pack $source_dir\CaseManagement.BPMN.Persistence.EF\CaseManagement.BPMN.Persistence.EF.csproj -c $config --no-build $versionSuffix --output $result_dir }
6059
exec { dotnet pack $source_dir\CaseManagement.CMMN\CaseManagement.CMMN.csproj -c $config --no-build $versionSuffix --output $result_dir }
6160
exec { dotnet pack $source_dir\CaseManagement.CMMN.AspNetCore\CaseManagement.CMMN.AspNetCore.csproj -c $config --no-build $versionSuffix --output $result_dir }

global.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"sdk": {
3-
"version": "5.0.103"
3+
"version": "5.0.103",
4+
"rollForward": "latestFeature"
45
}
56
}

private/CleanupEnvironment.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ function CleanupEnvironment {
55
$env:PATH = $currentContext.originalEnvPath
66
Set-Location $currentContext.originalDirectory
77
$global:ErrorActionPreference = $currentContext.originalErrorActionPreference
8+
$psake.LoadedTaskModules = @{}
9+
$psake.ReferenceTasks = @{}
810
[void] $psake.context.Pop()
911
}
1012
}

private/ConfigureBuildEnvironment.ps1

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@ function ConfigureBuildEnvironment {
3838
}
3939
{($_ -eq '4.5') -or ($_ -eq '4.5.1') -or ($_ -eq '4.5.2')} {
4040
$versions = @('v4.0.30319')
41-
$buildToolsVersions = @('15.0', '14.0', '12.0')
41+
$buildToolsVersions = @('16.0', '15.0', '14.0', '12.0')
4242
}
4343
{($_ -eq '4.6') -or ($_ -eq '4.6.1') -or ($_ -eq '4.6.2')} {
4444
$versions = @('v4.0.30319')
45-
$buildToolsVersions = @('15.0', '14.0')
45+
$buildToolsVersions = @('16.0', '15.0', '14.0')
4646
}
4747
{($_ -eq '4.7') -or ($_ -eq '4.7.1') -or ($_ -eq '4.7.2')} {
4848
$versions = @('v4.0.30319')
49-
$buildToolsVersions = @('15.0')
49+
$buildToolsVersions = @('16.0', '15.0')
50+
}
51+
'4.8' {
52+
$versions = @('v4.0.30319')
53+
$buildToolsVersions = @('16.0', '15.0')
5054
}
5155

5256
default {
@@ -102,7 +106,7 @@ function ConfigureBuildEnvironment {
102106

103107
# borrowed from nightroman https://github.com/nightroman/Invoke-Build
104108
if ($vsInstances = Get-VSSetupInstance) {
105-
$vs = @($vsInstances | Select-VSSetupInstance -Version '[15.0,16.0)' -Require Microsoft.Component.MSBuild)
109+
$vs = @($vsInstances | Select-VSSetupInstance -Version '[15.0, 16.0)' -Require Microsoft.Component.MSBuild)
106110
if ($vs) {
107111
if ($buildToolsKey -eq 'MSBuildToolsPath32') {
108112
$frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\15.0\Bin
@@ -112,7 +116,7 @@ function ConfigureBuildEnvironment {
112116
}
113117
}
114118

115-
$vs = @($vsInstances | Select-VSSetupInstance -Version '[15.0,16.0)' -Product Microsoft.VisualStudio.Product.BuildTools)
119+
$vs = @($vsInstances | Select-VSSetupInstance -Version '[15.0, 16.0)' -Product Microsoft.VisualStudio.Product.BuildTools)
116120
if ($vs) {
117121
if ($buildToolsKey -eq 'MSBuildToolsPath32') {
118122
$frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\15.0\Bin
@@ -138,6 +142,38 @@ function ConfigureBuildEnvironment {
138142
}
139143
}
140144
}
145+
elseif ($ver -eq "16.0") {
146+
if ($null -eq (Get-Module -Name VSSetup)) {
147+
if ($null -eq (Get-Module -Name VSSetup -ListAvailable)) {
148+
WriteColoredOutput ($msgs.warning_missing_vsssetup_module -f $ver) -foregroundcolor Yellow
149+
continue
150+
}
151+
152+
Import-Module VSSetup
153+
}
154+
155+
# borrowed from nightroman https://github.com/nightroman/Invoke-Build
156+
if ($vsInstances = Get-VSSetupInstance) {
157+
$vs = @($vsInstances | Select-VSSetupInstance -Version '[16.0,)' -Require Microsoft.Component.MSBuild)
158+
if ($vs) {
159+
$frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\Current\Bin
160+
}
161+
162+
$vs = @($vsInstances | Select-VSSetupInstance -Version '[16.0,)' -Product Microsoft.VisualStudio.Product.BuildTools)
163+
if ($vs) {
164+
$frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\Current\Bin
165+
}
166+
}
167+
else {
168+
if (!($root = ${env:ProgramFiles(x86)})) {$root = $env:ProgramFiles}
169+
if (Test-Path -LiteralPath "$root\Microsoft Visual Studio\2019") {
170+
$rp = @(Resolve-Path "$root\Microsoft Visual Studio\2019\*\MSBuild\Current\Bin" -ErrorAction SilentlyContinue)
171+
if ($rp) {
172+
$frameworkDirs += $rp[-1].ProviderPath
173+
}
174+
}
175+
}
176+
}
141177
elseif (Test-Path "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$ver") {
142178
$frameworkDirs += (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$ver" -Name $buildToolsKey).$buildToolsKey
143179
}
@@ -156,7 +192,6 @@ function ConfigureBuildEnvironment {
156192
}
157193

158194
$frameworkDirs | ForEach-Object { Assert (test-path $_ -pathType Container) ($msgs.error_no_framework_install_dir_found -f $_)}
159-
160195
$env:PATH = ($frameworkDirs -join ";") + ";$env:PATH"
161196
}
162197

private/ExecuteInBuildFileScope.ps1

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,36 @@ function ExecuteInBuildFileScope {
88
$psake.build_script_dir = $psake.build_script_file.DirectoryName
99
$psake.build_success = $false
1010

11-
$psake.context.push(@{
12-
"taskSetupScriptBlock" = {};
13-
"taskTearDownScriptBlock" = {};
14-
"executedTasks" = new-object System.Collections.Stack;
15-
"callStack" = new-object System.Collections.Stack;
16-
"originalEnvPath" = $env:PATH;
17-
"originalDirectory" = get-location;
18-
"originalErrorActionPreference" = $global:ErrorActionPreference;
19-
"tasks" = @{};
20-
"aliases" = @{};
21-
"properties" = @();
22-
"includes" = new-object System.Collections.Queue;
23-
"config" = CreateConfigurationForNewContext $buildFile $framework
24-
})
25-
11+
# Create a new psake context
12+
$psake.context.push(
13+
@{
14+
"buildSetupScriptBlock" = {}
15+
"buildTearDownScriptBlock" = {}
16+
"taskSetupScriptBlock" = {}
17+
"taskTearDownScriptBlock" = {}
18+
"executedTasks" = new-object System.Collections.Stack
19+
"callStack" = new-object System.Collections.Stack
20+
"originalEnvPath" = $env:PATH
21+
"originalDirectory" = get-location
22+
"originalErrorActionPreference" = $global:ErrorActionPreference
23+
"tasks" = @{}
24+
"aliases" = @{}
25+
"properties" = new-object System.Collections.Stack
26+
"includes" = new-object System.Collections.Queue
27+
"config" = CreateConfigurationForNewContext $buildFile $framework
28+
}
29+
)
30+
31+
# Load in the psake configuration (or default)
2632
LoadConfiguration $psake.build_script_dir
2733

2834
set-location $psake.build_script_dir
2935

36+
# Import any modules declared in the build script
3037
LoadModules
3138

3239
$frameworkOldValue = $framework
40+
3341
. $psake.build_script_file.FullName
3442

3543
$currentContext = $psake.context.Peek()

private/FormatErrorMessage.ps1

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function FormatErrorMessage
2+
{
3+
[CmdletBinding()]
4+
param(
5+
[Parameter(ValueFromPipeline=$true)]
6+
$ErrorRecord = $Error[0]
7+
)
8+
9+
$currentConfig = GetCurrentConfigurationOrDefault
10+
if ($currentConfig.verboseError) {
11+
$error_message = "{0}: An Error Occurred. See Error Details Below: $($script:nl)" -f (Get-Date)
12+
$error_message += ("-" * 70) + $script:nl
13+
$error_message += "Error: {0}$($script:nl)" -f (ResolveError $ErrorRecord -Short)
14+
$error_message += ("-" * 70) + $script:nl
15+
$error_message += ResolveError $ErrorRecord
16+
$error_message += ("-" * 70) + $script:nl
17+
$error_message += "Script Variables" + $script:nl
18+
$error_message += ("-" * 70) + $script:nl
19+
$error_message += get-variable -scope script | format-table | out-string
20+
} else {
21+
# ($_ | Out-String) gets error messages with source information included.
22+
$error_message = "Error: {0}: $($script:nl){1}" -f (Get-Date), (ResolveError $ErrorRecord -Short)
23+
}
24+
25+
$error_message
26+
}

private/ResolveError.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ function ResolveError
1515
$ex = $_.Exception
1616

1717
if (-not $Short) {
18-
$error_message = "`nErrorRecord:{0}ErrorRecord.InvocationInfo:{1}Exception:`n{2}"
18+
$error_message = "$($script:nl)ErrorRecord:{0}ErrorRecord.InvocationInfo:{1}Exception:$($script:nl){2}"
1919
$formatted_errorRecord = $_ | format-list * -force | out-string
2020
$formatted_invocationInfo = $_.InvocationInfo | format-list * -force | out-string
2121
$formatted_exception = ''
2222

2323
$i = 0
2424
while ($null -ne $ex) {
2525
$i++
26-
$formatted_exception += ("$i" * 70) + "`n" +
27-
($ex | format-list * -force | out-string) + "`n"
26+
$formatted_exception += ("$i" * 70) + $script:nl +
27+
($ex | format-list * -force | out-string) + $script:nl
2828
$ex = $ex | SelectObjectWithDefault -Name 'InnerException' -Value $null
2929
}
3030

@@ -34,7 +34,7 @@ function ResolveError
3434
$lastException = @()
3535
while ($null -ne $ex) {
3636
$lastMessage = $ex | SelectObjectWithDefault -Name 'Message' -Value ''
37-
$lastException += ($lastMessage -replace "`n", '')
37+
$lastException += ($lastMessage -replace $script:nl, '')
3838
if ($ex -is [Data.SqlClient.SqlException]) {
3939
$lastException += "(Line [$($ex.LineNumber)] " +
4040
"Procedure [$($ex.Procedure)] Class [$($ex.Class)] " +
@@ -46,7 +46,7 @@ function ResolveError
4646

4747
$header = $null
4848
$header = (($_.InvocationInfo |
49-
SelectObjectWithDefault -Name 'PositionMessage' -Value '') -replace "`n", ' '),
49+
SelectObjectWithDefault -Name 'PositionMessage' -Value '') -replace $script:nl, ' '),
5050
($_ | SelectObjectWithDefault -Name 'Message' -Value ''),
5151
($_ | SelectObjectWithDefault -Name 'Exception' -Value '') |
5252
Where-Object { -not [String]::IsNullOrEmpty($_) } |

private/Test-ModuleVersion.ps1

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<#
2+
.SYNOPSIS
3+
Validate that the version of a module passed in via the $currentVersion
4+
parameter is valid based on the criteria specified by the following
5+
parameters.
6+
.DESCRIPTION
7+
This function is used to determine whether or not a given module is within
8+
the version bounds specified by the parameters passed in. Psake will use
9+
this information to determine if the module it has found will contain the
10+
proper version of the shared task it has been asked to import.
11+
12+
This function should allow bounds that are only on the lower limit, only on
13+
the upper, within a range, or if no bounds are supplied, the current module
14+
will be accepted without question.
15+
.PARAMETER currentVersion
16+
The version of the module in the current session to be subjected to comparison
17+
.PARAMETER minimumVersion
18+
The lower bound of the version that will be accepted. This comparison should
19+
be inclusive, meaning an input version greater than or equal to this version
20+
should be accepted.
21+
.PARAMETER maximumVersion
22+
The upper bound of the version that will be accepted. This comparison should
23+
be inclusive, meaning an input version less than or equal to this version
24+
should be accepted.
25+
.PARAMETER lessThanVersion
26+
The upper bound of the version that will be accepted. This comparison should
27+
be exlusive. Meaning an input version that is less than only, not equal to
28+
this version, will be accepted.
29+
.INPUTS
30+
A $currentVersion of type [System.Version] or a convertable string.
31+
A set of version criteria, each of type [System.Version] or a convertable string.
32+
.OUTPUTS
33+
boolean - Pass/Fail
34+
#>
35+
function Test-ModuleVersion {
36+
[CmdletBinding()]
37+
param (
38+
[string]$currentVersion,
39+
[string]$minimumVersion,
40+
[string]$maximumVersion,
41+
[string]$lessThanVersion
42+
)
43+
44+
begin {
45+
}
46+
47+
process {
48+
$result = $true
49+
50+
# If no version is specified simply return true and allow the module to pass.
51+
if("$minimumVersion$maximumVersion$lessthanVersion" -eq ''){
52+
return $true
53+
}
54+
55+
# Single integer values cannot be converted to type system.version.
56+
# We convert to a string, and if there is a single character we know that
57+
# we need to add a '.0' to the integer to make it convertable to a version.
58+
if(![string]::IsNullOrEmpty($currentVersion)) {
59+
if($currentVersion.ToString().Length -eq 1) {
60+
[version]$currentVersion = "$currentVersion.0"
61+
} else {
62+
[version]$currentVersion = $currentVersion
63+
}
64+
}
65+
66+
if(![string]::IsNullOrEmpty($minimumVersion)) {
67+
if($minimumVersion.ToString().Length -eq 1){
68+
[version]$minimumVersion = "$minimumVersion.0"
69+
} else {
70+
[version]$minimumVersion = $minimumVersion
71+
}
72+
73+
if($currentVersion.CompareTo($minimumVersion) -lt 0){
74+
$result = $false
75+
}
76+
}
77+
78+
if(![string]::IsNullOrEmpty($maximumVersion)) {
79+
if($maximumVersion.ToString().Length -eq 1) {
80+
[version]$maximumVersion = "$maximumVersion.0"
81+
} else {
82+
[version]$maximumVersion = $maximumVersion
83+
}
84+
85+
if ($currentVersion.CompareTo($maximumVersion) -gt 0) {
86+
$result = $false
87+
}
88+
}
89+
90+
if(![string]::IsNullOrEmpty($lessThanVersion)) {
91+
if($lessThanVersion.ToString().Length -eq 1) {
92+
[version]$lessThanVersion = "$lessThanVersion.0"
93+
} else {
94+
[version]$lessThanVersion = $lessThanVersion
95+
}
96+
97+
if($currentVersion.CompareTo($lessThanVersion) -ge 0) {
98+
$result = $false
99+
}
100+
}
101+
102+
Write-Output $result
103+
}
104+
105+
end {
106+
}
107+
}

psake

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env sh
2+
3+
# Use greadlink on macOS.
4+
if [ "$(uname)" = "Darwin" ]; then
5+
which greadlink > /dev/null || {
6+
printf 'GNU readlink not found\n'
7+
exit 1
8+
}
9+
alias readlink="greadlink"
10+
fi
11+
12+
pwsh -NoProfile -Command "& $(dirname "$(readlink -f -- "$0")")/psake.ps1 $@"

psake-config.ps1

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
1-
$config.buildFileName="default.ps1"
2-
$config.framework = "4.6.1"
1+
<#
2+
-------------------------------------------------------------------
3+
Defaults
4+
-------------------------------------------------------------------
5+
$config.buildFileName="psakefile.ps1"
6+
$config.legacyBuildFileName="default.ps1"
7+
$config.framework = "4.0"
38
$config.taskNameFormat="Executing {0}"
4-
$config.verboseError= $true
9+
$config.verboseError=$false
510
$config.coloredOutput = $true
6-
$config.moduleScope="global"
7-
$config.taskNameFormat= { param($taskName) "Executing $taskName at $(get-date)" }
11+
$config.modules=$null
12+
13+
-------------------------------------------------------------------
14+
Load modules from .\modules folder and from file my_module.psm1
15+
-------------------------------------------------------------------
16+
$config.modules=(".\modules\*.psm1",".\my_module.psm1")
17+
18+
-------------------------------------------------------------------
19+
Use scriptblock for taskNameFormat
20+
-------------------------------------------------------------------
21+
$config.taskNameFormat= { param($taskName) "Executing $taskName at $(get-date)" }
22+
#>

0 commit comments

Comments
 (0)