private void DoGenerate() { string headerTemplate, footerTemplate, rowTemplate, rowSeparatorTemplate; SplitTemplate(out headerTemplate, out footerTemplate, out rowTemplate, out rowSeparatorTemplate); string commonDirName = InfoList.Count > 1 ? "common" : "content"; string commonDirPath = Path.Combine(m_OutputDir, commonDirName); Directory.CreateDirectory(commonDirPath); string buttonPath = Path.Combine(commonDirName, "button.png"); Resources.Button.Save(Path.Combine(m_OutputDir, buttonPath)); string imageokPath = Path.Combine(commonDirName, "imageok.png"); string imagefailPath = Path.Combine(commonDirName, "imagefail.png"); if (IsUUIDServiceEnabled()) { Resources.imageok.Save(Path.Combine(m_OutputDir, imageokPath)); Resources.imagefail.Save(Path.Combine(m_OutputDir, imagefailPath)); // Where should I place the htacccess file? //string htaaccessPath = Path.Combine(commonDirName, ".htaccess"); string htaaccessPath = ".htaccess"; File.WriteAllText(Path.Combine(m_OutputDir, htaaccessPath), Resources.htaccess); } Dictionary <string, string> commonDictionary = new Dictionary <string, string>(); commonDictionary.Add("[[BUTTON-URL]]", GetAbsoluteUrl(buttonPath)); commonDictionary.Add("[[BUNDLE-DISPLAY-NAME]]", "Ad-Hoc Installers"); string installPath = "Install.html"; StringBuilder installer = new StringBuilder(); installer.Append(ReplaceTokens(headerTemplate, commonDictionary)); foreach (var info in InfoList) { if (InfoList.IndexOf(info) > 0) { installer.Append(ReplaceTokens(rowSeparatorTemplate, commonDictionary)); } Dictionary <string, string> dictionary = new Dictionary <string, string>(commonDictionary); string ipaName = Path.GetFileNameWithoutExtension(info.BundlePath); string ipaFileName = Path.GetFileName(info.BundlePath); string infoFileName = ipaName + ".plist"; string contentDirName = "content" + (InfoList.Count > 1 ? "_" + InfoList.IndexOf(info) : ""); string contentDirPath = Path.Combine(m_OutputDir, contentDirName); Directory.CreateDirectory(m_OutputDir); Directory.CreateDirectory(contentDirPath); string icon57Path = Path.Combine(contentDirName, "Icon-57.png"); string icon72Path = Path.Combine(contentDirName, "Icon-72.png"); string icon256Path = Path.Combine(contentDirName, "Icon-256.png"); string icon512Path = Path.Combine(contentDirName, "Icon-512.png"); string ipaPath = Path.Combine(contentDirName, ipaFileName); string infoPath = Path.Combine(contentDirName, infoFileName); string mobileconfigPath = Path.Combine(contentDirName, "device.mobileconfig"); string provicheckPath = Path.Combine(contentDirName, "provisioningcheck.html"); info.Icon57.Icon.Save(Path.Combine(m_OutputDir, icon57Path)); info.Icon72.Icon.Save(Path.Combine(m_OutputDir, icon72Path)); info.Icon256.Icon.Save(Path.Combine(m_OutputDir, icon256Path)); info.Icon512.Icon.Save(Path.Combine(m_OutputDir, icon512Path)); dictionary["[[BUNDLE-DISPLAY-NAME]]"] = info.BundleDisplayName; dictionary["[[BUNDLE-ID]]"] = info.BundleIdentifier; dictionary["[[BUNDLE-VERSION]]"] = info.BundleVersion; dictionary["[[BUILD-PLATFORM]]"] = info.DeviceFamily.ToString(); dictionary["[[BUILD-DATE]]"] = info.BuildDate.ToString(); dictionary["[[ICON-SMALL-URL]]"] = GetAbsoluteUrl(icon57Path); dictionary["[[ICON-URL]]"] = GetAbsoluteUrl(icon72Path); dictionary["[[ICON-LARGE-URL]]"] = GetAbsoluteUrl(icon256Path); dictionary["[[ICON-XLARGE-URL]]"] = GetAbsoluteUrl(icon512Path); dictionary["[[IPA-URL]]"] = GetAbsoluteUrl(ipaPath); dictionary["[[PLIST-URL]]"] = GetAbsoluteUrl(infoPath); dictionary["[[DEVICECONFIG-URL]]"] = GetAbsoluteUrl(mobileconfigPath); dictionary["[[DEVICECONFIG-VISIBILITY]]"] = "; visibility: hidden;"; if (IsUUIDServiceEnabled()) { // Warning: This tool require server side code! // ============================================ // Take a look on mobileconfig.xml template (in Resources). You need to provide URL to web service, which could parse // response from device (extract UUID) and redirect user to website, which address is in url argument. // http://yourservice_getuuid.company.com/receiver.php?url=<url_generated_by_installer> // Service should redicert user to <url_generated_by_installer>?uid=<uuid_extracted_from_resopnse> // // References: // http://www.joshwright.com/tips/getting-an-iphone-udid-from-mobile-safari // https://github.com/hunk/get-udid // Make the "Check profile" link visible dictionary["[[DEVICECONFIG-VISIBILITY]]"] = ""; Dictionary <string, string> provisionedDictionary = new Dictionary <string, string>(); provisionedDictionary.Add("[[TITLE-NAME]]", "Ad-Hoc Installers"); provisionedDictionary["[[BUNDLE-DISPLAY-NAME]]"] = info.BundleDisplayName; provisionedDictionary["[[BUNDLE-ID]]"] = info.BundleIdentifier; provisionedDictionary["[[BUNDLE-VERSION]]"] = info.BundleVersion; provisionedDictionary["[[BUILD-PLATFORM]]"] = info.DeviceFamily.ToString(); provisionedDictionary["[[BUILD-DATE]]"] = info.BuildDate.ToString(); provisionedDictionary["[[ICON-LARGE-URL]]"] = GetAbsoluteUrl(icon256Path); provisionedDictionary["[[IMAGE-OK-URL]]"] = GetAbsoluteUrl(imageokPath); provisionedDictionary["[[IMAGE-FAIL-URL]]"] = GetAbsoluteUrl(imagefailPath); provisionedDictionary["[[PLIST-URL]]"] = GetAbsoluteUrl(infoPath); provisionedDictionary["[[UUID-ARRAY]]"] = GetJavaScriptArrayofUUIDs(info); provisionedDictionary["[[BUTTON-URL]]"] = GetAbsoluteUrl(buttonPath); string provicheckContent = ReplaceTokens(Resources.ProvisioningCheck, provisionedDictionary); File.WriteAllText(Path.Combine(m_OutputDir, provicheckPath), provicheckContent); Dictionary <string, string> mobileConfigDictionary = new Dictionary <string, string>(); mobileConfigDictionary.Add("[[PROVISIONCHECK-URL]]", GetAbsoluteUrl(provicheckPath)); mobileConfigDictionary.Add("[[PROVISIONCHECK-SERVER]]", UUIDServiceUrl); string mobileconfigContent = ReplaceTokens(Resources.mobileconfig, mobileConfigDictionary); File.WriteAllText(Path.Combine(m_OutputDir, mobileconfigPath), mobileconfigContent); } string installRow = ReplaceTokens(rowTemplate, dictionary); string infoContent = ReplaceTokens(Resources.Template, dictionary); File.WriteAllText(Path.Combine(m_OutputDir, infoPath), infoContent); installer.Append(installRow); if (!SkipCopying) { CopyFile(info.BundlePath, Path.Combine(m_OutputDir, ipaPath)); } } installer.Append(ReplaceTokens(footerTemplate, commonDictionary)); File.WriteAllText(Path.Combine(m_OutputDir, installPath), installer.ToString()); // IPA Keys: // [[IPA-URL]] [[ICON-URL]] [[ICON-LARGE-URL]] [[BUNDLE-ID]] [[BUNDLE-VERSION]] [[BUNDLE-DISPLAY-NAME]] [[BUILD-PLATFORM]] [[BUILD-DATE]] [[DEVICECONFIG-URL]] // Install Keys: // [[BUNDLE-DISPLAY-NAME]] [[ICON-LARGE-URL]] [[PLIST-URL]] [[BUTTON-URL]] }