Пример #1
0
        public override bool Execute()
        {
            PDictionary plist = null;

            if (!string.IsNullOrEmpty(AppManifest?.ItemSpec))
            {
                try {
                    plist = PDictionary.FromFile(AppManifest.ItemSpec);
                } catch (Exception ex) {
                    Log.LogError(null, null, null, AppManifest, 0, 0, 0, 0, MSBStrings.E0010, AppManifest, ex.Message);
                    return(false);
                }
            }

            var minimumOSVersionInManifest = plist?.Get <PString> (PlatformFrameworkHelper.GetMinimumOSVersionKey(Platform))?.Value;

            if (string.IsNullOrEmpty(minimumOSVersionInManifest))
            {
                MinimumOSVersion = SdkVersion;
            }
            else if (!IAppleSdkVersion_Extensions.TryParse(minimumOSVersionInManifest, out var _))
            {
                Log.LogError(null, null, null, AppManifest, 0, 0, 0, 0, MSBStrings.E0011, minimumOSVersionInManifest);
                return(false);
            }
            else
            {
                MinimumOSVersion = minimumOSVersionInManifest;
            }

            return(true);
        }
Пример #2
0
        public override bool Execute()
        {
            PDictionary plist = null;

            if (!string.IsNullOrEmpty(AppManifest?.ItemSpec))
            {
                try {
                    plist = PDictionary.FromFile(AppManifest.ItemSpec);
                } catch (Exception ex) {
                    Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, MSBStrings.E0010, AppManifest.ItemSpec, ex.Message);
                    return(false);
                }
            }

            var minimumOSVersionInManifest = plist?.Get <PString> (PlatformFrameworkHelper.GetMinimumOSVersionKey(Platform))?.Value;

            if (string.IsNullOrEmpty(minimumOSVersionInManifest))
            {
                MinimumOSVersion = SdkVersion;
            }
            else if (!IAppleSdkVersion_Extensions.TryParse(minimumOSVersionInManifest, out var _))
            {
                Log.LogError(null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, MSBStrings.E0011, minimumOSVersionInManifest);
                return(false);
            }
            else
            {
                MinimumOSVersion = minimumOSVersionInManifest;
            }

            if (Platform == ApplePlatform.MacCatalyst)
            {
                // Convert the min macOS version to the min iOS version, which the rest of our tooling expects.
                if (!MacCatalystSupport.TryGetiOSVersion(Sdks.GetAppleSdk(Platform).GetSdkPath(SdkVersion, false), MinimumOSVersion, out var convertedVersion))
                {
                    Log.LogError(MSBStrings.E0187, MinimumOSVersion);
                }
                MinimumOSVersion = convertedVersion;
            }

            return(true);
        }
        bool SetMinimumOSVersion(PDictionary plist)
        {
            var    minimumVersionKey          = PlatformFrameworkHelper.GetMinimumOSVersionKey(Platform);
            var    minimumOSVersionInManifest = plist?.Get <PString> (minimumVersionKey)?.Value;
            string convertedSupportedOSPlatformVersion;
            string minimumOSVersion;

            if (Platform == ApplePlatform.MacCatalyst && !string.IsNullOrEmpty(SupportedOSPlatformVersion))
            {
                // SupportedOSPlatformVersion is the iOS version for Mac Catalyst.
                // But we need to store the macOS version in the app manifest, so convert it to the macOS version here.
                if (!MacCatalystSupport.TryGetMacOSVersion(Sdks.GetAppleSdk(Platform).GetSdkPath(SdkVersion, false), SupportedOSPlatformVersion, out var convertedVersion, out var knowniOSVersions))
                {
                    Log.LogError(MSBStrings.E0188, SupportedOSPlatformVersion, string.Join(", ", knowniOSVersions));
                }
                convertedSupportedOSPlatformVersion = convertedVersion;
            }
            else
            {
                convertedSupportedOSPlatformVersion = SupportedOSPlatformVersion;
            }

            if (Platform == ApplePlatform.MacCatalyst && string.IsNullOrEmpty(minimumOSVersionInManifest))
            {
                // If there was no value for the macOS min version key, then check the iOS min version key.
                var minimumiOSVersionInManifest = plist?.Get <PString> (ManifestKeys.MinimumOSVersion)?.Value;
                if (!string.IsNullOrEmpty(minimumiOSVersionInManifest))
                {
                    // Convert to the macOS version
                    if (!MacCatalystSupport.TryGetMacOSVersion(Sdks.GetAppleSdk(Platform).GetSdkPath(SdkVersion, false), minimumiOSVersionInManifest, out var convertedVersion, out var knowniOSVersions))
                    {
                        Log.LogError(MSBStrings.E0188, minimumiOSVersionInManifest, string.Join(", ", knowniOSVersions));
                    }
                    minimumOSVersionInManifest = convertedVersion;
                }
            }

            if (string.IsNullOrEmpty(minimumOSVersionInManifest))
            {
                // Nothing is specified in the Info.plist - use SupportedOSPlatformVersion, and if that's not set, then use the sdkVersion
                if (!string.IsNullOrEmpty(convertedSupportedOSPlatformVersion))
                {
                    minimumOSVersion = convertedSupportedOSPlatformVersion;
                }
                else
                {
                    minimumOSVersion = SdkVersion;
                }
            }
            else if (!IAppleSdkVersion_Extensions.TryParse(minimumOSVersionInManifest, out var _))
            {
                LogAppManifestError(MSBStrings.E0011, minimumOSVersionInManifest);
                return(false);
            }
            else if (!string.IsNullOrEmpty(convertedSupportedOSPlatformVersion) && convertedSupportedOSPlatformVersion != minimumOSVersionInManifest)
            {
                // SupportedOSPlatformVersion and the value in the Info.plist are not the same. This is an error.
                LogAppManifestError(MSBStrings.E7082, minimumVersionKey, minimumOSVersionInManifest, SupportedOSPlatformVersion);
                return(false);
            }
            else
            {
                minimumOSVersion = minimumOSVersionInManifest;
            }

            // Write out our value
            plist [minimumVersionKey] = minimumOSVersion;

            return(true);
        }