This has been driving me nuts. I can not get the android versions to auto increment.
Error:
Version code 10100000 has already been used. Try another version code.
Error:
Version code 10100000 has already been used. Try another version code.
XML:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Major>1</Major>
<Minor>1</Minor>
<Patch>0</Patch>
<TargetFrameworks>net8.0-maccatalyst;net8.0-android34.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">
$(TargetFrameworks);net8.0-windows10.0.19041.0
</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>InstantRepair</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ApplicationTitle>InstantRepair</ApplicationTitle>
<ApplicationId>com.companyname.instantrepair</ApplicationId>
<AssemblyVersion>$(Major).$(Minor).0.0</AssemblyVersion>
<SingleTFMBuild Condition="'$(IsCrossTargetingBuild)'!='true' and '$(TargetFramework)'!=''">true</SingleTFMBuild>
<Version>$(Major).$(Minor).$(Patch)</Version>
<ApplicationDisplayVersion>$(Version)</ApplicationDisplayVersion>
<ApplicationVersion>$([MSBuild]::Add($([MSBuild]::Add($([MSBuild]::Multiply($(Major),10000000)),$([MSBuild]::Multiply($(Minor),100000)))),$(Patch)))</ApplicationVersion>
<FileVersion>$(Version).0</FileVersion>
<InformationalVersion>$(Version)</InformationalVersion>
<WindowsPackageVersion>$(Major).$(Minor).$(Patch).0</WindowsPackageVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">23.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0-android34.0|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningStorePass>j**JS(*kN^&dDS%$6gkLI67cvcf</AndroidSigningStorePass>
<AndroidSigningKeyAlias>InstantRepair</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>j**JS(*kN^&dDS%$6gkLI67cvcf</AndroidSigningKeyPass>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0-android34.0|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningStorePass>j**JS(*kN^&dDS%$6gkLI67cvcf</AndroidSigningStorePass>
<AndroidSigningKeyAlias>InstantRepair</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>j**JS(*kN^&dDS%$6gkLI67cvcf</AndroidSigningKeyPass>
</PropertyGroup>
<ItemGroup>
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185" />
<MauiFont Include="Resources\Fonts\*" />
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<PackageReference Include="Plugin.MauiMTAdmob" Version="2.0.2" />
</ItemGroup>
<!-- Android-only pin to satisfy both Plugin.MauiMTAdmob and Ktx constraints -->
<ItemGroup Condition="'$(TargetFramework)'=='net8.0-android34.0'">
<PackageReference Include="Xamarin.AndroidX.Collection.Jvm" Version="1.5.0.1" />
<PackageReference Include="Xamarin.AndroidX.Collection.Ktx" Version="1.5.0.1" />
</ItemGroup>
<Target Name="EnsureBuildCounter"
BeforeTargets="ComputeVersion;GetTargetPath"
Condition="'$(DesignTimeBuild)'!='true'">
<ItemGroup Condition="!Exists('build-counter.txt')">
<_InitLine Include="0" />
</ItemGroup>
<WriteLinesToFile Condition="!Exists('build-counter.txt')"
File="build-counter.txt"
Lines="@(_InitLine)"
Overwrite="true" />
</Target>
<Target Name="ComputeVersion"
BeforeTargets="GetTargetPath;ResolveReferences;PrepareForBuild"
DependsOnTargets="EnsureBuildCounter"
Condition="'$(DesignTimeBuild)'!='true'">
<ReadLinesFromFile File="build-counter.txt">
<Output TaskParameter="Lines" ItemName="CounterLines" />
</ReadLinesFromFile>
<PropertyGroup>
<_CurrentPatch Condition="'@(CounterLines)'!=''">@(CounterLines)</_CurrentPatch>
<_CurrentPatch Condition="'@(CounterLines)'==''">0</_CurrentPatch>
</PropertyGroup>
<PropertyGroup>
<_ShouldIncrement>false</_ShouldIncrement>
<_IsOuterRelease Condition="'$(Configuration)'=='Release' and '$(RuntimeIdentifier)'=='' and ( '$(IsCrossTargetingBuild)'=='true' or '$(SingleTFMBuild)'=='true')">true</_IsOuterRelease>
<_ShouldIncrement Condition="'$(_IsOuterRelease)'=='true'">true</_ShouldIncrement>
<Patch Condition="'$(_ShouldIncrement)'=='true'">$([MSBuild]::Add($(_CurrentPatch),1))</Patch>
<Patch Condition="'$(_ShouldIncrement)'!='true'">$(_CurrentPatch)</Patch>
<Version>$(Major).$(Minor).$(Patch)</Version>
<ApplicationDisplayVersion>$(Version)</ApplicationDisplayVersion>
<ApplicationVersion>$([MSBuild]::Add($([MSBuild]::Add($([MSBuild]::Multiply($(Major),10000000)),$([MSBuild]::Multiply($(Minor),100000)))),$(Patch)))</ApplicationVersion>
<FileVersion>$(Version).0</FileVersion>
<InformationalVersion>$(Version)</InformationalVersion>
<WindowsPackageVersion>$(Major).$(Minor).$(Patch).0</WindowsPackageVersion>
</PropertyGroup>
<WriteLinesToFile Condition="'$(_ShouldIncrement)'=='true'"
File="build-counter.txt"
Lines="$(Patch)"
Overwrite="true" />
<Message Importance="High"
Text="ComputeVersion: Version=$(Version) versionCode=$(ApplicationVersion) Increment=$(_ShouldIncrement) Cfg=$(Configuration) TFM=$(TargetFramework) RID=$(RuntimeIdentifier)" />
</Target>
</Project>