Red Gate forums :: View topic - Windows application, using Advanced Installer and FTP
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation

Deployment Manager PowerShell Scripts forum

Windows application, using Advanced Installer and FTP

Search in Deployment Manager PowerShell Scripts forum
Post new topic   Reply to topic
Jump to:  
Author Message
justin.caldicott



Joined: 20 Apr 2011
Posts: 55

PostPosted: Tue Jun 25, 2013 5:52 pm    Post subject: Windows application, using Advanced Installer and FTP Reply with quote

This script deploys an installer to a central location, via FTP, for download via a check for updates mechanism. In this case, I'm using the updates system that is part of the Advanced Installer tool. There's code here to build an updates INI file too, and include release notes from a text file.

It's being used for this Windows app: http://www.bluebirdtechnology.com/

My package has the installer, deploy.ps1 and ReleaseNotes.txt files together in the root.

In the application, I configure the update "channel" to point to the appropriate location on the website, eg. Downloads/Testing/MyApplicationSetup.exe.

Here's the deploy.ps1:
Code:

# Inputs:
#$RedGateReleaseNumber = "3.1.353.0"
#$RedGatePackageVersion = "3.1.353.0"
#$RedGateEnvironmentName = "Testing"

$ftpDownloadsUrl = "ftp://ftp.MyDomain.com/wwwroot/Downloads/MyProduct/" + $RedGateEnvironmentName
$ftpUserName = "MyUserName"
$ftpPassword = "MyPassword"
$httpDownloadsUrl = "http://www.MyDomain.com/Downloads/MyProduct/" + $RedGateEnvironmentName


Function FtpDelete ([System.Uri]$uri, [string]$username, [string]$password)
{
$ftp = [System.Net.FtpWebRequest]::Create($uri)
$ftp = [System.Net.FtpWebRequest]$ftp
$ftp.Method = [System.Net.WebRequestMethods+Ftp]::DeleteFile
$ftp.Credentials = new-object System.Net.NetworkCredential($username,$password)
$rs = $ftp.GetResponse()
$rs.Close()
$rs.Dispose()
}


Function FtpUpload ([System.Uri]$uri, [string]$username, [string]$password, [string]$filePath)
{
$ftp = [System.Net.FtpWebRequest]::Create($uri)
$ftp = [System.Net.FtpWebRequest]$ftp
$ftp.Method = [System.Net.WebRequestMethods+Ftp]::UploadFile
$ftp.Credentials = new-object System.Net.NetworkCredential($username,$password)
$ftp.UseBinary = $true
$ftp.UsePassive = $true
$content = [System.IO.File]::ReadAllBytes($filePath)
$ftp.ContentLength = $content.Length
$rs = $ftp.GetRequestStream()
$rs.Write($content, 0, $content.Length)
$rs.Close()
$rs.Dispose()
}


$myDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$updatesFileName = "MyApplicationUpdates.txt"
$updatesPath = $myDir + "\" + $updatesFileName
$installerFileName = "MyApplicationSetup.exe"
$installerPath = $myDir + "\" + $installerFileName


if (Test-Path $updatesPath) { Remove-Item $updatesPath }


$releaseNotesLines = [IO.File]::ReadAllLines("ReleaseNotes.txt")


$u = ";aiu;`n"
$u += "`n"
$u += "[My Application 3]`n"
$u += "Name=My Application $RedGateReleaseNumber`n"
$u += "ProductVersion=$RedGatePackageVersion`n"
$u += "UpdatedApplicationVersions=>=3`n"
$u += "URL=$httpDownloadsUrl/$installerFileName`n"
$u += "Size="+(Get-Item $installerPath).Length+"`n"
$u += "ServerFileName=$installerFileName`n"
$u += "Flags=NoCache`n"
$u += "FilePath=[APPDIR]MyApplication.exe`n"
$u += "Version=$RedGatePackageVersion`n"


$lineNumber = 0;
foreach($line in $releaseNotesLines){
    $descriptionNumber = ""
    if ($lineNumber -gt 0)
    {
        $descriptionNumber = $lineNumber
    }
    $u += "Description$descriptionNumber=$line`n"
    $lineNumber++
}
$u += "AutoCloseApplication=[APPDIR]MyApplication.exe`n"


$u | out-file $updatesPath -encoding ASCII


FtpUpload (new-object System.Uri "$ftpDownloadsUrl/$updatesFileName") $ftpUserName $ftpPassword $updatesPath
FtpUpload (new-object System.Uri "$ftpDownloadsUrl/$installerFileName") $ftpUserName $ftpPassword $installerPath


I hope this helps,

Justin
_________________
Justin Caldicott
Product Manager - Deployment Manager
Red Gate
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group