public async Task CreateConfigurationAsync(string filePath, ConfigurationModel configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var xmlWriterSettings = XmlWriterHelper.GetDefaultXmlWriterSettings(); var OSBitArchitecture = configuration.SelectedEdition.GetOSArchitecture(); await Task.Run(() => { using (var fileStream = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite)) { using (var xmlWriter = XmlWriter.Create(fileStream, xmlWriterSettings)) { xmlWriter.WriteStartElement("Configuration"); xmlWriter.WriteStartElement("Add"); if (configuration.UseCustomSourcePath && !string.IsNullOrWhiteSpace(configuration.SourcePath)) { xmlWriter.WriteAttributeString("SourcePath", configuration.SourcePath); } if (!string.IsNullOrWhiteSpace(configuration.Version)) { xmlWriter.WriteAttributeString("Version", configuration.Version); } xmlWriter.WriteAttributeString("OfficeClientEdition", OSBitArchitecture.ToString()); xmlWriter.WriteAttributeString("Channel", configuration.SelectedChannel.ToString("G")); if (configuration.UseCustomDownloadPath && !string.IsNullOrWhiteSpace(configuration.DownloadPath)) { xmlWriter.WriteAttributeString("DownloadPath", configuration.DownloadPath); } if (configuration.ForceUpgradeFromOffice2013) { xmlWriter.WriteAttributeString("ForceUpgrade", true.GetBooleanStringFromBoolean()); } xmlWriter.WriteOffice365ProPlusRetailProductElement( languages: configuration.AddedLanguages.Select(l => l.Id), excludedAppIds: configuration.ExcludedProducts.Select(p => p.Id)); xmlWriter.WriteEndElement(); xmlWriter.WriteRemoveElement(configuration.RemovePreviousOfficeInstallations); xmlWriter.WriteUpdatesElement(configuration.EnableUpdates, configuration.SelectedChannel); xmlWriter.WriteDisplayElement(configuration.SilentMode, configuration.AcceptEula); xmlWriter.WritePropertyElement("AUTOACTIVATE", (configuration.AutoActivate.GetBitStringFromBoolean())); xmlWriter.WritePropertyElement("FORCEAPPSHUTDOWN", (configuration.ForceAppShutdown.GetBooleanStringFromBoolean())); xmlWriter.WritePropertyElement("PinIconsToTaskBar", (configuration.PinIconsToTaskBar.GetBooleanStringFromBoolean())); xmlWriter.WritePropertyElement("SharedComputerLicensing", (configuration.SharedComputerLicensing.GetBitStringFromBoolean())); xmlWriter.WriteEndElement(); xmlWriter.Flush(); } } }); }