Skip to content

Instantly share code, notes, and snippets.

@dwdii
Created April 28, 2012 02:45
Show Gist options
  • Save dwdii/2515232 to your computer and use it in GitHub Desktop.
Save dwdii/2515232 to your computer and use it in GitHub Desktop.
Mono Android Auto-Increment Manifest Version using PowerShell
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")
}
@dwdii
Copy link
Author

dwdii commented Apr 28, 2012

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}

@asjit
Copy link

asjit commented Mar 15, 2017

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