3
3
[CmdletBinding ()]
4
4
param (
5
5
[bool ]$InstallDotNet = $true ,
6
- [bool ]$InstallCrankAgent = $true
6
+ [bool ]$InstallCrankAgent = $true ,
7
+ [string ]$CrankBranch
7
8
)
8
9
9
10
$ErrorActionPreference = ' Stop'
@@ -24,12 +25,66 @@ function InstallDotNet {
24
25
}
25
26
}
26
27
27
- function InstallCrankAgent {
28
+ function New-TemporaryDirectory {
29
+ $parent = [System.IO.Path ]::GetTempPath()
30
+ $name = [System.Guid ]::NewGuid()
31
+ New-Item - ItemType Directory - Path (Join-Path $parent $name )
32
+ }
33
+
34
+ function BuildCrankAgent {
35
+ Write-Verbose " Cloning crank repo..."
36
+ git clone https:// github.com / dotnet/ crank.git > $null
37
+ Set-Location crank
38
+
39
+ $logFileName = ' build.log'
40
+ Write-Verbose " Building crank (see $ ( Join-Path - Path $PWD - ChildPath $logFileName ) )..."
41
+ $buildCommand = $IsWindows ? ' .\build.cmd' : ' ./build.sh'
42
+ & $buildCommand - configuration Release - pack > $logFileName
43
+
44
+ Join-Path - Path $PWD - ChildPath " artifacts/packages/Release/Shipping"
45
+ }
46
+
47
+ function GetDotNetToolsLocationArgs {
48
+ $IsWindows ? (' --tool-path' , ' c:\dotnet-tools' ) : ' -g'
49
+ }
50
+
51
+ function InstallCrankAgentTool ($LocalPackageSource ) {
52
+ Write-Verbose ' Uninstalling crank-agent...'
53
+
54
+ $uninstallArgs = ' tool' , ' uninstall' , ' Microsoft.Crank.Agent'
55
+ $uninstallArgs += GetDotNetToolsLocationArgs
56
+ & dotnet $uninstallArgs
57
+
28
58
Write-Verbose ' Installing crank-agent...'
29
- if ($IsWindows ) {
30
- dotnet tool install -- tool- path c:\dotnet- tools Microsoft.Crank.Agent -- version " 0.1.0-*"
59
+
60
+ $installArgs =
61
+ ' tool' , ' install' , ' Microsoft.Crank.Agent' ,
62
+ ' --version' , ' 0.1.0-*'
63
+
64
+ $installArgs += GetDotNetToolsLocationArgs
65
+
66
+ if ($LocalPackageSource ) {
67
+ $installArgs += ' --add-source' , $LocalPackageSource
68
+ }
69
+
70
+ & dotnet $installArgs
71
+ }
72
+
73
+ function InstallCrankAgent {
74
+ if ($CrankBranch ) {
75
+ $tempDir = New-TemporaryDirectory
76
+ Write-Verbose " Creating temporary directory: $ ( $tempDir.FullName ) "
77
+ Push-Location - Path $tempDir.FullName
78
+ try {
79
+ $packagesDirectory = BuildCrankAgent
80
+ InstallCrankAgentTool - LocalPackageSource $packagesDirectory
81
+ } finally {
82
+ Pop-Location
83
+ Write-Verbose " Removing temporary directory: $ ( $tempDir.FullName ) "
84
+ Remove-Item $tempDir.FullName - Recurse - Force - ErrorAction Ignore
85
+ }
31
86
} else {
32
- dotnet tool install - g Microsoft.Crank.Agent -- version " 0.1.0-* "
87
+ InstallCrankAgentTool
33
88
}
34
89
}
35
90
0 commit comments