public void FixCloseAppsCondition() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", " <Fragment>", " <util:CloseApplication Id='EndApp' Target='example.exe'>", " a<>b", " </util:CloseApplication>", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", " <Fragment>", " <util:CloseApplication Id=\"EndApp\" Target=\"example.exe\" Condition=\"a<>b\" />", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(3, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void FixXmlConfigValue() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", " <Fragment>", " <util:XmlConfig Id='Change' ElementPath='book'>", " a<>b", " </util:XmlConfig>", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", " <Fragment>", " <util:XmlConfig Id=\"Change\" ElementPath=\"book\" Value=\"a<>b\" />", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(3, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void FixRemoteAddressValue() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:fw='http://schemas.microsoft.com/wix/FirewallExtension'>", " <Fragment>", " <fw:RemoteAddress>", " 127.0.0.1", " </fw:RemoteAddress>", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:fw=\"http://wixtoolset.org/schemas/v4/wxs/firewall\">", " <Fragment>", " <fw:RemoteAddress Value=\"127.0.0.1\" />", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(3, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void CanConvertExePackageCommandToArguments() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <Fragment>", " <PackageGroup Id='exe'>", " <ExePackage InstallCommand='-install' RepairCommand='-repair' UninstallCommand='-uninstall' SourceFile='test.exe' />", " </PackageGroup>", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <PackageGroup Id=\"exe\">", " <ExePackage SourceFile=\"test.exe\" InstallArguments=\"-install\" RepairArguments=\"-repair\" UninstallArguments=\"-uninstall\" />", " </PackageGroup>", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(3, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void FixTagExtensionTagRef() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:tag='http://schemas.microsoft.com/wix/TagExtension'>", " <Fragment>", " <PatchFamily>", " <tag:TagRef Regid='wixtoolset.org' />", " </PatchFamily>", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <PatchFamily>", " <SoftwareTagRef Regid=\"wixtoolset.org\" />", " </PatchFamily>", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(3, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void FixTagExtensionDeprecations() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:tag='http://schemas.microsoft.com/wix/TagExtension'>", " <Product>", " <tag:Tag Regid='wixtoolset.org' InstallDirectory='InstallFolder' Licensed='true' Type='component' Win64='yes' />", " </Product>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Package>", " <SoftwareTag Regid=\"wixtoolset.org\" InstallDirectory=\"InstallFolder\" Bitness=\"always64\" />", " </Package>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(7, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void CanConvertRemotePayloadElement() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <RemotePayload", " Description='Microsoft ASP.NET Core 3.1.8 - Shared Framework'", " Hash='61DC9EAA0C8968E48E13C5913ED202A2F8F94DBA'", " CertificatePublicKey='3756E9BBF4461DCD0AA68E0D1FCFFA9CEA47AC18'", " CertificateThumbprint='2485A7AFA98E178CB8F30C9838346B514AEA4769'", " ProductName='Microsoft ASP.NET Core 3.1.8 - Shared Framework'", " Size='7841880'", " Version='3.1.8.20421' />", "</Wix>"); var expected = String.Join(Environment.NewLine, "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <RemotePayload Description=\"Microsoft ASP.NET Core 3.1.8 - Shared Framework\" Hash=\"61DC9EAA0C8968E48E13C5913ED202A2F8F94DBA\" ProductName=\"Microsoft ASP.NET Core 3.1.8 - Shared Framework\" Size=\"7841880\" Version=\"3.1.8.20421\" />", "</Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(2, errors); Assert.Equal(expected, actual); }
public void RemoveDeprecatedAllowAdvertiseAttributes() { var parse = String.Join(Environment.NewLine, "<?xml version=\"1.0\" encoding=\"utf-16\"?>", "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", " <Fragment>", " <Feature AllowAdvertise='disallow' />", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <Feature />", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(3, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void CantCreateBootstrapperApplicationDllFromV3PayloadGroupRef() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", " <Fragment>", " <BootstrapperApplication Id='ba'>", " <PayloadGroupRef Id='baPayloads' />", " </BootstrapperApplication>", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <BootstrapperApplication Id=\"ba\">", " <PayloadGroupRef Id=\"baPayloads\" />", " </BootstrapperApplication>", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(2, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void CanConvertMsiCustomTableRef() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <CustomTable Id='FgAppx'>", " <Row>", " <Data Column='Column1'>Row1</Data>", " </Row>", " </CustomTable>", "</Wix>"); var expected = String.Join(Environment.NewLine, "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <CustomTableRef Id=\"FgAppx\">", " <Row>", " <Data Column=\"Column1\" Value=\"Row1\" />", " </Row>", " </CustomTableRef>", "</Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, customTableTarget: CustomTableTarget.Msi); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(2, errors); Assert.Equal(expected, actual); }
public void FixNamespace() { var parse = String.Join(Environment.NewLine, "<Include xmlns='http://schemas.microsoft.com/wix/2006/wi'>", " <Fragment />", "</Include>"); var expected = new[] { "<Include xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment />", "</Include>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(1, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void EnsuresDeclarationWhenIgnored() { var parse = String.Join(Environment.NewLine, "<?xml version='1.0' encoding='utf-16'?>", "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <Fragment />", "</Wix>"); var expected = String.Join(Environment.NewLine, "<?xml version=\"1.0\" encoding=\"utf-16\"?>", "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment />", "</Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, ignoreErrors: new[] { "DeclarationPresent" }); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document, omitXmlDeclaration: false); Assert.Equal(0, errors); Assert.Equal(expected, actual); }
public void CanConvertNamedMainNamespace() { var parse = String.Join(Environment.NewLine, "<?xml version='1.0' encoding='utf-8'?>", "<w:Wix xmlns:w='http://schemas.microsoft.com/wix/2006/wi'>", " <w:Fragment />", "</w:Wix>"); var expected = String.Join(Environment.NewLine, "<w:Wix xmlns:w=\"http://wixtoolset.org/schemas/v4/wxs\">", " <w:Fragment />", "</w:Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(2, errors); Assert.Equal(expected, actual); Assert.Equal(Wix4Namespace, document.Root.GetNamespaceOfPrefix("w")); }
public void CanConvertAnonymousFile() { var parse = String.Join(Environment.NewLine, "<?xml version='1.0' encoding='utf-8'?>", "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", " <File Source='path\\to\\foo.txt' />", "</Wix>"); var expected = String.Join(Environment.NewLine, "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <File Id=\"foo.txt\" Source=\"path\\to\\foo.txt\" />", "</Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(3, errors); Assert.Equal(expected, actual); }
public void CanConvertShortNameDirectoryWithoutName() { var parse = String.Join(Environment.NewLine, "<?xml version='1.0' encoding='utf-8'?>", "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <Directory ShortName='iamshort' />", "</Wix>"); var expected = String.Join(Environment.NewLine, "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Directory Name=\"iamshort\" />", "</Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(2, errors); Assert.Equal(expected, actual); }
public void CanConvertMsiCustomTableBootstrapperApplicationData() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <CustomTable Id='FgAppx' BootstrapperApplicationData='yes'>", " <Column Id='Column1' PrimaryKey='yes' Type='string' Width='0' Category='text' Description='The first custom column.' />", " <Row>", " <Data Column='Column1'>Row1</Data>", " </Row>", " </CustomTable>", "</Wix>"); var expected = String.Join(Environment.NewLine, "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <CustomTable Id=\"FgAppx\" Unreal=\"yes\">", " <Column Id=\"Column1\" PrimaryKey=\"yes\" Type=\"string\" Width=\"0\" Category=\"text\" Description=\"The first custom column.\" />", " <Row>", " <Data Column=\"Column1\" Value=\"Row1\" />", " </Row>", " </CustomTable>", "</Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, customTableTarget: CustomTableTarget.Msi); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(2, errors); Assert.Equal(expected, actual); }
public void CanConvertSingleFile() { const string beforeFileName = "SingleFile.wxs"; const string afterFileName = "ConvertedSingleFile.wxs"; var folder = TestData.Get(@"TestData\SingleFile"); using (var fs = new DisposableFileSystem()) { var baseFolder = fs.GetFolder(true); var targetFile = Path.Combine(baseFolder, beforeFileName); File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName)); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 4); var errors = converter.ConvertFile(targetFile, true); Assert.Equal(9, errors); var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n"); var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n"); Assert.Equal(expected, actual); EnsureFixed(targetFile); } }
public void KeepsDpiAwarenessFromV4() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <Fragment>", " <BootstrapperApplication Id='ba' SourceFile='ba.dll' DpiAwareness='system' />", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <BootstrapperApplication Id=\"ba\">", "<BootstrapperApplicationDll SourceFile=\"ba.dll\" DpiAwareness=\"system\" />", "</BootstrapperApplication>", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(1, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void RemovesBalUseUILanguages() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:bal='http://schemas.microsoft.com/wix/BalExtension'>", " <Fragment>", " <BootstrapperApplication Id='ba' bal:UseUILanguages='true' />", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <BootstrapperApplication Id=\"ba\" />", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(5, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void CanFormatWithNewLineAtEndOfFile() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <Fragment>", "", " <Property Id='Prop' Value='Val' />", "", " </Fragment>", "</Wix>", ""); var expected = String.Join(Environment.NewLine, "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", "", " <Property Id=\"Prop\" Value=\"Val\" />", "", " </Fragment>", "</Wix>", ""); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 4, null, null); var conversions = converter.FormatDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(expected, actual); Assert.Equal(3, conversions); }
public void ConvertStandardBootstrapperApplicationRefWithoutExistingElement() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:bal='http://schemas.microsoft.com/wix/BalExtension'>", " <Fragment>", " <BootstrapperApplicationRef Id='WixStandardBootstrapperApplication.RtfLicense' />", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:bal=\"http://wixtoolset.org/schemas/v4/wxs/bal\">", " <Fragment>", " <BootstrapperApplication>", "<bal:WixStandardBootstrapperApplication Theme=\"rtfLicense\" />", "</BootstrapperApplication>", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(3, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void FixCondition() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>", " <Fragment>", " <InstallUISequence>", " <Custom Action='ExampleCA' After='InstallFiles'>NOT Installed</Custom>", " </InstallUISequence>", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <InstallUISequence>", " <Custom Action=\"ExampleCA\" After=\"InstallFiles\" Condition=\"NOT Installed\" />", " </InstallUISequence>", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(2, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void CanConvertCustomAction() { var parse = String.Join(Environment.NewLine, "<?xml version='1.0' encoding='utf-8'?>", "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <CustomAction Id='Foo' BinaryKey='WixCA' DllEntry='CAQuietExec' />", " <CustomAction Id='Foo' BinaryKey='WixCA_x64' DllEntry='CAQuietExec64' />", " <CustomAction Id='Foo' BinaryKey='UtilCA' DllEntry='WixQuietExec' />", " <CustomAction Id='Foo' BinaryKey='UtilCA_x64' DllEntry='WixQuietExec64' />", "</Wix>"); var expected = String.Join(Environment.NewLine, "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <CustomAction Id=\"Foo\" DllEntry=\"WixQuietExec\" BinaryRef=\"Wix4UtilCA_X86\" />", " <CustomAction Id=\"Foo\" DllEntry=\"WixQuietExec64\" BinaryRef=\"Wix4UtilCA_X64\" />", " <CustomAction Id=\"Foo\" DllEntry=\"WixQuietExec\" BinaryRef=\"Wix4UtilCA_X86\" />", " <CustomAction Id=\"Foo\" DllEntry=\"WixQuietExec64\" BinaryRef=\"Wix4UtilCA_X64\" />", "</Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(11, errors); Assert.Equal(expected, actual); }
public void CanKeepCdataWithOnlyWhitespace() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <Fragment>", " <Property Id='Prop'><![CDATA[ ]]></Property>", " </Fragment>", "</Wix>"); var expected = String.Join(Environment.NewLine, "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <Property Id=\"Prop\" Value=\" \" />", " </Fragment>", "</Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(expected, actual); Assert.Equal(1, errors); }
public void DoesntFixFormattedTypeFromV4() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <Fragment>", " <Variable Name='ImplicitString' Value='implicit' />", " <Variable Name='ExplicitString' Type='string' Value='explicit' />", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <Variable Name=\"ImplicitString\" Value=\"implicit\" />", " <Variable Name=\"ExplicitString\" Type=\"string\" Value=\"explicit\" />", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(0, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void ConvertDotNetCoreBootstrapperApplicationRefWithoutExistingElement() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs' xmlns:bal='http://wixtoolset.org/schemas/v4/wxs/bal'>", " <Fragment>", " <BootstrapperApplicationRef Id='DotNetCoreBootstrapperApplicationHost' />", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:bal=\"http://wixtoolset.org/schemas/v4/wxs/bal\">", " <Fragment>", " <BootstrapperApplication>", "<bal:WixDotNetCoreBootstrapperApplicationHost />", "</BootstrapperApplication>", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(1, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void FixUtilRegistrySearchBitness() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>", " <Fragment>", " <util:RegistrySearch Id='RegValue' Root='HKLM' Key='Converter' Variable='Test' />", " <util:RegistrySearch Id='RegValue2' Root='HKLM' Key='Converter' Variable='Test' Result='value' Win64='no' />", " <util:RegistrySearch Id='RegValue3' Root='HKLM' Key='Converter' Variable='Test' Result='exists' Win64='yes' />", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\" xmlns:util=\"http://wixtoolset.org/schemas/v4/wxs/util\">", " <Fragment>", " <util:RegistrySearch Id=\"RegValue\" Root=\"HKLM\" Key=\"Converter\" Variable=\"Test\" />", " <util:RegistrySearch Id=\"RegValue2\" Root=\"HKLM\" Key=\"Converter\" Variable=\"Test\" Result=\"value\" Bitness=\"always32\" />", " <util:RegistrySearch Id=\"RegValue3\" Root=\"HKLM\" Key=\"Converter\" Variable=\"Test\" Result=\"exists\" Bitness=\"always64\" />", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(6, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
public void CanConvertMissingWixNamespace() { var parse = String.Join(Environment.NewLine, "<?xml version='1.0' encoding='utf-8'?>", "<Wix>", " <Fragment />", "</Wix>"); var expected = String.Join(Environment.NewLine, "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment />", "</Wix>"); var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); var actual = UnformattedDocumentString(document); Assert.Equal(2, errors); Assert.Equal(expected, actual); Assert.Equal(Wix4Namespace, document.Root.GetDefaultNamespace()); }
public void CanConvertMspYesCache() { var parse = String.Join(Environment.NewLine, "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>", " <Fragment>", " <PackageGroup Id='exe'>", " <MspPackage Cache='yes' SourceFile='test.msp' />", " </PackageGroup>", " </Fragment>", "</Wix>"); var expected = new[] { "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", " <Fragment>", " <PackageGroup Id=\"exe\">", " <MspPackage Cache=\"keep\" SourceFile=\"test.msp\" />", " </PackageGroup>", " </Fragment>", "</Wix>" }; var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 2, null, null); var errors = converter.ConvertDocument(document); Assert.Equal(1, errors); var actualLines = UnformattedDocumentLines(document); WixAssert.CompareLineByLine(expected, actualLines); }
private static void EnsureFixed(string targetFile) { var messaging2 = new MockMessaging(); var converter2 = new WixConverter(messaging2, 4); var errors2 = converter2.ConvertFile(targetFile, true); Assert.Equal(0, errors2); }