Beispiel #1
0
        public static UnityEngine.Object Load(string prefabName, BundleType bundleType = BundleType.Resources)
        {
            if (bundleType == BundleType.Resources || ForceResourcesLoad)
            {
                return(ResourcesLoad(prefabName));
            }

            UnityEngine.Object obj = null;

            {
                string ABPrefabName = prefabName.Remove(0, prefabName.LastIndexOf('/') + 1);

                if (bundleType == BundleType.Main)
                {
                    if (MainBundle == null)
                    {
                        return(ResourcesLoad(prefabName));
                    }
                    obj = MainBundle.LoadAsset(ABPrefabName);
                }
                else
                {
                    if (bundleType == BundleType.Art)
                    {
                        return(ResourcesLoad(prefabName));
                    }
                    obj = ArtBundle.LoadAsset(ABPrefabName);
                }
            }
            return(obj);
        }
Beispiel #2
0
        /***************************************************************************
        *
        * Private Methods
        *
        ***************************************************************************/

        private async void Generate_File_Button_Click(object sender, RoutedEventArgs e)
        {
            //Check that all required fields have been filled
            if (!_validateInput())
            {
                return;
            }

            var savePicker = new Windows.Storage.Pickers.FileSavePicker
            {
                SuggestedStartLocation =
                    Windows.Storage.Pickers.PickerLocationId.Desktop
            };

            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add("APPINSTALLER file", new List <string>()
            {
                ".appinstaller"
            });
            // Default file name if the user does not type one in or select a file to replace

            Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();

            try
            {
                var t = Task.Run(async() =>
                {
                    var fileStream = await file.OpenAsync(FileAccessMode.ReadWrite);

                    //Create file
                    //FileStream writer = new FileStream(file.Path, FileMode.OpenOrCreate);

                    AppInstaller appInstaller = new AppInstaller(App.AppInstallerFilePath, App.AppInstallerVersionNumber);

                    XmlWriterSettings settings = new XmlWriterSettings
                    {
                        Indent              = true,
                        OmitXmlDeclaration  = false,
                        NewLineOnAttributes = true,
                        Encoding            = Encoding.UTF8,
                        NamespaceHandling   = NamespaceHandling.OmitDuplicates
                    };

                    var fs = fileStream.AsStreamForWrite();
                    fs.SetLength(0);


                    XmlWriter xdw = XmlWriter.Create(fs, settings);

                    //DataContractSerializer appInstallerDCS = new DataContractSerializer(typeof(AppInstaller));

                    //AppInstaller Content
                    //appInstallerDCS.WriteStartObject(xdw, appInstaller);
                    xdw.WriteStartElement("", "AppInstaller", App.AppInstallerFileSchemaNamespace);

                    //xdw.WriteAttributeString("xmlns", );
                    xdw.WriteAttributeString("Version", App.AppInstallerVersionNumber);
                    xdw.WriteAttributeString("Uri", App.AppInstallerFilePath);


                    //Main Package Content
                    if (App.MainPackage.PackageType == PackageType.MSIX)
                    {
                        //DataContractSerializer mainPackageDCS = new DataContractSerializer(typeof(MainPackage));

                        //mainPackageDCS.WriteStartObject(xdw, _mainPackage);

                        xdw.WriteStartElement("MainPackage");

                        xdw.WriteAttributeString("Name", _mainPackage.Name);
                        xdw.WriteAttributeString("Publisher", _mainPackage.Publisher);
                        xdw.WriteAttributeString("Version", _mainPackage.Version);
                        if (_mainPackage.ResourceId != "")
                        {
                            xdw.WriteAttributeString("ResourceId", _mainPackage.ResourceId);
                        }
                        if (_mainPackage.ProcessorArchitecture != "" && _mainPackage.PackageType != PackageType.MSIXBUNDLE)
                        {
                            xdw.WriteAttributeString("ProcessorArchitecture", _mainPackage.ProcessorArchitecture.ToString());
                        }
                        xdw.WriteAttributeString("Uri", _mainPackage.FilePath);
                        xdw.WriteEndElement();
                        //mainPackageDCS.WriteEndObject(xdw);
                    }
                    else if (App.MainPackage.PackageType == PackageType.MSIXBUNDLE)
                    {
                        //DataContractSerializer mainBundleDCS = new DataContractSerializer(typeof(MainBundle));
                        MainBundle mainBundle = new MainBundle(App.MainPackage.FilePath, App.MainPackage.Version, App.MainPackage.Publisher, App.MainPackage.Name);
                        //mainBundleDCS.WriteStartObject(xdw, mainBundle);
                        xdw.WriteStartElement("MainBundle");

                        xdw.WriteAttributeString("Name", mainBundle.Name);
                        xdw.WriteAttributeString("Publisher", mainBundle.Publisher);
                        xdw.WriteAttributeString("Version", mainBundle.Version);
                        xdw.WriteAttributeString("Uri", mainBundle.FilePath);
                        //mainBundleDCS.WriteEndObject(xdw);
                        xdw.WriteEndElement();
                    }

                    //Optional Packages Content
                    ObservableCollection <OptionalPackage> optionalPackages = App.OptionalPackages;
                    //DataContractSerializer optionalPackageDCS = new DataContractSerializer(typeof(OptionalPackage));

                    //Modification Packages Content
                    ObservableCollection <ModificationPackage> modificationPackages = App.ModificationPackages;

                    bool hasOptionalPackage     = (optionalPackages.Count > 0 && App.IsOptionalPackages);
                    bool hasModificationPackage = (modificationPackages.Count > 0 && App.IsModificationPackages);

                    if (hasOptionalPackage || hasModificationPackage)
                    {
                        xdw.WriteStartElement("OptionalPackages");
                        //optionalPackageDCS.WriteStartObject(xdw, optionalPackages[0]);
                        if (hasOptionalPackage)
                        {
                            for (int i = 0; i < optionalPackages.Count; i++)
                            {
                                //Write package or bundle element
                                if (optionalPackages[i].PackageType == PackageType.MSIX)
                                {
                                    Package package = new Package(
                                        optionalPackages[i].FilePath,
                                        optionalPackages[i].Version,
                                        optionalPackages[i].Publisher,
                                        optionalPackages[i].Name,
                                        optionalPackages[i].PackageType,
                                        optionalPackages[i].ProcessorArchitecture
                                        );

                                    //DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package));
                                    xdw.WriteStartElement("Package");
                                    //packageDCS.WriteStartObject(xdw, package);
                                    xdw.WriteAttributeString("Version", package.Version);
                                    xdw.WriteAttributeString("Uri", package.FilePath);
                                    xdw.WriteAttributeString("Publisher", package.Publisher);
                                    if (package.ProcessorArchitecture != "" && package.PackageType != PackageType.MSIXBUNDLE)
                                    {
                                        xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString());
                                    }
                                    xdw.WriteAttributeString("Name", package.Name);
                                    //packageDCS.WriteEndObject(xdw);
                                    xdw.WriteEndElement();
                                }
                                else if (optionalPackages[i].PackageType == PackageType.MSIXBUNDLE)
                                {
                                    Bundle bundle = new Bundle(
                                        optionalPackages[i].FilePath,
                                        optionalPackages[i].Version,
                                        optionalPackages[i].Publisher,
                                        optionalPackages[i].Name,
                                        optionalPackages[i].PackageType
                                        );

                                    //DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle));
                                    //bundleDCS.WriteStartObject(xdw, bundle);
                                    xdw.WriteStartElement("Bundle");
                                    xdw.WriteAttributeString("Version", bundle.Version);
                                    xdw.WriteAttributeString("Uri", bundle.FilePath);
                                    xdw.WriteAttributeString("Publisher", bundle.Publisher);
                                    xdw.WriteAttributeString("Name", bundle.Name);
                                    //bundleDCS.WriteEndObject(xdw);
                                    xdw.WriteEndElement();
                                }
                            }
                        }

                        if (hasModificationPackage)
                        {
                            for (int i = 0; i < modificationPackages.Count; i++)
                            {
                                //Write package or bundle element
                                if (modificationPackages[i].PackageType == PackageType.MSIX)
                                {
                                    Package package = new Package(
                                        modificationPackages[i].FilePath,
                                        modificationPackages[i].Version,
                                        modificationPackages[i].Publisher,
                                        modificationPackages[i].Name,
                                        modificationPackages[i].PackageType,
                                        modificationPackages[i].ProcessorArchitecture
                                        );

                                    //DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package));
                                    //packageDCS.WriteStartObject(xdw, package);
                                    xdw.WriteStartElement("Package");
                                    xdw.WriteAttributeString("Version", package.Version);
                                    xdw.WriteAttributeString("Uri", package.FilePath);
                                    xdw.WriteAttributeString("Publisher", package.Publisher);
                                    if (package.ProcessorArchitecture != "" && package.PackageType != PackageType.MSIXBUNDLE)
                                    {
                                        xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString());
                                    }
                                    xdw.WriteAttributeString("Name", package.Name);
                                    //packageDCS.WriteEndObject(xdw);
                                    xdw.WriteEndElement();
                                }
                                else if (modificationPackages[i].PackageType == PackageType.MSIXBUNDLE)
                                {
                                    Bundle bundle = new Bundle(
                                        modificationPackages[i].FilePath,
                                        modificationPackages[i].Version,
                                        modificationPackages[i].Publisher,
                                        modificationPackages[i].Name,
                                        modificationPackages[i].PackageType
                                        );

                                    //DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle));
                                    //bundleDCS.WriteStartObject(xdw, bundle);
                                    xdw.WriteStartElement("Bundle");
                                    xdw.WriteAttributeString("Version", bundle.Version);
                                    xdw.WriteAttributeString("Uri", bundle.FilePath);
                                    xdw.WriteAttributeString("Publisher", bundle.Publisher);
                                    xdw.WriteAttributeString("Name", bundle.Name);
                                    //bundleDCS.WriteEndObject(xdw);
                                    xdw.WriteEndElement();
                                }
                            }
                        }
                        //optionalPackageDCS.WriteEndObject(xdw);
                        xdw.WriteEndElement();
                    }

                    //Related Packages Content
                    ObservableCollection <RelatedPackage> relatedPackages = App.RelatedPackages;
                    //DataContractSerializer relatedPackageDCS = new DataContractSerializer(typeof(RelatedPackage));
                    if (relatedPackages.Count > 0 && App.IsRelatedPackages)
                    {
                        //relatedPackageDCS.WriteStartObject(xdw, relatedPackages[0]);
                        xdw.WriteStartElement("RelatedPackages");
                        for (int i = 0; i < relatedPackages.Count; i++)
                        {
                            //Write package or bundle element
                            if (relatedPackages[i].PackageType == PackageType.MSIX)
                            {
                                Package package = new Package(
                                    relatedPackages[i].FilePath,
                                    relatedPackages[i].Version,
                                    relatedPackages[i].Publisher,
                                    relatedPackages[i].Name,
                                    relatedPackages[i].PackageType,
                                    relatedPackages[i].ProcessorArchitecture
                                    );

                                //DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package));
                                xdw.WriteStartElement("Package");
                                //packageDCS.WriteStartObject(xdw, package);
                                xdw.WriteAttributeString("Version", package.Version);
                                xdw.WriteAttributeString("Uri", package.FilePath);
                                xdw.WriteAttributeString("Publisher", package.Publisher);
                                if (package.ProcessorArchitecture != "" && package.PackageType != PackageType.MSIXBUNDLE)
                                {
                                    xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString());
                                }
                                xdw.WriteAttributeString("Name", package.Name);
                                //packageDCS.WriteEndObject(xdw);
                                xdw.WriteEndElement();
                            }
                            else if (relatedPackages[i].PackageType == PackageType.MSIXBUNDLE)
                            {
                                Bundle bundle = new Bundle(
                                    relatedPackages[i].FilePath,
                                    relatedPackages[i].Version,
                                    relatedPackages[i].Publisher,
                                    relatedPackages[i].Name,
                                    relatedPackages[i].PackageType
                                    );

                                //DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle));
                                //bundleDCS.WriteStartObject(xdw, bundle);
                                xdw.WriteStartElement("Bundle");
                                xdw.WriteAttributeString("Version", bundle.Version);
                                xdw.WriteAttributeString("Uri", bundle.FilePath);
                                xdw.WriteAttributeString("Publisher", bundle.Publisher);
                                xdw.WriteAttributeString("Name", bundle.Name);
                                //bundleDCS.WriteEndObject(xdw);
                                xdw.WriteEndElement();
                            }
                        }
                        //relatedPackageDCS.WriteEndObject(xdw);
                        xdw.WriteEndElement();
                    }


                    //Dependency Content

                    ObservableCollection <Dependency> dependencies = App.Dependencies;
                    //DataContractSerializer dependencyDCS = new DataContractSerializer(typeof(Dependency));
                    if (dependencies.Count > 0 && App.IsDependencies)
                    {
                        //dependencyDCS.WriteStartObject(xdw, dependencies[0]);
                        xdw.WriteStartElement("Dependencies");
                        for (int i = 0; i < dependencies.Count; i++)
                        {
                            //Write package or bundle element
                            if (dependencies[i].PackageType == PackageType.MSIX)
                            {
                                Package package = new Package(
                                    dependencies[i].FilePath,
                                    dependencies[i].Version,
                                    dependencies[i].Publisher,
                                    dependencies[i].Name,
                                    dependencies[i].PackageType,
                                    dependencies[i].ProcessorArchitecture
                                    );

                                //DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package));
                                //packageDCS.WriteStartObject(xdw, package);
                                xdw.WriteStartElement("Package");
                                xdw.WriteAttributeString("Version", package.Version);
                                xdw.WriteAttributeString("Uri", package.FilePath);
                                xdw.WriteAttributeString("Publisher", package.Publisher);
                                if (package.ProcessorArchitecture != "" && package.PackageType != PackageType.MSIXBUNDLE)
                                {
                                    xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString());
                                }
                                xdw.WriteAttributeString("Name", package.Name);
                                //packageDCS.WriteEndObject(xdw);
                                xdw.WriteEndElement();
                            }
                            else if (dependencies[i].PackageType == PackageType.MSIXBUNDLE)
                            {
                                Bundle bundle = new Bundle(
                                    dependencies[i].FilePath,
                                    dependencies[i].Version,
                                    dependencies[i].Publisher,
                                    dependencies[i].Name,
                                    dependencies[i].PackageType
                                    );

                                //DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle));
                                //bundleDCS.WriteStartObject(xdw, bundle);
                                xdw.WriteStartElement("Bundle");
                                xdw.WriteAttributeString("Version", bundle.Version);
                                xdw.WriteAttributeString("Uri", bundle.FilePath);
                                xdw.WriteAttributeString("Publisher", bundle.Publisher);
                                xdw.WriteAttributeString("Name", bundle.Name);
                                //bundleDCS.WriteEndObject(xdw);
                                xdw.WriteEndElement();
                            }
                        }
                        //dependencyDCS.WriteEndObject(xdw);
                        xdw.WriteEndElement();
                    }


                    //Update Settings
                    UpdateSettings updateSettings = new UpdateSettings();

                    //OnLaunch
                    OnLaunch onLaunch = new OnLaunch(App.IsCheckUpdates, App.HoursBetweenUpdates, App.IsShowPrompt, App.IsBlockUpdate);

                    //ForceUpdateFromAnyVersion
                    ForceUpdateFromAnyVersion forceUpdate = new ForceUpdateFromAnyVersion(App.IsForceUpdate);

                    //AutomaticBackgroundTask
                    AutomaticBackgroundTask automaticBackgroundTask = new AutomaticBackgroundTask(App.IsAutoUpdate);

                    if (onLaunch.IsCheckUpdates)
                    {
                        //DataContractSerializer updateSettingsDCS = new DataContractSerializer(typeof(UpdateSettings));
                        //updateSettingsDCS.WriteStartObject(xdw, updateSettings);
                        xdw.WriteStartElement("UpdateSettings");

                        //DataContractSerializer onLaunchDCS = new DataContractSerializer(typeof(OnLaunch));
                        //onLaunchDCS.WriteStartObject(xdw, onLaunch);
                        xdw.WriteStartElement("OnLaunch");

                        //HoursBetweenUpdate checks is only available AFTER 1709
                        if (!App.AppInstallerFileSchemaNamespace.Equals("http://schemas.microsoft.com/appx/appinstaller/2017"))
                        {
                            xdw.WriteAttributeString("HoursBetweenUpdateChecks", onLaunch.HoursBetweenUpdateChecks.ToString());
                        }

                        if (onLaunch.IsShowPrompt)
                        {
                            xdw.WriteAttributeString("ShowPrompt", onLaunch.IsShowPrompt.ToString().ToLower());
                        }
                        if (onLaunch.IsBlockUpdate)
                        {
                            xdw.WriteAttributeString("UpdateBlocksActivation", onLaunch.IsBlockUpdate.ToString().ToLower());
                        }
                        //onLaunchDCS.WriteEndObject(xdw);
                        xdw.WriteEndElement();

                        if (forceUpdate.IsForceUpdate)
                        {
                            //DataContractSerializer forceUpdateDCS = new DataContractSerializer(typeof(ForceUpdateFromAnyVersion));
                            //forceUpdateDCS.WriteStartObject(xdw, forceUpdate);
                            xdw.WriteStartElement("ForceUpdateFromAnyVersion");
                            xdw.WriteString(forceUpdate.IsForceUpdate.ToString().ToLower());
                            //forceUpdateDCS.WriteEndObject(xdw);
                            xdw.WriteEndElement();
                        }

                        if (automaticBackgroundTask.IsAutoUpdate)
                        {
                            //DataContractSerializer autoUpdateDCS = new DataContractSerializer(typeof(AutomaticBackgroundTask));
                            //autoUpdateDCS.WriteStartObject(xdw, automaticBackgroundTask);
                            xdw.WriteStartElement("AutomaticBackgroundTask");
                            //autoUpdateDCS.WriteEndObject(xdw);
                            xdw.WriteEndElement();
                        }

                        //updateSettingsDCS.WriteEndObject(xdw);
                        xdw.WriteEndElement();
                    }


                    //xdw.WriteEndElement();
                    //appInstallerDCS.WriteEndObject(xdw);
                    xdw.Dispose();
                });
                t.Wait();
            }
            catch (Exception exc)
            {
                Debug.WriteLine("The serialization operation failed: {0} StackTrace: {1}",
                                exc.Message, exc.StackTrace);
            }

            //Display dialog
            _displaySuccessDialog(file);
        }
        private void SetupAppleDevAccount()
        {
            string?path = MainBundle.PathForResource(AppleDevAccount.ResourcePath, Json.String());

            AppleDevAccount = DeserializeObject <AppleDevAccount>(File.ReadAllText(path));
        }
        private void SetupApplicationVersions()
        {
            string?path = MainBundle.PathForResource(ApplicationVersion.ResourcePath, Json.String());

            ApplicationVersions = DeserializeObject <List <ApplicationVersion> >(File.ReadAllText(path));
        }
