Created
April 11, 2013 19:05
-
-
Save Folcon/5366261 to your computer and use it in GitHub Desktop.
Modifications to Create-Release.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param ( | |
[Parameter(Position=0, ValueFromPipeLine=$true, Mandatory=$false)] | |
[string] $ProjectNameToBuild = '', | |
[Parameter(Mandatory=$false)] | |
[string] $SolutionDir, | |
[Parameter(Mandatory=$false)] | |
[string] $BuildDirectory | |
) | |
Set-PSDebug -Strict | |
$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Path | |
$createReleasePackageExe = Join-Path $toolsDir "CreateReleasePackage.exe" | |
$wixDir = Join-Path $toolsDir "wix" | |
$echoargs = Join-Path $wixDir "EchoArgs.exe" | |
$support = Join-Path $toolsDir "support.ps1" | |
. $support | |
function Get-ProjectBuildOutputDir { | |
param( | |
[parameter(Mandatory = $true)] | |
[string]$ProjectName | |
) | |
$projDir = Get-ProjectPropertyValue $ProjectName 'FullPath' | |
$proj = Get-Project $ProjectName | |
$buildSuffix = $proj.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value | |
Join-Path $projDir $buildSuffix | |
} | |
function Generate-TemplateFromPackage { | |
param( | |
[Parameter(Mandatory = $true)] | |
[string]$packageFile, | |
[Parameter(Mandatory = $true)] | |
[string]$templateFile | |
) | |
$resultFile = & $createReleasePackageExe --preprocess-template $templateFile $pkg.FullName | |
$resultFile | |
} | |
function Create-ReleaseForProject { | |
param( | |
[Parameter(Mandatory = $true)] | |
[string]$solutionDir, | |
[Parameter(Mandatory = $true)] | |
[string]$buildDirectory | |
) | |
$releaseDir = Join-Path $solutionDir "Releases" | |
if (!(Test-Path $releaseDir)) { mkdir -p $releaseDir } | |
echo "Creating Release for $solutionDir => $releaseDir`n" | |
#$nugetPackages = ls "$buildDirectory\*.nupkg" | ?{ $_.Name.EndsWith(".symbols.nupkg") -eq $false } | |
$nugetPackages = ls "*.nupkg" | ?{ $_.Name.EndsWith(".symbols.nupkg") -eq $false } | |
$test = ls "$buildDirectory\" | |
foreach($pkg in $nugetPackages) { | |
$packageDir = Join-Path $solutionDir "packages" | |
$fullRelease = & $createReleasePackageExe -o $releaseDir -p $packageDir $pkg.FullName 2> $null | |
echo "TestO: $createReleasePackageExe -o $releaseDir -p $packageDir $pkg`n" | |
## NB: For absolutely zero reason whatsoever, $fullRelease ends up being the full path Three times | |
#$fullRelease = $fullRelease.Split(" ")[0] | |
echo "FULL RELEASE: $fullRelease" | |
$fullRelease = $fullRelease[0].Split(" ")[0]+ " " +$fullRelease[0].Split(" ")[1] | |
echo "Full release file at $fullRelease" | |
$candleTemplate = Generate-TemplateFromPackage $pkg.FullName "$toolsDir\template.wxs" | |
$wixTemplate = Join-Path $buildDirectory "template.wxs" | |
$wixTemplateobj = Join-Path $buildDirectory "template.wixobj" | |
$dotnet40 = Join-Path $toolsDir "dotNetFx40_Full_x86_x64.exe" | |
rm $wixTemplate | |
mv $candleTemplate $wixTemplate | |
$pkgFullName = $pkg.FullName | |
$defines = " -d`"ToolsDir=$toolsDir`"" + " -d`"NuGetFullPackage=$fullRelease`"" | |
echo "Defines:: $defines`n" | |
$candleExe = Join-Path $wixDir "candle.exe" | |
$lightExe = Join-Path $wixDir "light.exe" | |
if (Test-Path $wixTemplateobj){ | |
rm $wixTemplateobj | |
} | |
echo "RUN:: $candleExe -dToolsDir=$toolsDir -dReleasesFile=$releaseDir\RELEASES -dNuGetFullPackage=$fullRelease -out $wixTemplateobj -arch x86 -ext $wixDir\WixBalExtension.dll -ext $wixDir\WixUtilExtension.dll $wixTemplate" | |
#& $candleExe "-dToolsDir=$toolsDir -dReleasesFile=$releaseDir\RELEASES -dNuGetFullPackage=$fullRelease -out $wixTemplateobj -arch x86 -ext $wixDir\WixBalExtension.dll -ext $wixDir\WixUtilExtension.dll $wixTemplate" | |
echo "Candle:: " "-dToolsDir=`'$toolsDir`' -dReleasesFile=`'$releaseDir\RELEASES`' -dNuGetFullPackage=$fullRelease " $wixTemplate | |
echo "-------------------" | |
cp $dotnet40 $buildDirectory | |
& $candleExe "-dToolsDir=$toolsDir", "-dReleasesFile=$releaseDir\RELEASES", "-dNuGetFullPackage=$fullRelease", -out $wixTemplateobj, -arch x86, -ext $wixDir\WixBalExtension.dll, -ext $wixDir\WixUtilExtension.dll, $wixTemplate | |
& $lightExe -out "$releaseDir\Setup.exe", -ext $wixDir\WixBalExtension.dll, -ext $wixDir\WixUtilExtension.dll, $wixTemplateobj | |
} | |
} | |
if (-not $ProjectNameToBuild) { | |
$ProjectNameToBuild = (Get-Project).Name | |
} | |
if (-not $SolutionDir) { | |
if (Test-Path variable:Dte) { | |
$SolutionDir = Get-SolutionDir | |
} else { | |
throw "Cannot determine the Solution directory - either run this script`n" + | |
"inside the NuGet Package Console, or specify a directory as a parameter" | |
} | |
} | |
if (Test-Path variable:Configuration) { | |
$BuildDirectory = "$SolutionDir\bin\$Configuration" | |
} | |
if (-not $BuildDirectory) { | |
if (Test-Path variable:Dte) { | |
$BuildDirectory = Get-ProjectBuildOutputDir $ProjectNameToBuild | |
} else { | |
throw "Cannot determine the Build directory - either run this script`n" + | |
"inside the NuGet Package Console, or specify a directory as a parameter" | |
} | |
} | |
### DEBUG: | |
#$createReleasePackageExe = [IO.Path]::Combine($toolsDir, '..', 'bin', 'Debug', 'CreateReleasePackage.exe') | |
#$wixDir = [IO.Path]::Combine($toolsDir, '..', '..', '..', 'ext', 'wix') | |
### End DEBUG | |
# nuget pack .\Project\Project.csproj -Version 1.0.1-alpha | |
# .nuget\NuGet pack .\Project\Project.csproj -Build -Properties Configuration=Release -Version 1.0.1-alpha | |
# Create-Release Project | |
$toolsDir = Split-Path -Parent $MyInvocation.MyCommand.Path | |
Create-ReleaseForProject $SolutionDir $BuildDirectory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment