Automatize deployment

Jun 13, 2012 at 7:19 AM

Hi all,

I'm using NetSparkle to autoupdate my applications.

After Setup file (msi) build in VS2010, I have to modify app cast file and put MSI file on the Web server manualy.

I'd like to automate these tasks (with PostBuildTask for example).

Does it already exist something for that?

Many thanks in advance for your help

Jun 16, 2012 at 8:02 PM

Hi,

I'm using powershell to automate and script everything. Perhaps this might help you.

 

# variable definitions
#$version = "0.9.7"
$guid = "{" + [guid]::NewGuid().ToString() + "}"


$msbuild = "C:\Windows\Microsoft.NET\Framework\v4.0.30319\MsBuild.exe"
$ScriptDir = Split-Path $MyInvocation.MyCommand.Path -Parent


#
#
# build anycpu version
#
#
& $msbuild "SolutionName.sln" "/target:Clean"
& $msbuild "SolutionName.sln" "/property:Configuration=Release;Platform=Any CPU"

$versionFile = $ScriptDir + '\SolutionName\bin\Release\SolutionName.exe'
$myAsm = [System.Reflection.Assembly]::LoadFile($versionFile)
$aName = $myAsm.GetName()
$version = $aName.version
Write-Host "Extracted version: " + $version
$wixanycpu = "/p:Version=" + $version + ";ProductGUID=" + $guid + ";Source=bin\Release"
$wixx86 = "/p:Version=" + $version + ";ProductGUID=" + $guid + ";Source=bin\x86\Release;Platform=x86"


& $msbuild ".\Setup\build_package.wixproj" $wixanycpu

# copy msi
$copyDest = $ScriptDir + '\Automatic Updates\x64\' + $version + '\'
$copySource = $ScriptDir + '\Setup\Into SolutionName.msi'
if (!(Test-Path -path $copyDest))
{
    New-Item $copyDest -type directory
} 
Copy-Item $copySource $copyDest

# adapt version info xml
$xmlDir = $ScriptDir + '\Automatic Updates\x64\' + '\'
$versionInfoXML = [xml](get-content ($xmlDir + "versioninfo.xml"))
$newElement = $versionInfoXML.CreateElement("item")
$titleElement = $versionInfoXML.CreateElement("title")
$titleElement.InnerText = "Version " + $version
$newElement.AppendChild($titleElement)
$releaseLinkElement = $versionInfoXML.CreateElement("releaseNotesLink","sparkle")
$releaseLinkElement.InnerText = "http://www.imissit.nl/intoSolutionName/relnotes/" + $version + ".html"
$newElement.AppendChild($releaseLinkElement)
$newDateElement = $versionInfoXML.CreateElement("pubDate")
$newDateElement.InnerText = Get-Date
$newElement.AppendChild($newDateElement)
$newEnclosureElement = $versionInfoXML.CreateElement("enclosure")
$newEnclosureElement.SetAttribute("url", "http://www.imissit.nl/intoSolutionName/x64/" + $version + "/Into SolutionName.msi")
$file = Get-Item $copySource
$newEnclosureElement.SetAttribute("length", $file.length)
$newEnclosureElement.SetAttribute("type", "application/octet-stream")
$newEnclosureElement.SetAttribute("version", "http://www.andymatuschak.org/xml-namespaces/sparkle", $version)
$signTarget = $copyDest + 'Into SolutionName.msi'
$dsa = & "D:\netsparkle\1.0.83\NetSparkleDSAHelper.exe" "/sign_update" $signTarget ".\NetSparkle_DSA.priv"
$newEnclosureElement.SetAttribute("dsaSignature", "http://www.andymatuschak.org/xml-namespaces/sparkle", $dsa)
$newElement.AppendChild($newEnclosureElement)
$versionInfoXML.rss.channel.AppendChild($newElement)
$versionInfoXML.OuterXml
$versionInfoXML.Save($xmlDir + "versioninfo.xml")





#
#
# build x86 version
#
#
& $msbuild "SolutionName.sln" "/target:Clean"
& $msbuild "SolutionName.sln" "/property:Configuration=Release;Platform=x86"
& $msbuild ".\Setup\build_package.wixproj" $wixx86

# copy msi
$copyDest86 = $ScriptDir + '\Automatic Updates\x86\' + $version + '\'
$copySource86 = $ScriptDir + '\Setup\Into SolutionName x86.msi'
if (!(Test-Path -path $copyDest86))
{
    New-Item $copyDest86 -type directory
} 
Copy-Item $copySource86 $copyDest86

# adapt version info xml
$xmlDir = $ScriptDir + '\Automatic Updates\x86\' + '\'
$versionInfoXML = [xml](get-content ($xmlDir + "versioninfo.xml"))
$newElement = $versionInfoXML.CreateElement("item")
$titleElement = $versionInfoXML.CreateElement("title")
$titleElement.InnerText = "Version " + $version
$newElement.AppendChild($titleElement)
$releaseLinkElement = $versionInfoXML.CreateElement("releaseNotesLink","sparkle")
$releaseLinkElement.InnerText = "http://www.imissit.nl/intoSolutionName/relnotes/" + $version + ".html"
$newElement.AppendChild($releaseLinkElement)
$newDateElement = $versionInfoXML.CreateElement("pubDate")
$newDateElement.InnerText = Get-Date
$newElement.AppendChild($newDateElement)
$newEnclosureElement = $versionInfoXML.CreateElement("enclosure")
$newEnclosureElement.SetAttribute("url", "http://www.imissit.nl/intoSolutionName/x86/" + $version + "/Into SolutionName x86.msi")
$file = Get-Item $copySource86
$newEnclosureElement.SetAttribute("length", $file.length)
$newEnclosureElement.SetAttribute("type", "application/octet-stream")
$newEnclosureElement.SetAttribute("version", "http://www.andymatuschak.org/xml-namespaces/sparkle", $version)
$signTarget = $copyDest86 + 'Into SolutionName x86.msi'
$dsa = & "D:\netsparkle\1.0.83\NetSparkleDSAHelper.exe" "/sign_update" $signTarget ".\NetSparkle_DSA.priv"
$newEnclosureElement.SetAttribute("dsaSignature", "http://www.andymatuschak.org/xml-namespaces/sparkle", $dsa)
$newElement.AppendChild($newEnclosureElement)
$versionInfoXML.rss.channel.AppendChild($newElement)
$versionInfoXML.OuterXml
$versionInfoXML.Save($xmlDir + "versioninfo.xml")

# sign msi's
Write-Output "Guid used: " $guid "`n"
Write-Output "AnyCPU bit DSA:"
$signTarget = $copyDest + 'Into SolutionName.msi'
& "D:\netsparkle\1.0.83\NetSparkleDSAHelper.exe" "/sign_update" $signTarget ".\NetSparkle_DSA.priv"
Write-Output `n`n`n
Write-Output "x86 DSA:"
$signTarget = $copyDest86 + 'Into SolutionName x86.msi'
& "D:\netsparkle\1.0.83\NetSparkleDSAHelper.exe" "/sign_update" $signTarget ".\NetSparkle_DSA.priv"