/
LicenseCollector.psm1
78 lines (68 loc) · 2.25 KB
/
LicenseCollector.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
72
73
74
75
76
77
78
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 = "LicenseCollector"
[string] $ToolDownloadUrl = "https://github.com/GriffinPlus/LicenseCollector/releases/download/v2.0.0/LicenseCollector-portable-v2.0.0.zip"
[string] $ToolVersionHash = "3C1281060FC1281E72645A790BDE771A0B51111110DAE476544EE220E9E3773F"
#-------------------------------------------------------------------------------------------------------------------------------------
function LicenseCollector
{
Param
(
[Parameter()][string] $SolutionPath = $global:SolutionPath,
[Parameter()][string] $Configuration,
[Parameter()][string] $Platform,
[Parameter()][string] $SearchPattern = "*.License",
[Parameter()][string] $TemplatePath = "",
[Parameter()][string] $OutputPath,
[Parameter()][switch] $IsVerbose,
[Parameter()][switch] $PauseOnError
)
Try
{
$ToolDirectory = DownloadBuildTool $ToolName $ToolDownloadUrl $ToolVersionHash
$LicenseCollectorToolPath = "$ToolDirectory\LicenseCollector.dll"
if (!(Test-Path $LicenseCollectorToolPath -PathType Leaf))
{
Write-Host -ForegroundColor "Red" "The LicenseCollector could not be found under '$LicenseCollectorToolPath'. Stopping further processing..."
if ($PauseOnError)
{
Read-Host "Press ANY key..."
}
exit(-1)
}
Write-Host -ForegroundColor "Green" "Collecting licenses for ($Configuration|$Platform) build..."
$cmd = @("dotnet.exe")
$cmd += $LicenseCollectorToolPath
if ($IsVerbose)
{
$cmd += "-v"
}
$cmd += "-s"
$cmd += "$SolutionPath"
$cmd += "-c"
$cmd += "$Configuration"
$cmd += "-p"
$cmd += "$Platform"
$cmd += "--searchPattern"
$cmd += "$SearchPattern"
$cmd += "--licenseTemplatePath"
$cmd += "$TemplatePath"
$cmd += "$OutputPath"
Write-Host "Cmd: $cmd"
EnvRunExec $cmd
}
Catch [Exception]
{
# tell the caller it has all gone wrong
echo $_.Exception|format-list -force
if ($PauseOnError) {
Read-Host "Press ANY key..."
}
exit(-1)
}
}