Skip to content

Instantly share code, notes, and snippets.

@LanceMcCarthy
Last active May 2, 2023 23:53
Show Gist options
  • Save LanceMcCarthy/3dd493ba2302b314ba06bd63e714e721 to your computer and use it in GitHub Desktop.
Save LanceMcCarthy/3dd493ba2302b314ba06bd63e714e721 to your computer and use it in GitHub Desktop.
An example csproj that shows how to use conditionalsfor publishing settings
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>Hacked.Maui</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>Hacked?</ApplicationTitle>
<!-- App Identifier -->
<!-- moved ApplicationId to separate section below -->
<!-- moved ApplicationIdGuid to separate section below -->
<!-- Versions (if neccessary, you can also set the app version per-platform below) -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<!-- special asset and resource file build settings -->
<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.svg" BaseSize="168,208" />
<MauiFont Include="Resources\Fonts\*" />
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<!-- nuget packages -->
<ItemGroup>
<PackageReference Include="CommonHelpers" Version="1.2.0" />
<PackageReference Include="Telerik.UI.for.Maui" Version="5.1.0" />
</ItemGroup>
<!-- **************** SECTION: per-platform app identification settings **************** -->
<!-- Windows -->
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<ApplicationId>com.lancelotsoftware.HackedApp</ApplicationId>
<ApplicationIdGuid>61717AC6-F401-4830-BLAH-78DD35E085CC</ApplicationIdGuid>
</PropertyGroup>
<!-- MacCatalyst -->
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">
<ApplicationId>com.lancelotsoftware.HackedApp</ApplicationId>
<ApplicationIdGuid>61717AC6-F401-4830-BLAH-78DD35E085CC</ApplicationIdGuid>
</PropertyGroup>
<!-- iOS -->
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
<ApplicationId>com.lancelotsoftware.HackedApp</ApplicationId>
<ApplicationIdGuid>61717AC6-F401-4830-BLAH-78DD35E085CC</ApplicationIdGuid>
</PropertyGroup>
<!-- Android -->
<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">
<ApplicationId>com.lancelotsoftware.hacked</ApplicationId>
<ApplicationIdGuid>61717AC6-F401-4830-BLAH-78DD35E085CC</ApplicationIdGuid>
</PropertyGroup>
<!-- **************** SECTION: code signing and publishing **************** -->
<!-- ------- Android ------- -->
<!-- Release -->
<PropertyGroup Condition="$(TargetFramework.Contains('-android')) and '$(Configuration)' == 'Release'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyStore>your.keystore</AndroidSigningKeyStore>
<AndroidSigningStorePass>$(android_keystore_password)</AndroidSigningStorePass>
<AndroidSigningKeyAlias>your.alias</AndroidSigningKeyAlias>
<AndroidSigningKeyPass>$(android_keystore_alias_password)</AndroidSigningKeyPass>
</PropertyGroup>-->
<!-- or publish command with inline values
dotnet publish -f:net7.0-android -c:Release /p:AndroidKeyStore=True /p:AndroidSigningKeyStore=dvlup.keystore /p:AndroidSigningStorePass=$(android_keystore_password) /p:AndroidSigningKeyAlias=dvlup.alias /p:AndroidSigningKeyPass=mypassword=$(android_keystore_alias_password)
-->
<!-- ------- iOS ------- -->
<!-- Release -->
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
<CodesignKey>Apple Distribution: Lancelot Software, LLC (L65255N3F7)</CodesignKey>
for TestFlight
<CodesignProvision>HackedApp_AdHoc_2023.mobileprovision</CodesignProvision>
or for App Store
<CodesignProvision>HackedApp_AppStore_2023.mobileprovision</CodesignProvision>
</PropertyGroup>
<!-- Debug -->
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Debug'">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
<CodesignKey>Apple Development: Lance McCarthy (AJ9XMDH9A2)</CodesignKey>
<CodesignProvision>HackedApp_Dev_iOS_2022.mobileprovision</CodesignProvision>
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>
<!-- publish command
dotnet publish -f:net7.0-ios -c:Release /p:ServerAddress=192.168.1.184 /p:ServerUser=$MACOS_USER_NAME /p:ServerPassword=$MACOS_USER_PASSWORD /p:TcpPort=58181 /p:ArchiveOnBuild=true /p:_DotNetRootRemoteDirectory=/Users/mccarthy/Library/Caches/Xamarin/XMA/SDKs/dotnet/ /p:EnableAssemblyILStripping=false
-->
<!-- ------- MacCatalyst ------- -->
<!-- Release -->
<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifier>maccatalyst-x64</RuntimeIdentifier>
<CodesignKey>Apple Distribution: Lancelot Software, LLC (L65255N3F7)</CodesignKey>
<CodesignProvision>HackedApp_MacStore_2022.provisionprofile</CodesignProvision>
</PropertyGroup>
<!-- Debug -->
<PropertyGroup Condition="$(TargetFramework.Contains('-maccatalyst')) and '$(Configuration)' == 'Debug'">
<RuntimeIdentifier>maccatalyst-x64</RuntimeIdentifier>
<CodesignKey>Apple Development: Lance McCarthy (AJ9XMDH9A2)</CodesignKey>
<CodesignProvision>HackedApp_Dev_MacOS_2023.mobileprovision</CodesignProvision>
</PropertyGroup>
<!-- ------- Windows (WinUI) ------- -->
<!-- Release -->
<PropertyGroup Condition="$(TargetFramework.Contains('-windows')) and '$(Configuration)' == 'Release'">
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
<AppxPackageSigningEnabled>true</AppxPackageSigningEnabled>
<PackageCertificateThumbprint>$(PFX_THUMBPRINT)<PackageCertificateThumbprint/>
<PackageCertificatePassword>$(PFX_PASSWORD)<PackageCertificatePassword/>
<ANY_OTHER_PARAMETER>The cool thing is you can put whatever you'd use in the command line here, too!</ANY_OTHER_PARAMETER>
</PropertyGroup>
<!-- command This is just like packaging WinUI projects
msbuild /restore /t:Publish /p:TargetFramework=net7.0-windows10.0.19041 /p:configuration=release /p:GenerateAppxPackageOnBuild=true /p:AppxPackageSigningEnabled=true /p:PackageCertificateThumbprint=$PFX_THUMBPRINT /p:PackageCertificatePassword=$PFX_PASSWORD
-->
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment