I developed for fun a couple a WP7 apps and I needed to automate (just a little bit:-) the release process, mainly because:
The easiest way I found to do this is via PowerShell. I wrote a super simple script that:
The directory structure I used (in my project – LED) is the following
I think that this approach can be used/extended in many other scenarios similar to this one.
Good luck
$version = "1.02.00.00" $SolutionPath = "D:\MyProjects2010\WP7\PRO\LED\" $Solution = $SolutionPath + "LED.sln" $SolutionBin = $SolutionPath + "NicolD.Phone.App.LED\Bin\" $LogFile = $SolutionBin + "Build.log" $VStudio2010= "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" $releases = $SolutionPath + "Releases\" $build = $SolutionBin + "Release\NicolD.Phone.App.LED.xap" $buildArchive = $releases + "NicolD.Phone.App.LED-" + $version + ".xap" function replace { $o = $args[0] $a = $args[1] $b = $args[2] (Get-Content $o) | Foreach-Object {$_ -replace $a, $b} | Set-Content $o } $AssemblyInfo = $SolutionPath + "NicolD.Phone.App.LED\Properties\AssemblyInfo.cs" $filter = 'AssemblyVersion\("\d+.\d+.\d+.\d+"\)' $newstring = 'AssemblyVersion("' + $version + '")' replace $AssemblyInfo $filter $newstring $filter = 'AssemblyFileVersion\("\d+.\d+.\d+.\d+"\)' $newstring = 'AssemblyFileVersion("' + $version + '")' replace $AssemblyInfo $filter $newstring $manifest = $SolutionPath + "NicolD.Phone.App.LED\Properties\WMAppManifest.xml" $filter = 'Version="\d+.\d+.\d+.\d+"' $newstring = 'Version="' + $version + '"' replace $manifest $filter $newstring $appinfo = $SolutionPath + "NicolD.Phone.App.LED\Model\ApplicationInfo.cs" $filter = 'ApplicationVersion = "\d+.\d+.\d+.\d+"' $newstring = 'ApplicationVersion = "' + $version + '"' replace $appinfo $filter $newstring & $VStudio2010 $Solution /clean | Out-Null & $VStudio2010 $Solution /rebuild release /out $logfile | Out-Null copy $build $buildarchive
$version = "1.02.00.00"
$SolutionPath = "D:\MyProjects2010\WP7\PRO\LED\"
$Solution = $SolutionPath + "LED.sln"
$SolutionBin = $SolutionPath + "NicolD.Phone.App.LED\Bin\"
$LogFile = $SolutionBin + "Build.log"
$VStudio2010= "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"
$releases = $SolutionPath + "Releases\"
$build = $SolutionBin + "Release\NicolD.Phone.App.LED.xap"
$buildArchive = $releases + "NicolD.Phone.App.LED-" + $version + ".xap"
function replace
{
$o = $args[0]
$a = $args[1]
$b = $args[2]
(Get-Content $o) |
Foreach-Object {$_ -replace $a, $b} |
Set-Content $o
}
$AssemblyInfo = $SolutionPath + "NicolD.Phone.App.LED\Properties\AssemblyInfo.cs"
$filter = 'AssemblyVersion\("\d+.\d+.\d+.\d+"\)'
$newstring = 'AssemblyVersion("' + $version + '")'
replace $AssemblyInfo $filter $newstring
$filter = 'AssemblyFileVersion\("\d+.\d+.\d+.\d+"\)'
$newstring = 'AssemblyFileVersion("' + $version + '")'
$manifest = $SolutionPath + "NicolD.Phone.App.LED\Properties\WMAppManifest.xml"
$filter = 'Version="\d+.\d+.\d+.\d+"'
$newstring = 'Version="' + $version + '"'
replace $manifest $filter $newstring
$appinfo = $SolutionPath + "NicolD.Phone.App.LED\Model\ApplicationInfo.cs"
$filter = 'ApplicationVersion = "\d+.\d+.\d+.\d+"'
$newstring = 'ApplicationVersion = "' + $version + '"'
replace $appinfo $filter $newstring
& $VStudio2010 $Solution /clean | Out-Null
& $VStudio2010 $Solution /rebuild release /out $logfile | Out-Null
copy $build $buildarchive