Beispiel #5
0
        /***************************************************************************
        *
        * Private Methods
        *
        ***************************************************************************/

        private void Generate_File_Button_Click(object sender, RoutedEventArgs e)
        {
            //Check that all required fields have been filled
            if (!_validateInput())
            {
                return;
            }

            try
            {
                var t = Task.Run(() =>
                {
                    //Create file
                    FileStream writer = new FileStream(ApplicationData.Current.LocalFolder.Path + "//Your_AppInstaller_File_Name.xml", FileMode.Create);

                    AppInstaller appInstaller = new AppInstaller(App.AppInstallerFilePath, App.AppInstallerVersionNumber);

                    //Initialize DCS of type AppInstallerModel
                    XmlDictionaryWriter xdw = XmlDictionaryWriter.CreateTextWriter(writer, Encoding.UTF8);

                    DataContractSerializer appInstallerDCS = new DataContractSerializer(typeof(AppInstaller));

                    //AppInstaller Content
                    appInstallerDCS.WriteStartObject(xdw, appInstaller);
                    xdw.WriteAttributeString("xmlns", "http://schemas.microsoft.com/appx/appinstaller/2017");
                    xdw.WriteAttributeString("Uri", App.AppInstallerFilePath);
                    xdw.WriteAttributeString("Version", App.AppInstallerVersionNumber);

                    //Main Package Content
                    if (App.MainPackage.PackageType == PackageType.MSIX)
                    {
                        DataContractSerializer mainPackageDCS = new DataContractSerializer(typeof(MainPackage));
                        MainPackage mainPackage = new MainPackage(App.MainPackage.FilePath, App.MainPackage.Version, App.MainPackage.Publisher, App.MainPackage.Name, App.MainPackage.PackageType, App.MainPackage.ProcessorArchitecture, App.MainPackage.ResourceId);
                        mainPackageDCS.WriteStartObject(xdw, mainPackage);
                        xdw.WriteAttributeString("Uri", mainPackage.FilePath);
                        xdw.WriteAttributeString("Version", mainPackage.Version);
                        xdw.WriteAttributeString("Publisher", mainPackage.Publisher);
                        if (mainPackage.ResourceId != "")
                        {
                            xdw.WriteAttributeString("ResourceId", mainPackage.ResourceId);
                        }
                        if (mainPackage.ProcessorArchitecture != ProcessorArchitecture.none && mainPackage.PackageType != PackageType.msixbundle)
                        {
                            xdw.WriteAttributeString("ProcessorArchitecture", mainPackage.ProcessorArchitecture.ToString());
                        }
                        xdw.WriteAttributeString("Name", mainPackage.Name);
                        mainPackageDCS.WriteEndObject(xdw);
                    }
                    else if (App.MainPackage.PackageType == PackageType.msixbundle)
                    {
                        DataContractSerializer mainBundleDCS = new DataContractSerializer(typeof(MainBundle));
                        MainBundle mainBundle = new MainBundle(App.MainPackage.FilePath, App.MainPackage.Version, App.MainPackage.Publisher, App.MainPackage.Name);
                        mainBundleDCS.WriteStartObject(xdw, mainBundle);
                        xdw.WriteAttributeString("Uri", mainBundle.FilePath);
                        xdw.WriteAttributeString("Version", mainBundle.Version);
                        xdw.WriteAttributeString("Publisher", mainBundle.Publisher);
                        xdw.WriteAttributeString("Name", mainBundle.Name);
                        mainBundleDCS.WriteEndObject(xdw);
                    }

                    //Optional Packages Content
                    ObservableCollection <OptionalPackage> optionalPackages = App.OptionalPackages;
                    DataContractSerializer optionalPackageDCS = new DataContractSerializer(typeof(OptionalPackage));
                    if (optionalPackages.Count > 0 && App.IsOptionalPackages)
                    {
                        optionalPackageDCS.WriteStartObject(xdw, optionalPackages[0]);
                        for (int i = 0; i < optionalPackages.Count; i++)
                        {
                            //Write package or bundle element
                            if (optionalPackages[i].PackageType == PackageType.MSIX)
                            {
                                Package package = new Package(
                                    optionalPackages[i].FilePath,
                                    optionalPackages[i].Version,
                                    optionalPackages[i].Publisher,
                                    optionalPackages[i].Name,
                                    optionalPackages[i].PackageType,
                                    optionalPackages[i].ProcessorArchitecture
                                    );

                                DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package));
                                packageDCS.WriteStartObject(xdw, package);
                                xdw.WriteAttributeString("Version", package.Version);
                                xdw.WriteAttributeString("Uri", package.FilePath);
                                xdw.WriteAttributeString("Publisher", package.Publisher);
                                if (package.ProcessorArchitecture != ProcessorArchitecture.none && package.PackageType != PackageType.msixbundle)
                                {
                                    xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString());
                                }
                                xdw.WriteAttributeString("Name", package.Name);
                                packageDCS.WriteEndObject(xdw);
                            }
                            else if (optionalPackages[i].PackageType == PackageType.msixbundle)
                            {
                                Bundle bundle = new Bundle(
                                    optionalPackages[i].FilePath,
                                    optionalPackages[i].Version,
                                    optionalPackages[i].Publisher,
                                    optionalPackages[i].Name,
                                    optionalPackages[i].PackageType
                                    );

                                DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle));
                                bundleDCS.WriteStartObject(xdw, bundle);
                                xdw.WriteAttributeString("Version", bundle.Version);
                                xdw.WriteAttributeString("Uri", bundle.FilePath);
                                xdw.WriteAttributeString("Publisher", bundle.Publisher);
                                xdw.WriteAttributeString("Name", bundle.Name);
                                bundleDCS.WriteEndObject(xdw);
                            }
                        }
                        optionalPackageDCS.WriteEndObject(xdw);
                    }


                    //Modification Packages Content
                    ObservableCollection <ModificationPackage> modificationPackages = App.ModificationPackages;
                    DataContractSerializer modificationPackageDCS = new DataContractSerializer(typeof(ModificationPackage));
                    if (modificationPackages.Count > 0 && App.IsModificationPackages)
                    {
                        modificationPackageDCS.WriteStartObject(xdw, modificationPackages[0]);
                        for (int i = 0; i < modificationPackages.Count; i++)
                        {
                            //Write package or bundle element
                            if (modificationPackages[i].PackageType == PackageType.MSIX)
                            {
                                Package package = new Package(
                                    modificationPackages[i].FilePath,
                                    modificationPackages[i].Version,
                                    modificationPackages[i].Publisher,
                                    modificationPackages[i].Name,
                                    modificationPackages[i].PackageType,
                                    modificationPackages[i].ProcessorArchitecture
                                    );

                                DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package));
                                packageDCS.WriteStartObject(xdw, package);
                                xdw.WriteAttributeString("Version", package.Version);
                                xdw.WriteAttributeString("Uri", package.FilePath);
                                xdw.WriteAttributeString("Publisher", package.Publisher);
                                if (package.ProcessorArchitecture != ProcessorArchitecture.none && package.PackageType != PackageType.msixbundle)
                                {
                                    xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString());
                                }
                                xdw.WriteAttributeString("Name", package.Name);
                                packageDCS.WriteEndObject(xdw);
                            }
                            else if (modificationPackages[i].PackageType == PackageType.msixbundle)
                            {
                                Bundle bundle = new Bundle(
                                    modificationPackages[i].FilePath,
                                    modificationPackages[i].Version,
                                    modificationPackages[i].Publisher,
                                    modificationPackages[i].Name,
                                    modificationPackages[i].PackageType
                                    );

                                DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle));
                                bundleDCS.WriteStartObject(xdw, bundle);
                                xdw.WriteAttributeString("Version", bundle.Version);
                                xdw.WriteAttributeString("Uri", bundle.FilePath);
                                xdw.WriteAttributeString("Publisher", bundle.Publisher);
                                xdw.WriteAttributeString("Name", bundle.Name);
                                bundleDCS.WriteEndObject(xdw);
                            }
                        }
                        modificationPackageDCS.WriteEndObject(xdw);
                    }

                    //Related Packages Content
                    ObservableCollection <RelatedPackage> relatedPackages = App.RelatedPackages;
                    DataContractSerializer relatedPackageDCS = new DataContractSerializer(typeof(RelatedPackage));
                    if (relatedPackages.Count > 0 && App.IsRelatedPackages)
                    {
                        relatedPackageDCS.WriteStartObject(xdw, relatedPackages[0]);
                        for (int i = 0; i < relatedPackages.Count; i++)
                        {
                            //Write package or bundle element
                            if (relatedPackages[i].PackageType == PackageType.MSIX)
                            {
                                Package package = new Package(
                                    relatedPackages[i].FilePath,
                                    relatedPackages[i].Version,
                                    relatedPackages[i].Publisher,
                                    relatedPackages[i].Name,
                                    relatedPackages[i].PackageType,
                                    relatedPackages[i].ProcessorArchitecture
                                    );

                                DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package));
                                packageDCS.WriteStartObject(xdw, package);
                                xdw.WriteAttributeString("Version", package.Version);
                                xdw.WriteAttributeString("Uri", package.FilePath);
                                xdw.WriteAttributeString("Publisher", package.Publisher);
                                if (package.ProcessorArchitecture != ProcessorArchitecture.none && package.PackageType != PackageType.msixbundle)
                                {
                                    xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString());
                                }
                                xdw.WriteAttributeString("Name", package.Name);
                                packageDCS.WriteEndObject(xdw);
                            }
                            else if (relatedPackages[i].PackageType == PackageType.msixbundle)
                            {
                                Bundle bundle = new Bundle(
                                    relatedPackages[i].FilePath,
                                    relatedPackages[i].Version,
                                    relatedPackages[i].Publisher,
                                    relatedPackages[i].Name,
                                    relatedPackages[i].PackageType
                                    );

                                DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle));
                                bundleDCS.WriteStartObject(xdw, bundle);
                                xdw.WriteAttributeString("Version", bundle.Version);
                                xdw.WriteAttributeString("Uri", bundle.FilePath);
                                xdw.WriteAttributeString("Publisher", bundle.Publisher);
                                xdw.WriteAttributeString("Name", bundle.Name);
                                bundleDCS.WriteEndObject(xdw);
                            }
                        }
                        relatedPackageDCS.WriteEndObject(xdw);
                    }


                    //Dependency Content

                    ObservableCollection <Dependency> dependencies = App.Dependencies;
                    DataContractSerializer dependencyDCS           = new DataContractSerializer(typeof(Dependency));
                    if (dependencies.Count > 0 && App.IsDependencies)
                    {
                        dependencyDCS.WriteStartObject(xdw, dependencies[0]);
                        for (int i = 0; i < dependencies.Count; i++)
                        {
                            //Write package or bundle element
                            if (dependencies[i].PackageType == PackageType.MSIX)
                            {
                                Package package = new Package(
                                    dependencies[i].FilePath,
                                    dependencies[i].Version,
                                    dependencies[i].Publisher,
                                    dependencies[i].Name,
                                    dependencies[i].PackageType,
                                    dependencies[i].ProcessorArchitecture
                                    );

                                DataContractSerializer packageDCS = new DataContractSerializer(typeof(Package));
                                packageDCS.WriteStartObject(xdw, package);
                                xdw.WriteAttributeString("Version", package.Version);
                                xdw.WriteAttributeString("Uri", package.FilePath);
                                xdw.WriteAttributeString("Publisher", package.Publisher);
                                if (package.ProcessorArchitecture != ProcessorArchitecture.none && package.PackageType != PackageType.msixbundle)
                                {
                                    xdw.WriteAttributeString("ProcessorArchitecture", package.ProcessorArchitecture.ToString());
                                }
                                xdw.WriteAttributeString("Name", package.Name);
                                packageDCS.WriteEndObject(xdw);
                            }
                            else if (dependencies[i].PackageType == PackageType.msixbundle)
                            {
                                Bundle bundle = new Bundle(
                                    dependencies[i].FilePath,
                                    dependencies[i].Version,
                                    dependencies[i].Publisher,
                                    dependencies[i].Name,
                                    dependencies[i].PackageType
                                    );

                                DataContractSerializer bundleDCS = new DataContractSerializer(typeof(Bundle));
                                bundleDCS.WriteStartObject(xdw, bundle);
                                xdw.WriteAttributeString("Version", bundle.Version);
                                xdw.WriteAttributeString("Uri", bundle.FilePath);
                                xdw.WriteAttributeString("Publisher", bundle.Publisher);
                                xdw.WriteAttributeString("Name", bundle.Name);
                                bundleDCS.WriteEndObject(xdw);
                            }
                        }
                        dependencyDCS.WriteEndObject(xdw);
                    }


                    //Update Settings
                    UpdateSettings updateSettings = new UpdateSettings();

                    //OnLaunch
                    OnLaunch onLaunch = new OnLaunch(App.IsCheckUpdates, App.HoursBetweenUpdates);

                    if (onLaunch.IsCheckUpdates)
                    {
                        DataContractSerializer updateSettingsDCS = new DataContractSerializer(typeof(UpdateSettings));
                        updateSettingsDCS.WriteStartObject(xdw, updateSettings);

                        DataContractSerializer onLaunchDCS = new DataContractSerializer(typeof(OnLaunch));
                        onLaunchDCS.WriteStartObject(xdw, onLaunch);
                        xdw.WriteAttributeString("HoursBetweenUpdateChecks", onLaunch.HoursBetweenUpdateChecks.ToString());
                        onLaunchDCS.WriteEndObject(xdw);
                        updateSettingsDCS.WriteEndObject(xdw);
                    }


                    appInstallerDCS.WriteEndObject(xdw);
                    xdw.Dispose();
                });
                t.Wait();
            }
            catch (Exception exc)
            {
                Debug.WriteLine("The serialization operation failed: {0} StackTrace: {1}",
                                exc.Message, exc.StackTrace);
            }

            //Display dialog
            _displaySuccessDialog();
        }