private static void UpgradeMauiAndroid(IProjectPropertyElements projectproperties, IProjectFile file) { // confirm final mappings https://github.com/xamarin/xamarin-android/blob/main/Documentation/guides/OneDotNet.md#changes-to-msbuild-properties // remove uneeded properties projectproperties.RemoveProjectProperty("AndroidApplication"); projectproperties.RemoveProjectProperty("AndroidResgenFile"); projectproperties.RemoveProjectProperty("AndroidResgenClass"); projectproperties.RemoveProjectProperty("MonoAndroidAssetsPrefix"); projectproperties.RemoveProjectProperty("MonoAndroidAssetsPrefix"); projectproperties.RemoveProjectProperty("AndroidUseLatestPlatformSdk"); projectproperties.RemoveProjectProperty("AndroidEnableSGenConcurrent"); projectproperties.RemoveProjectProperty("AndroidHttpClientHandlerType"); projectproperties.RemoveProjectProperty("AndroidManagedSymbols"); projectproperties.RemoveProjectProperty("AndroidUseSharedRuntime"); projectproperties.RemoveProjectProperty("MonoAndroidResourcePrefix"); projectproperties.RemoveProjectProperty("AndroidUseAapt2"); projectproperties.RemoveProjectProperty("AndroidSupportedAbis"); file.SetPropertyValue("RuntimeIdentifiers", "android-arm;android-arm64;android-x86;android-x64"); var androidLinkMode = projectproperties.GetProjectPropertyValue("AndroidLinkMode"); foreach (var linkMode in androidLinkMode) { projectproperties.RemoveProjectProperty("AndroidLinkMode"); if (string.Equals(linkMode, "SdkOnly", StringComparison.Ordinal) || string.Equals(linkMode, "Full", StringComparison.Ordinal)) { file.SetPropertyValue("PublishTrimmed", "true"); file.SetPropertyValue("TrimMode", "link"); } } }
public static void RuntimePropertyMapper(IProjectPropertyElements projectproperties, IProjectFile file, string oldRumtimePropertyName) { // following conversion mapping here : https://github.com/xamarin/xamarin-macios/wiki/Project-file-properties-dotnet-migration var runtimeMapping = new Dictionary <string, string>() { { "x86_64", "iossimulator-x64;" }, { "i386", "iossimulator-x86;" }, { "ARM64", "ios-arm64;" }, { "x86_64+i386", "iossimulator-x86;iossimulator-x64;" }, { "ARMv7+ARM64+i386", "ios-arm;ios-arm64;" }, }; var runtimeprops = projectproperties.GetProjectPropertyValue(oldRumtimePropertyName).Distinct(); var runtimeIdentifierString = string.Empty; foreach (var prop in runtimeprops) { runtimeIdentifierString += runtimeMapping[prop]; } // remove old properties before adding new projectproperties.RemoveProjectProperty(oldRumtimePropertyName); if (runtimeIdentifierString.Count(x => x.Equals(';')) > 1) { file.SetPropertyValue("RuntimeIdentifiers", runtimeIdentifierString); } else { file.SetPropertyValue("RuntimeIdentifier", runtimeIdentifierString); } }
public static void TransformProperty(IProjectPropertyElements projectproperties, IProjectFile file, string oldpropertyName, string newPropertyName, string oldPropertyValue = "", string newPropertyValue = "") { var currentPropertyValue = projectproperties.GetProjectPropertyValue(oldpropertyName).FirstOrDefault(); if (!string.IsNullOrEmpty(currentPropertyValue)) { projectproperties.RemoveProjectProperty(oldpropertyName); if (string.Equals(currentPropertyValue, oldPropertyValue, StringComparison.OrdinalIgnoreCase)) { file.SetPropertyValue(newPropertyName, newPropertyValue); } if (string.IsNullOrEmpty(newPropertyValue)) { file.SetPropertyValue(newPropertyName, currentPropertyValue); } else { file.SetPropertyValue(newPropertyName, newPropertyValue); } } }