Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        private XmlDocument RunScriptBuilderWith(WixBuilderParameters parameters)
        {
            var resultingDocument = new StringWriter();

            new WixScriptBuilder(resultingDocument, root, parameters).Build();
            return(LoadXml(resultingDocument.ToString()));
        }
Ejemplo n.º 5
0
	private void InitializeFileIdMappings(WixBuilderParameters parameters)
	{
		foreach (KnownId ki in parameters.KnownIds)
		{
			_fileIdMapping.Add(Rebase(ki.Path), ki.Id);
		}
	}
Ejemplo n.º 6
0
 private void InitializeFileIdMappings(WixBuilderParameters parameters)
 {
     foreach (KnownId ki in parameters.KnownIds)
     {
         _fileIdMapping.Add(Rebase(ki.Path), ki.Id);
     }
 }
Ejemplo n.º 7
0
	public WixScriptBuilder(XmlWriter writer, IFolder basePath, WixBuilderParameters parameters)
	{
		parameters.Validate();
		_writer = writer;
		_basePath = basePath;
		_parameters = parameters;
		InitializeFileIdMappings(parameters);
	}
Ejemplo n.º 8
0
 public WixScriptBuilder(XmlWriter writer, IFolder basePath, WixBuilderParameters parameters)
 {
     parameters.Validate();
     _writer     = writer;
     _basePath   = basePath;
     _parameters = parameters;
     InitializeFileIdMappings(parameters);
 }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
0
    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();
        }
    }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
            }
        }
Ejemplo n.º 13
0
		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();
		}
Ejemplo n.º 14
0
		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);
		}
Ejemplo n.º 15
0
 public WixScriptBuilder(TextWriter writer, string basePath, WixBuilderParameters parameters) : this(writer, NativeFileSystem.GetFolder(basePath), parameters)
 {
 }
Ejemplo n.º 16
0
 public WixScriptBuilder(TextWriter writer, IFolder basePath, WixBuilderParameters parameters)
     : this(XmlTextWriterFor(writer), basePath, parameters)
 {
 }
Ejemplo n.º 17
0
		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 + "'.");
				}
			}
		}
Ejemplo n.º 18
0
		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);
			}
		}
Ejemplo n.º 19
0
	public WixScriptBuilder(TextWriter writer, string basePath, WixBuilderParameters parameters) : this(writer, NativeFileSystem.GetFolder(basePath), parameters)
	{
	}
Ejemplo n.º 20
0
	public WixScriptBuilder(TextWriter writer, IFolder basePath, WixBuilderParameters parameters)
		: this(XmlTextWriterFor(writer), basePath, parameters)
	{
	}
Ejemplo n.º 21
0
		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);
			}
		}
Ejemplo n.º 22
0
		private WixDocument WixDocumentFor(WixBuilderParameters parameters)
		{
			return RunScriptBuilderWith(parameters).DocumentElement.ToWix<WixDocument>();
		}
Ejemplo n.º 23
0
		private XmlDocument RunScriptBuilderWith(WixBuilderParameters parameters)
		{
			var resultingDocument = new StringWriter();
			new WixScriptBuilder(resultingDocument, root, parameters).Build();
			return LoadXml(resultingDocument.ToString());
		}
Ejemplo n.º 24
0
 private WixDocument WixDocumentFor(WixBuilderParameters parameters)
 {
     return(RunScriptBuilderWith(parameters).DocumentElement.ToWix <WixDocument>());
 }
Ejemplo n.º 25
0
        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 + "'.");
                }
            }
        }
Ejemplo n.º 26
0
        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);

        }
Ejemplo n.º 27
0
		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);
		}