/
PreBuildWizard.psm1
71 lines (63 loc) · 2.4 KB
/
PreBuildWizard.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"
[String]$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
Import-Module "$ScriptDir\Configuration.psm1"
Import-Module "$ScriptDir\Helper.psm1"
#-------------------------------------------------------------------------------------------------------------------------------------
# Properties
[string] $ToolName = "PreBuildWizard"
[string] $ToolDownloadUrl = "https://github.com/GriffinPlus/PreBuildWizard/releases/download/v3.0.2/PreBuildWizard-portable-v3.0.2.zip"
[string] $ToolVersionHash = "3E97629175F04D1936DCC67834BBEECFBAA23EA6F0DF40FD5F02BA84387E9108"
#-------------------------------------------------------------------------------------------------------------------------------------
function PreBuildWizard
{
Param
(
[Parameter()][string] $SolutionPath = $global:SolutionPath,
[Parameter()][string] $PreBuildWizardRelativeSourcePath = "src",
[Parameter()][switch] $SkipNuGetConsistencyCheck,
[Parameter()][switch] $PauseOnError
)
Try
{
$ToolDirectory = DownloadBuildTool $ToolName $ToolDownloadUrl $ToolVersionHash
$SolutionDir = Split-Path -Path "$SolutionPath"
$BaseIntermediateOutputPath = "$SolutionDir\_build\.obj"
$PreBuildWizardToolPath = "$ToolDirectory\PreBuildWizard.dll"
if (!(Test-Path $PreBuildWizardToolPath -PathType Leaf))
{
Write-Host -ForegroundColor "Red" "The PreBuildWizard could not be found under '$PreBuildWizardToolPath'. Stopping further processing..."
if ($PauseOnError)
{
Read-Host "Press ANY key..."
}
exit(-1)
}
Write-Host -ForegroundColor "Green" "Running PreBuildWizard..."
$PreBuildWizardAbsoluteSourcePath = [System.IO.Path]::GetFullPath((Join-Path $SolutionDir $PreBuildWizardRelativeSourcePath))
if ($PreBuildWizardAbsoluteSourcePath.StartsWith($SolutionDir))
{
if ($SkipNuGetConsistencyCheck)
{
EnvRunExec ( "dotnet.exe", "$PreBuildWizardToolPath", "$PreBuildWizardAbsoluteSourcePath" )
}
else
{
EnvRunExec ( "dotnet.exe", "$PreBuildWizardToolPath", "-b", "$BaseIntermediateOutputPath", "$PreBuildWizardAbsoluteSourcePath" )
}
}
else
{
throw "Path for patching files is outside repository structure. SourcePath: $PreBuildWizardAbsoluteSourcePath"
}
}
Catch [Exception]
{
# tell the caller it has all gone wrong
echo $_.Exception|format-list -force
if ($PauseOnError) {
Read-Host "Press ANY key..."
}
exit(-1)
}
}