diff --git a/src/chocolatey.ps1 b/src/chocolatey.ps1 index c8c9359..ab2f6c1 100644 --- a/src/chocolatey.ps1 +++ b/src/chocolatey.ps1 @@ -50,6 +50,7 @@ $nugetPath = (Split-Path -Parent $nugetChocolateyPath) $nugetExePath = Join-Path $nuGetPath 'bin' $nugetLibPath = Join-Path $nuGetPath 'lib' $badLibPath = Join-Path $nuGetPath 'lib-bad' +$runLibPath = Join-Path $nuGetPath 'lib-run' $extensionsPath = Join-Path $nugetPath 'extensions' $chocInstallVariableName = "ChocolateyInstall" $nugetExe = Join-Path $nugetChocolateyPath 'nuget.exe' diff --git a/src/functions/Chocolatey-NuGet.ps1 b/src/functions/Chocolatey-NuGet.ps1 index 1745f0f..e3acde0 100644 --- a/src/functions/Chocolatey-NuGet.ps1 +++ b/src/functions/Chocolatey-NuGet.ps1 @@ -22,7 +22,17 @@ param( $srcArgs = "(from $source)" } +$isRunPackage = $packageName.ToLower().EndsWith('.run'); Write-Host "Chocolatey (v$chocVer) is installing `'$packageName`' and dependencies. By installing you accept the license for `'$packageName`' and each dependency you are installing." -ForegroundColor $RunNote -BackgroundColor Black + +if($isRunPackage) { + $nugetInstallPath = Join-Path $nuGetPath 'lib-run' + Write-Host ".run Package detected. Will run package install script, and remove package afterwards." -ForegroundColor $Note -BackgroundColor Black +} +else { + $nugetInstallPath=$nugetLibPath; +} + Write-Debug "Installing packages to `"$nugetLibPath`"." $nugetOutput = (Run-NuGet $packageName $source $version).Split("`n") @@ -77,20 +87,31 @@ Write-Debug "Installing packages to `"$nugetLibPath`"." Write-Host "$installedPackageName v$installedPackageVersion" -ForegroundColor $Note -BackgroundColor Black if ([System.IO.Directory]::Exists($packageFolder)) { - try { - Delete-ExistingErrorLog $installedPackageName - Run-ChocolateyPS1 $packageFolder $installedPackageName "install" $installerArguments - Get-ChocolateyBins $packageFolder - if ($installedPackageName.ToLower().EndsWith('.extension')) { - Chocolatey-InstallExtension $packageFolder $installedPackageName + if($installedPackageName.ToLower().EndsWith('.run')) { + try { + Delete-ExistingErrorLog $installedPackageName + Run-ChocolateyPS1 $packageFolder $installedPackageName "install" $installerArguments + } catch { + Write-Error "Package `'$installedPackageName v$installedPackageVersion`' did not run successfully: $($_.Exception.Message)" + $chocolateyErrored = $true + } + Remove-Item $packageFolder -force -recurse + } + else { + try { + Delete-ExistingErrorLog $installedPackageName + Run-ChocolateyPS1 $packageFolder $installedPackageName "install" $installerArguments + Get-ChocolateyBins $packageFolder + if ($installedPackageName.ToLower().EndsWith('.extension')) { + Chocolatey-InstallExtension $packageFolder $installedPackageName + } + } catch { + Move-BadInstall $installedPackageName $installedPackageVersion $packageFolder + Write-Error "Package `'$installedPackageName v$installedPackageVersion`' did not install successfully: $($_.Exception.Message)" + if ($badPackages -ne '') { $badPackages += ', '} + $badPackages += "$packageName" + $chocolateyErrored = $true } - - } catch { - Move-BadInstall $installedPackageName $installedPackageVersion $packageFolder - Write-Error "Package `'$installedPackageName v$installedPackageVersion`' did not install successfully: $($_.Exception.Message)" - if ($badPackages -ne '') { $badPackages += ', '} - $badPackages += "$packageName" - $chocolateyErrored = $true } } } diff --git a/src/functions/Run-NuGet.ps1 b/src/functions/Run-NuGet.ps1 index dfc0ef3..861a013 100644 --- a/src/functions/Run-NuGet.ps1 +++ b/src/functions/Run-NuGet.ps1 @@ -2,14 +2,15 @@ param( [string] $packageName, [string] $source = '', - [string] $version = '' -) + [string] $version = '', + [string] $nugetInstallPath=$nugetLibPath) + Write-Debug "Running 'Run-NuGet' for $packageName with source: `'$source`', version:`'$version`'"; Write-Debug "___ NuGet ____" $srcArgs = Get-SourceArguments $source - $packageArgs = "install $packageName -OutputDirectory `"$nugetLibPath`" $srcArgs -NonInteractive -NoCache" + $packageArgs = "install $packageName -OutputDirectory `"$nugetInstallPath`" $srcArgs -NonInteractive -NoCache" if ($version -notlike '') { $packageArgs = $packageArgs + " -Version $version"; }