Esempio n. 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);
        }
Esempio n. 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);
        }
        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);
                }
            }

            CFBundleExecutable   = plist.GetCFBundleExecutable();
            CFBundleDisplayName  = plist?.GetCFBundleDisplayName();
            CFBundleIdentifier   = plist?.GetCFBundleIdentifier();
            CFBundleVersion      = plist?.GetCFBundleVersion();
            CLKComplicationGroup = plist?.Get <PString> (ManifestKeys.CLKComplicationGroup)?.Value;

            MinimumOSVersion = plist?.Get <PString> (PlatformFrameworkHelper.GetMinimumOSVersionKey(Platform))?.Value;
            if (Platform == ApplePlatform.MacCatalyst)
            {
                // The minimum version in the Info.plist is the macOS version. However, the rest of our tooling
                // expects the iOS version, so expose that.
                if (!MacCatalystSupport.TryGetiOSVersion(Sdks.GetAppleSdk(Platform).GetSdkPath(SdkVersion, false), MinimumOSVersion !, out var convertedVersion, out var knownMacOSVersions))
                {
                    Log.LogError(MSBStrings.E0187, MinimumOSVersion, string.Join(", ", knownMacOSVersions));
                }
                MinimumOSVersion = convertedVersion;
            }

            NSExtensionPointIdentifier = plist?.GetNSExtensionPointIdentifier();
            UIDeviceFamily             = plist?.GetUIDeviceFamily().ToString();
            WKWatchKitApp       = plist?.GetWKWatchKitApp() == true;
            XSAppIconAssets     = plist?.Get <PString> (ManifestKeys.XSAppIconAssets)?.Value;
            XSLaunchImageAssets = plist?.Get <PString> (ManifestKeys.XSLaunchImageAssets)?.Value;

            return(!Log.HasLoggedErrors);
        }
        public override bool Execute()
        {
            PDictionary plist;

            try {
                plist = PDictionary.FromFile(AppManifest);
            } catch (Exception ex) {
                LogAppManifestError(MSBStrings.E0010, AppManifest, ex.Message);
                return(false);
            }

            plist.SetIfNotPresent(PlatformFrameworkHelper.GetMinimumOSVersionKey(Platform), MinimumOSVersion);

            if (!string.IsNullOrEmpty(TargetArchitectures) && !Enum.TryParse(TargetArchitectures, out architectures))
            {
                LogAppManifestError(MSBStrings.E0012, TargetArchitectures);
                return(false);
            }

            plist.SetIfNotPresent(ManifestKeys.CFBundleIdentifier, BundleIdentifier);
            plist.SetIfNotPresent(ManifestKeys.CFBundleInfoDictionaryVersion, "6.0");
            plist.SetIfNotPresent(ManifestKeys.CFBundlePackageType, IsAppExtension ? "XPC!" : "APPL");
            plist.SetIfNotPresent(ManifestKeys.CFBundleSignature, "????");
            plist.SetIfNotPresent(ManifestKeys.CFBundleVersion, "1.0");
            plist.SetIfNotPresent(ManifestKeys.CFBundleExecutable, AssemblyName);

            if (!Compile(plist))
            {
                return(false);
            }

            // Merge with any partial plists generated by the Asset Catalog compiler...
            MergePartialPlistTemplates(plist);

            CompiledAppManifest = new TaskItem(Path.Combine(AppManifestBundleDirectory, "Info.plist"));
            plist.Save(CompiledAppManifest.ItemSpec, true, true);

            return(!Log.HasLoggedErrors);
        }
        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);
        }
Esempio n. 6
0
        public override bool Execute()
        {
            PDictionary plist;

            try {
                plist = PDictionary.FromFile(AppManifest);
            } catch (Exception ex) {
                LogAppManifestError(MSBStrings.E0010, AppManifest, ex.Message);
                return(false);
            }

            plist.SetIfNotPresent(PlatformFrameworkHelper.GetMinimumOSVersionKey(Platform), MinimumOSVersion);

            if (!string.IsNullOrEmpty(TargetArchitectures) && !Enum.TryParse(TargetArchitectures, out architectures))
            {
                LogAppManifestError(MSBStrings.E0012, TargetArchitectures);
                return(false);
            }

            plist.SetCFBundleIdentifier(BundleIdentifier);              // no ifs and buts, we've computed the final bundle identifier (BundleIdentifier) in DetectSigningIdentityTask.
            plist.SetIfNotPresent(ManifestKeys.CFBundleInfoDictionaryVersion, "6.0");
            plist.SetIfNotPresent(ManifestKeys.CFBundlePackageType, IsAppExtension ? "XPC!" : "APPL");
            plist.SetIfNotPresent(ManifestKeys.CFBundleSignature, "????");
            plist.SetIfNotPresent(ManifestKeys.CFBundleExecutable, AssemblyName);
            plist.SetIfNotPresent(ManifestKeys.CFBundleName, AppBundleName);

            if (GenerateApplicationManifest && !string.IsNullOrEmpty(ApplicationTitle))
            {
                plist.SetIfNotPresent(ManifestKeys.CFBundleDisplayName, ApplicationTitle);
            }

            string defaultBundleVersion = "1.0";

            if (GenerateApplicationManifest && !string.IsNullOrEmpty(ApplicationVersion))
            {
                defaultBundleVersion = ApplicationVersion;
            }
            plist.SetIfNotPresent(ManifestKeys.CFBundleVersion, defaultBundleVersion);

            string defaultBundleShortVersion = null;

            if (GenerateApplicationManifest)
            {
                if (!string.IsNullOrEmpty(AppleShortVersion))
                {
                    defaultBundleShortVersion = AppleShortVersion;
                }
                else if (!string.IsNullOrEmpty(ApplicationVersion))
                {
                    defaultBundleShortVersion = ApplicationVersion;
                }
            }
            if (string.IsNullOrEmpty(defaultBundleShortVersion))
            {
                defaultBundleShortVersion = plist.GetCFBundleVersion();
            }
            plist.SetIfNotPresent(ManifestKeys.CFBundleShortVersionString, defaultBundleShortVersion);

            if (!Compile(plist))
            {
                return(false);
            }

            // Merge with any partial plists generated by the Asset Catalog compiler...
            MergePartialPlistTemplates(plist);

            CompiledAppManifest = new TaskItem(Path.Combine(AppManifestBundleDirectory, "Info.plist"));
            plist.Save(CompiledAppManifest.ItemSpec, true, true);

            return(!Log.HasLoggedErrors);
        }