示例#1
0
 static void WriteApplePlist(Stream stream, AppleConfig config)
 {
     using (stream)
     {
         var plist = new NSDictionary();
         plist.Add("CFBundleDevelopmentRegion", "German");
         plist.Add("CFBundleExecutable", "MonoAppLauncher");
         plist.Add("CFBundleHelpBookFolder", $"{config.BundleName} Help");
         plist.Add("CFBundleHelpBookName", $"{config.BundleName} Help");
         plist.Add("CFBundleGetInfoString", $"{config.BundleName} {config.BundleVersion}");
         plist.Add("CFBundleIconFile", "app.icns");
         plist.Add("CFBundleIdentifier", config.BundleId);
         plist.Add("CFBundleInfoDictionaryVersion", "6.0");
         plist.Add("CFBundleName", config.BundleName);
         plist.Add("CFBundleShortVersionString", config.BundleVersion);
         var purl = new NSDictionary();
         purl.Add("CFBundleURLName", $"{config.BundleName} URL");
         var parray = new NSArray(new NSString(config.UrlPrefix));
         purl.Add("CFBundleURLSchemes", parray);
         var purls = new NSArray(purl);
         plist.Add("CFBundleURLTypes", purls);
         plist.Add("CFBundleVersion", config.BundleVersion);
         plist.Add("LSApplicationCategoryType", "public.app-category.business");
         plist.Add("LSMinimumSystemVersion", "10.7");
         var pMinVer = new NSDictionary();
         pMinVer.Add("i386", "10.7.0");
         pMinVer.Add("x86_64", "10.7.0");
         plist.Add("LSMinimumSystemVersionByArchitecture", pMinVer);
         plist.Add("NSHumanReadableCopyright", config.Copyright);
         PropertyListParser.SaveAsXml(plist, stream);
     }
 }
示例#2
0
        static void WriteAppleApp(AppleConfig config, string dir)
        {
            var appFolder = Path.Combine(config.AppTemp, $"{config.BundleName}.app");

            Directory.CreateDirectory(appFolder);
            ExtractGzip(config.AppTemp, dir);
            var volicon = Path.Combine(config.AppTemp, ".VolumeIcon.icns");

            File.Copy(config.AppIcon, volicon, true);
            var background = Path.Combine(config.AppTemp, ".background", "installer_background.jpg");

            Directory.CreateDirectory(Path.GetDirectoryName(background));
            File.Copy(config.Background, background, true);
            var contentsFolder = Path.Combine(appFolder, "Contents");

            Directory.CreateDirectory(contentsFolder);
            var infoPlist = Path.Combine(contentsFolder, "Info.plist");

            using (var file = File.Create(infoPlist))
                WriteApplePlist(file, config);
            var macOsFolder = Path.Combine(contentsFolder, "MacOS");

            Directory.CreateDirectory(macOsFolder);
            var shellFile  = Path.Combine(macOsFolder, "MonoAppLauncher");
            var shellLines = new List <string>
            {
                "#!/bin/sh",
                "open ~"
            };
            var shellTxt = string.Join('\n' + "", shellLines).Trim();
            var noBom    = new UTF8Encoding(false);

            File.WriteAllText(shellFile, shellTxt, noBom);
            var resFolder = Path.Combine(contentsFolder, "Resources");

            Directory.CreateDirectory(resFolder);
            var iconFile = Path.Combine(resFolder, "app.icns");

            File.Copy(config.AppIcon, iconFile, true);
            var realRoot = Path.Combine(contentsFolder, "Mono");

            Directory.CreateDirectory(realRoot);
            IOHelper.CloneDirectory(config.BuildDirectory, realRoot);
        }