Skip to content

Commit 5d4664b

Browse files
committed
(GH-29) Correcting calls to Chocolatey
- Rather than using choco.exe directly, check to see what exists, and use that, i.e. either choco.exe of chocolatey.cmd.
1 parent 32948b7 commit 5d4664b

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

BuildScripts/default.ps1

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,15 @@ Task -Name __InstallChocolatey -Description $private -Action {
249249
if(isChocolateyInstalled) {
250250
Write-Output "Chocolatey already installed";
251251
Write-Output "Updating to latest Chocolatey..."
252-
$choco = Join-Path $script:chocolateyDir -ChildPath "choco.exe";
252+
253+
if(Test-Path -Path (Join-Path -Path $script:chocolateyDir -ChildPath "choco.exe")) {
254+
$script:chocolateyCommand = Join-Path $script:chocolateyDir -ChildPath "choco.exe"
255+
} else {
256+
$script:chocolateyCommand = Join-Path (Join-Path $script:chocolateyDir "chocolateyInstall") -ChildPath "chocolatey.cmd";
257+
}
253258

254259
exec {
255-
Invoke-Expression "$choco upgrade chocolatey";
260+
Invoke-Expression "$script:chocolateyCommand upgrade chocolatey";
256261
}
257262

258263
Write-Output "Latest Chocolatey installed."
@@ -281,14 +286,13 @@ Task -Name __InstallChocolatey -Description $private -Action {
281286
Task -Name __InstallReSharperCommandLineTools -Depends __InstallChocolatey -Description $private -Action {
282287
$chocolateyBinDir = Join-Path $script:chocolateyDir -ChildPath "bin";
283288
$inspectCodeExe = Join-Path $chocolateyBinDir -ChildPath "inspectcode.exe";
284-
$choco = Join-Path $script:chocolateyDir -ChildPath "choco.exe";
285289

286290
try {
287291
Write-Output "Running Install Command Line Tools..."
288292

289293
if (-not (Test-Path $inspectCodeExe)) {
290294
exec {
291-
Invoke-Expression "$choco install resharper-clt -y";
295+
Invoke-Expression "$script:chocolateyCommand install resharper-clt -y";
292296
}
293297
} else {
294298
Write-Output "resharper-clt already installed";
@@ -303,13 +307,11 @@ Task -Name __InstallReSharperCommandLineTools -Depends __InstallChocolatey -Desc
303307
}
304308

305309
Task -Name __UpdateReSharperCommandLineTools -Description $private -Action {
306-
$choco = Join-Path $script:chocolateyDir -ChildPath "choco.exe";
307-
308310
try {
309311
Write-Output "Running Upgrade Command Line Tools..."
310312

311313
exec {
312-
Invoke-Expression "$choco upgrade resharper-clt";
314+
Invoke-Expression "$script:chocolateyCommand upgrade resharper-clt";
313315
}
314316

315317
Write-Output ("************ Upgrade Command Line Tools Successful ************")
@@ -345,14 +347,13 @@ Task -Name __InstallPSBuild -Description $private -Action {
345347
Task -Name __InstallGitVersion -Depends __InstallChocolatey -Description $private -Action {
346348
$chocolateyBinDir = Join-Path $script:chocolateyDir -ChildPath "bin";
347349
$gitVersionExe = Join-Path $chocolateyBinDir -ChildPath "GitVersion.exe";
348-
$choco = Join-Path $script:chocolateyDir -ChildPath "choco.exe";
349350

350351
try {
351352
Write-Output "Running Install GitVersion.Portable..."
352353

353354
if (-not (Test-Path $gitVersionExe)) {
354355
exec {
355-
Invoke-Expression "$choco install GitVersion.Portable -pre -y";
356+
Invoke-Expression "$script:chocolateyCommand install GitVersion.Portable -pre -y";
356357
}
357358
} else {
358359
Write-Output "GitVersion.Portable already installed";
@@ -367,13 +368,11 @@ Task -Name __InstallGitVersion -Depends __InstallChocolatey -Description $privat
367368
}
368369

369370
Task -Name __UpdateGitVersion -Description $private -Action {
370-
$choco = Join-Path $script:chocolateyDir -ChildPath "choco.exe";
371-
372371
try {
373372
Write-Output "Running Upgrade GitVersion.Portable..."
374373

375374
exec {
376-
Invoke-Expression "$choco upgrade GitVersion.Portable";
375+
Invoke-Expression "$script:chocolateyCommand upgrade GitVersion.Portable";
377376
}
378377

379378
Write-Output ("************ Upgrade GitVersion.Portable Successful ************")

0 commit comments

Comments
 (0)