Last active
January 25, 2019 12:02
-
-
Save JannieT/0b9ff27fe7f90dbb2edf3333db701206 to your computer and use it in GitHub Desktop.
Xamarin Multiplatform App Version Synchronization
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
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<UsingTask TaskName="Increment" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> | |
<ParameterGroup> | |
<Number ParameterType="System.Int64" Required="true"/> | |
<Incremented ParameterType="System.Int64" Output="true"/> | |
</ParameterGroup> | |
<Task> | |
<Code Type="Fragment" Language="cs"> | |
Incremented = Number + 1; | |
</Code> | |
</Task> | |
</UsingTask> | |
<Target Name="BeforeBuild" Condition=" '$(Configuration)' == 'Release' " > | |
<PropertyGroup> | |
<QueryNamespace><Namespace Prefix='android' Uri='http://schemas.android.com/apk/res/android' /></QueryNamespace> | |
</PropertyGroup> | |
<XmlPeek XmlInputPath="$(AndroidManifest)" Namespaces="$(QueryNamespace)" Query="manifest/@android:versionCode" > | |
<Output TaskParameter="Result" ItemName="VersionCode" /> | |
</XmlPeek> | |
<Increment Number="@(VersionCode)"> | |
<Output ItemName="NewVersionCode" TaskParameter="Incremented"/> | |
</Increment> | |
<XmlPoke XmlInputPath="$(AndroidManifest)" Namespaces="$(QueryNamespace)" Query="manifest/@android:versionCode" Value="@(NewVersionCode)" /> | |
<XmlPoke XmlInputPath="$(AndroidManifest)" Namespaces="$(QueryNamespace)" Query="manifest/@android:versionName" Value="$(ReleaseVersion)" /> | |
</Target> | |
</Project> |
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
<?xml version="1.0" encoding="utf-8"?> | |
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<UsingTask TaskName="Increment" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll"> | |
<ParameterGroup> | |
<Number ParameterType="System.String" Required="true" /> | |
<Incremented ParameterType="System.String" Output="true" /> | |
</ParameterGroup> | |
<Task> | |
<Code Type="Fragment" Language="cs"> | |
Incremented = $"{Number.Split('.')[0]}.{Number.Split('.')[1]}."+DateTime.Now.DayOfYear.ToString()+DateTime.Now.Hour.ToString(); | |
</Code> | |
</Task> | |
</UsingTask> | |
<Target Name="BeforeBuild" Condition=" '$(Configuration)' == 'Release' "> | |
<PropertyGroup> | |
<InfoList>Info.plist</InfoList> | |
<VersionQuery>//dict/key[. = 'CFBundleVersion']/following-sibling::string[1]</VersionQuery> | |
</PropertyGroup> | |
<Increment Number="$(ReleaseVersion)"> | |
<Output ItemName="NewVersionCode" TaskParameter="Incremented" /> | |
</Increment> | |
<XmlPoke XmlInputPath="$(InfoList)" Query="$(VersionQuery)" Value="@(NewVersionCode)" /> | |
<XmlPoke XmlInputPath="$(InfoList)" Query="//dict/key[. = 'CFBundleShortVersionString']/following-sibling::string[1]" Value="$(ReleaseVersion)" /> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment