0

when building an APK using MSBuild I would like to change the output apk name to include the version number

so

android:versionName="3.1.5"

would end up like:

MyAndroidApp-3.1.5.apk

i tried to do a post-build step where i try to copy the apk to a different name , but there aren't any macros in the post build step that has the version (that i can see)

When calling

MSBuild .\trunk\TaxiTabletUniversal.Droid.MyAndroidProject /t:SignAndroidPackage  /p:Configuration=Release 

the output apk ends up with the name:

company_name.mypackage_name-Signed.apk

In the Android Package Signing setting i can only specify the keystore and paswords, but no output name.

I would like the output name to pickup the versionName in the

AndroidManifest.xml

file

clogwog
  • 343
  • 2
  • 13

1 Answers1

1

Changing default APK output to include version in the name using MSBuild

Sorry but the answer could be negative, as I know MSBuild itself doesn't have the ability to read data like Version-number from AndroidManifest.xml. In other words, it's not supported by msbuild.

MSBuild can access any property defined in project file or imported targets file, but it can't access AndroidManifest.xml file. And there's no official msbuild task can to this for us, so if you do need this behavior, we have to code ourselves to read the version info from that xml file. Topics about this: one, two, three...(Too many topics online talk about this, so I don't talk too much here, if you meet some issue about coding that, let me know:- ))

Here're two possible ways after that coding:

1.Create a .exe file with code to execute the renaming job, and call the .exe in a post-build event

2.Write a custom task named CustomTask, and add this script into the project file to call this task after build or SignAndroidPackage target.

  <UsingTask TaskName="CustomTask.CustomTask"
        AssemblyFile="path\CustomTask.dll"/>

  <!--Maybe it should be AfterTargets="SignAndroidPackage"-->
  <Target Name="CustomTarget" AfterTargets="Build">
    <CustomTask/>
  </Target>

May it makes some help.

LoLance
  • 25,666
  • 1
  • 39
  • 73