Created
April 28, 2012 02:45
-
-
Save dwdii/2515232 to your computer and use it in GitHub Desktop.
Mono Android Auto-Increment Manifest Version using PowerShell
This file contains 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
param | |
( | |
[string] $ProjectPath = "C:\SourceCode\TestApps\AndroidTestIt\AndroidTestIt" | |
) | |
process | |
{ | |
# Load the bootstrap file | |
[xml] $xam = Get-Content -Path ($ProjectPath + "\Properties\AndroidManifest.xml") | |
# Get the version from Android Manifest | |
$version = Select-Xml -xml $xam -Xpath "/manifest/@android:versionName" -namespace @{android="http://schemas.android.com/apk/res/android"} | |
# Increment the version | |
[double] $iVer = $version.Node.Value | |
$version.Node.Value = ($iVer + 0.001) | |
# Save the file | |
$xam.Save($ProjectPath + "\Properties\AndroidManifest.xml") | |
} | |
Round brackets for $(ProjectDir) - threw me for a while - but thanks for this useful post :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simply put the PreBuildEvt_IncAndroidManifestVersion.ps1 file in your project directory. Then go to Project Options > Custom Command, and create a Before Build event with the following properties:
Command: powershell.exe -File "PreBuildEvt_IncAndroidManifestVersion.ps1" ${ProjectDir}
Working Directory: ${ProjectDir}