maartenba / ChocolateyPackages

Packages I maintain on Chocolatey.org
5 stars 14 forks source link

Implement workaround for Chocolatey 0.10.14 working directory limitation #31

Closed ColinM9991-zz closed 5 years ago

ColinM9991-zz commented 5 years ago

Resovles #30

This moves the Set-Location to within the Start-ChocolateyProcessAsAdmin block so the encoded command which Chocolatey generates contains the correct location path and relative path for the teamcity agent batch files.

The existing code will cause Start-ChocolateyProcessAsAdmin to generate the following code

$noSleep = $False
#$env:ChocolateyEnvironmentDebug='false'
#$env:ChocolateyEnvironmentVerbose='false'
& import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1' -Verbose:$false | Out-Null;
try {
    $progressPreference="SilentlyContinue"

    Start-Process -FilePath .\service.install.bat -Wait
    if(!$noSleep) { start-sleep 6 }
}
catch {
    if(!$noSleep) { start-sleep 8 }
    throw
}

This pull request will result in the following changes, the comment will not be included and is only for reviewers of this pull request to see what's new.

$noSleep = $False
#$env:ChocolateyEnvironmentDebug='false'
#$env:ChocolateyEnvironmentVerbose='false'
& import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1' -Verbose:$false | Out-Null;
try {
    $progressPreference="SilentlyContinue"

    # Assuming that $agentDir is C:\buildAgent
    Set-Location "C:\buildAgent\bin"; Start-Process -FilePath .\service.install.bat -Wait
    if(!$noSleep) { start-sleep 6 }
}
catch {
    if(!$noSleep) { start-sleep 8 }
    throw
}

Should this change increment the package version in the nuspec definition?

maartenba commented 5 years ago

Looks good, will build and publish soon :)