public void TestKnownId() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "ApplicationFiles", Title = "All Files", Description = "All Files", Content = new Content { Include = @"**/*" } } }, KnownIds = new[] { new KnownId { Id = "foo", Path = "Bin/foo.exe" } } }; var document = WixDocumentFor(parameters); var fileWithKnownId = (from file in document.Files where file.Id == "foo" select file).AssertSingle(); WixAssert.AssertFile(DirectoryFromRoot("Bin")["foo.exe"], fileWithKnownId); }
public void TestSingleFeatureComponents() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "ApplicationFiles", Title = "Documentation", Description = "all the docs", Content = new Content { Include = @"Doc\*.*" } } } }; WixDocument wix = WixDocumentFor(parameters); WixFeature featureElement = wix.Features.AssertSingle(); Feature expectedFeature = parameters.Features[0]; WixAssert.AssertFeature(expectedFeature, featureElement); string componentRef = featureElement.ComponentReferences.AssertSingle(); WixComponent docComponent = wix.ResolveComponentReference(componentRef); WixAssert.AssertDirectoryComponent(DirectoryFromRoot("Doc"), docComponent); }
public void TestMultipleFeaturesReferencesFilesInCommonFolder() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "CHM_FILES", Title = "Documentation", Description = "Windows Help Files", Content = new Content { Include = @"Doc\*.chm" } }, new Feature { Id = "TXT_Files", Title = "Text Files", Description = "Text Files", Content = new Content { Include = @"Doc\*.TXT" } } } }; WixDocument wix = WixDocumentFor(parameters); wix.ResolveDirectoryByName("Doc").AssertSingle(); }
private XmlDocument RunScriptBuilderWith(WixBuilderParameters parameters) { var resultingDocument = new StringWriter(); new WixScriptBuilder(resultingDocument, root, parameters).Build(); return(LoadXml(resultingDocument.ToString())); }
private void InitializeFileIdMappings(WixBuilderParameters parameters) { foreach (KnownId ki in parameters.KnownIds) { _fileIdMapping.Add(Rebase(ki.Path), ki.Id); } }
public WixScriptBuilder(XmlWriter writer, IFolder basePath, WixBuilderParameters parameters) { parameters.Validate(); _writer = writer; _basePath = basePath; _parameters = parameters; InitializeFileIdMappings(parameters); }
public void TestCreateFolderIsInjectedInFoldersStoringOnlyShortcuts() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "Documentation", Title = "Documentation", Description = "all the docs", Content = new Content { Include = @"Doc\*.*" }, Shortcuts = new[] { new Shortcut { Name = "Foo documentation", Path = @"Doc/foo.chm" } } }, }, KnownIds = new[] { new KnownId { Id = "foo_help", Path = @"Doc/foo.chm" }, } }; var wixDocument = WixDocumentFor(parameters); var targetMenuFolder = wixDocument.ResolveDirectoryRef("TargetMenuFolder"); foreach (var shortcut in targetMenuFolder.Shortcuts) { WixComponent component = shortcut.ParentElement.ToWix <WixComponent>(); Assert.AreEqual(0, component.Files.Count()); Assert.AreEqual(1, component.SelectNodes("wix:CreateFolder").Count); AssertPerUserProfileComponentUsesRegistryKeyAsPath(component); } }
private static void RunWixScriptBuilder(string[] argv) { if (3 != argv.Length) { throw new ArgumentException("WixBuilder <src dir> <wix parameters file> <target file>"); } string srcDir = argv[0]; string parametersFile = argv[1]; string targetFile = argv[2]; using (StreamWriter stream = new StreamWriter(targetFile)) { WixScriptBuilder builder = new WixScriptBuilder(stream, srcDir, WixBuilderParameters.FromFile(parametersFile)); builder.Build(); } }
public void TestMultipleEmptyFolders() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "ApplicationFiles", Title = "Documentation", Description = "all the docs", Content = new Content { Include = @"native\**\*.*" } } } }; WixDocument wix = WixDocumentFor(parameters); WixFeature featureElement = wix.Features.AssertSingle(); Feature expectedFeature = parameters.Features[0]; WixAssert.AssertFeature(expectedFeature, featureElement); string componentRef = featureElement.ComponentReferences.AssertSingle(); WixComponent configComponent = wix.ResolveComponentReference(componentRef); WixAssert.AssertDirectoryComponent(DirectoryFromRoot("native/Db4objects.Db4o/Config"), configComponent); WixDirectory configDirectory = configComponent.ParentElement.ToWix <WixDirectory>(); Assert.AreEqual(DirectoryFromRoot("native/Db4objects.Db4o/Config").Name, configDirectory.Name); Assert.AreEqual(DirectoryFromRoot("native/Db4objects.Db4o").Name, configDirectory.ParentElement.ToWix <WixDirectory>().Name); Assert.AreEqual(DirectoryFromRoot("native").Name, configDirectory.ParentElement.ToWix <WixDirectory>().ParentElement.ToWix <WixDirectory>().Name); }
public void MissingFileForShortcut() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "Documentation", Title = "Documentation", Description = "all the docs", Content = new Content { Include = @"Doc\*.*" }, Shortcuts = new[] { new Shortcut { Name = "Foo documentation", Path = @"Doc/bar.chm" } } }, }, }; try { RunScriptBuilderWith(parameters); } catch (ArgumentException x) { Assert.AreEqual("Could not find file 'Doc/bar.chm' required by shortcut 'Foo documentation'", x.Message); } }
public void TestMultipleFeaturesReferencesFilesInCommonFolder() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "CHM_FILES", Title = "Documentation", Description = "Windows Help Files", Content = new Content { Include = @"Doc\*.chm" } }, new Feature { Id = "TXT_Files", Title = "Text Files", Description = "Text Files", Content = new Content { Include= @"Doc\*.TXT" } } } }; WixDocument wix = WixDocumentFor(parameters); wix.ResolveDirectoryByName("Doc").AssertSingle(); }
public WixScriptBuilder(TextWriter writer, string basePath, WixBuilderParameters parameters) : this(writer, NativeFileSystem.GetFolder(basePath), parameters) { }
public WixScriptBuilder(TextWriter writer, IFolder basePath, WixBuilderParameters parameters) : this(XmlTextWriterFor(writer), basePath, parameters) { }
public void TestShortcuts() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "Documentation", Title = "Documentation", Description = "all the docs", Content = new Content { Include = @"Doc\*.*" }, Shortcuts = new[] { new Shortcut { Name = "Foo documentation", Path = @"Doc/foo.chm" } } }, new Feature { Id = "SourceFiles", Title = "Source Files", Description = "all the source files", Content = new Content { Include = @"Src\*.*" }, Shortcuts = new[] { new Shortcut { Name = "Foo Project File", Path = @"Src/foo.booproj" } } }, new Feature { Id="ApplicationFiles", Title = "Visual Studio 2005 Plugin", Description = "Visual Studio 2005 Plugin", Content = new Content { Include=@"Bin\*.*" } } }, KnownIds = new[] { new KnownId { Id = "foo_help", Path = @"Doc/foo.chm" }, new KnownId { Id = "foo_project", Path = @"Src/foo.booproj" } } }; var wixDocument = WixDocumentFor(parameters); var targetMenuFolder = wixDocument.ResolveDirectoryRef("TargetMenuFolder"); var shortcutsByTarget = targetMenuFolder.Shortcuts.ToLookup(s => s.Target); var knownIdsByPath = parameters.KnownIds.ToLookup(ki => ki.Path); foreach (var feature in parameters.Features) { var wixFeature = wixDocument.FeatureById(feature.Id); foreach (var shortcut in feature.Shortcuts) { var shortcutId = knownIdsByPath[shortcut.Path].AssertSingle(); var shortcutTarget = "[#" + shortcutId.Id + "]"; var wixShortcut = shortcutsByTarget[shortcutTarget].AssertSingle(); var parentComponentId = wixShortcut.ParentElement.ToWix<WixComponent>().Id; Assert.IsTrue( wixFeature.ComponentReferences.Contains(parentComponentId), "Shortcut '" + shortcut.Name + "' is not referenced from feature '" + feature.Id + "'."); } } }
public void TestCreateFolderIsInjectedInFoldersStoringOnlyShortcuts() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "Documentation", Title = "Documentation", Description = "all the docs", Content = new Content { Include = @"Doc\*.*" }, Shortcuts = new[] { new Shortcut { Name = "Foo documentation", Path = @"Doc/foo.chm" } } }, }, KnownIds = new[] { new KnownId { Id = "foo_help", Path = @"Doc/foo.chm" }, } }; var wixDocument = WixDocumentFor(parameters); var targetMenuFolder = wixDocument.ResolveDirectoryRef("TargetMenuFolder"); foreach (var shortcut in targetMenuFolder.Shortcuts) { WixComponent component = shortcut.ParentElement.ToWix<WixComponent>(); Assert.AreEqual(0, component.Files.Count()); Assert.AreEqual(1, component.SelectNodes("wix:CreateFolder").Count); AssertPerUserProfileComponentUsesRegistryKeyAsPath(component); } }
private WixDocument WixDocumentFor(WixBuilderParameters parameters) { return RunScriptBuilderWith(parameters).DocumentElement.ToWix<WixDocument>(); }
private XmlDocument RunScriptBuilderWith(WixBuilderParameters parameters) { var resultingDocument = new StringWriter(); new WixScriptBuilder(resultingDocument, root, parameters).Build(); return LoadXml(resultingDocument.ToString()); }
private WixDocument WixDocumentFor(WixBuilderParameters parameters) { return(RunScriptBuilderWith(parameters).DocumentElement.ToWix <WixDocument>()); }
public void TestShortcuts() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "Documentation", Title = "Documentation", Description = "all the docs", Content = new Content { Include = @"Doc\*.*" }, Shortcuts = new[] { new Shortcut { Name = "Foo documentation", Path = @"Doc/foo.chm" } } }, new Feature { Id = "SourceFiles", Title = "Source Files", Description = "all the source files", Content = new Content { Include = @"Src\*.*" }, Shortcuts = new[] { new Shortcut { Name = "Foo Project File", Path = @"Src/foo.booproj" } } }, new Feature { Id = "ApplicationFiles", Title = "Visual Studio 2005 Plugin", Description = "Visual Studio 2005 Plugin", Content = new Content { Include = @"Bin\*.*" } } }, KnownIds = new[] { new KnownId { Id = "foo_help", Path = @"Doc/foo.chm" }, new KnownId { Id = "foo_project", Path = @"Src/foo.booproj" } } }; var wixDocument = WixDocumentFor(parameters); var targetMenuFolder = wixDocument.ResolveDirectoryRef("TargetMenuFolder"); var shortcutsByTarget = targetMenuFolder.Shortcuts.ToLookup(s => s.Target); var knownIdsByPath = parameters.KnownIds.ToLookup(ki => ki.Path); foreach (var feature in parameters.Features) { var wixFeature = wixDocument.FeatureById(feature.Id); foreach (var shortcut in feature.Shortcuts) { var shortcutId = knownIdsByPath[shortcut.Path].AssertSingle(); var shortcutTarget = "[#" + shortcutId.Id + "]"; var wixShortcut = shortcutsByTarget[shortcutTarget].AssertSingle(); var parentComponentId = wixShortcut.ParentElement.ToWix <WixComponent>().Id; Assert.IsTrue( wixFeature.ComponentReferences.Contains(parentComponentId), "Shortcut '" + shortcut.Name + "' is not referenced from feature '" + feature.Id + "'."); } } }
public void TestMultipleEmptyFolders() { var parameters = new WixBuilderParameters { Features = new[] { new Feature { Id = "ApplicationFiles", Title = "Documentation", Description = "all the docs", Content = new Content { Include = @"native\**\*.*" } } } }; WixDocument wix = WixDocumentFor(parameters); WixFeature featureElement = wix.Features.AssertSingle(); Feature expectedFeature = parameters.Features[0]; WixAssert.AssertFeature(expectedFeature, featureElement); string componentRef = featureElement.ComponentReferences.AssertSingle(); WixComponent configComponent = wix.ResolveComponentReference(componentRef); WixAssert.AssertDirectoryComponent(DirectoryFromRoot("native/Db4objects.Db4o/Config"), configComponent); WixDirectory configDirectory = configComponent.ParentElement.ToWix<WixDirectory>(); Assert.AreEqual(DirectoryFromRoot("native/Db4objects.Db4o/Config").Name, configDirectory.Name); Assert.AreEqual(DirectoryFromRoot("native/Db4objects.Db4o").Name, configDirectory.ParentElement.ToWix<WixDirectory>().Name); Assert.AreEqual(DirectoryFromRoot("native").Name, configDirectory.ParentElement.ToWix<WixDirectory>().ParentElement.ToWix<WixDirectory>().Name); }