Exemplo n.º 1
0
        public void InvalidOutputFileName()
        {
            string[] invalidFileNames = new string[] { "testfile>msi", "testfile<msi", "testfile?msi", "testfile|msi", "testfile*msi" };
            Dark dark;

            foreach (string invalidFileName in invalidFileNames)
            {
                dark = new Dark();
                dark.InputFile = Path.Combine(WixTests.SharedBaselinesDirectory, @"MSIs\BasicProduct.msi");
                dark.OutputFile = string.Empty;
                dark.OtherArguments = " -out " + invalidFileName;
                string expectedOutput = string.Format("Invalid file name specified on the command line: '{0}'. Error message: 'Illegal characters in path.'", invalidFileName);
                dark.ExpectedWixMessages.Add(new WixMessage(284, expectedOutput, WixMessage.MessageTypeEnum.Error));
                dark.ExpectedExitCode = 284;
                dark.Run();
            }

            // test for quotes
            dark = new Dark();
            dark.InputFile = Path.Combine(WixTests.SharedBaselinesDirectory, @"MSIs\BasicProduct.msi");
            dark.OutputFile = string.Empty;
            dark.OtherArguments = " -out testfile\\\"msi";
            string expectedOutput2 = string.Format("Your file or directory path '{0}' cannot contain a quote. Quotes are often accidentally introduced when trying to refer to a directory path with spaces in it, such as \"C:\\Out Directory\\\".  The correct representation for that path is: \"C:\\Out Directory\\\\\".", "testfile\"msi");
            dark.ExpectedWixMessages.Add(new WixMessage(117, expectedOutput2, WixMessage.MessageTypeEnum.Error));
            dark.ExpectedExitCode = 117;
            dark.Run();
        }
Exemplo n.º 2
0
        public void DisplayHelp()
        {
            Dark dark = new Dark();
            dark.Help = true;

            dark.ExpectedOutputStrings.Add("usage: dark.exe [-?] [-nologo] database.msi [source.wxs]");
            dark.ExpectedOutputStrings.Add("-ext <extension>  extension assembly or \"class, assembly\"");
            dark.ExpectedOutputStrings.Add("-nologo    skip printing dark logo information");
            dark.ExpectedOutputStrings.Add("-notidy    do not delete temporary files (useful for debugging)");
            dark.ExpectedOutputStrings.Add("-o[ut]     specify output file (default: write .wxs to current directory)");
            dark.ExpectedOutputStrings.Add("-sct       suppress decompiling custom tables");
            dark.ExpectedOutputStrings.Add("-sdet      suppress dropping empty tables (adds EnsureTable as appropriate)");
            dark.ExpectedOutputStrings.Add("-sras      suppress relative action sequencing");
            dark.ExpectedOutputStrings.Add("(use explicit sequence numbers)");
            dark.ExpectedOutputStrings.Add("-sui       suppress decompiling UI-related tables");
            dark.ExpectedOutputStrings.Add("-sw[N]     suppress all warnings or a specific message ID");
            dark.ExpectedOutputStrings.Add("(example: -sw1059 -sw1067)");
            dark.ExpectedOutputStrings.Add("-swall     suppress all warnings (deprecated)");
            dark.ExpectedOutputStrings.Add("-v         verbose output");
            dark.ExpectedOutputStrings.Add("-wx[N]     treat all warnings or a specific message ID as an error");
            dark.ExpectedOutputStrings.Add("(example: -wx1059 -wx1067)");
            dark.ExpectedOutputStrings.Add("-wxall     treat all warnings as errors (deprecated)");
            dark.ExpectedOutputStrings.Add("-x <path>  export binaries from cabinets and embedded binaries to <path>");
            dark.ExpectedOutputStrings.Add("-xo        output wixout instead of WiX source code");
            dark.ExpectedOutputStrings.Add("(mandatory for transforms and patches)");
            dark.ExpectedOutputStrings.Add("-? | -help this help information");
            dark.ExpectedOutputStrings.Add("Environment variables:");
            dark.ExpectedOutputStrings.Add("WIX_TEMP   overrides the temporary directory used for cab extraction, binary extraction, ...");
            dark.ExpectedOutputStrings.Add("For more information see: http://wix.sourceforge.net");

            dark.Run();
        }
Exemplo n.º 3
0
 public void MissingBinaryPath()
 {
     Dark dark = new Dark();
     dark.InputFile = Path.Combine(WixTests.SharedBaselinesDirectory, @"MSIs\BasicProduct.msi");
     dark.OtherArguments = " -x";
     dark.ExpectedWixMessages.Add(new WixMessage(280,String.Concat("The -x option requires a directory, but the provided path is a file: ", dark.InputFile), WixMessage.MessageTypeEnum.Error));
     dark.ExpectedExitCode = 280;
     dark.Run();
 }
Exemplo n.º 4
0
 public void MissingExtension()
 {
     Dark dark = new Dark();
     dark.InputFile = Path.Combine(WixTests.SharedBaselinesDirectory, @"MSIs\BasicProduct.msi");
     dark.Extensions.Add(string.Empty);
     dark.ExpectedWixMessages.Add(new WixMessage(113, "The parameter '-ext' must be followed by the extension's type specification.  The type specification should be a fully qualified class and assembly identity, for example: \"MyNamespace.MyClass,myextension.dll\".", WixMessage.MessageTypeEnum.Error));
     dark.ExpectedExitCode = 113;
     dark.Run();
 }
Exemplo n.º 5
0
 public void InvalidExtension()
 {
     Dark dark = new Dark();
     dark.InputFile = Path.Combine(WixTests.SharedBaselinesDirectory, @"MSIs\BasicProduct.msi");
     dark.Extensions.Add(WixTests.BasicProductWxs);
     dark.ExpectedWixMessages.Add(new WixMessage(144, string.Format("The extension '{0}' could not be loaded because of the following reason: Could not load file or assembly 'file:///{1}\\test\\data\\SharedData\\Authoring\\BasicProduct.wxs' or one of its dependencies. The module was expected to contain an assembly manifest.", WixTests.BasicProductWxs,Environment .GetEnvironmentVariable("WIX_ROOT")), WixMessage.MessageTypeEnum.Error));
     dark.ExpectedExitCode = 144;
     dark.Run();
 }
Exemplo n.º 6
0
        public void SimpleBinary()
        {
            string msi = Builder.BuildPackage(Path.Combine(BinaryTests.TestDataDirectory, @"SimpleBinary\product.wxs"));
            Verifier.VerifyResults(Path.Combine(BinaryTests.TestDataDirectory, @"SimpleBinary\expected.msi"), msi, "Binary");

            string binaryPathDirectory = Utilities.FileUtilities.GetUniqueFileName();
            Directory.CreateDirectory(binaryPathDirectory);

            Dark dark = new Dark();
            dark.InputFile = msi;
            dark.OutputFile = "decompiled.wxs";
            dark.BinaryPath = binaryPathDirectory;
            dark.Run();
        }
Exemplo n.º 7
0
        public void InvalidOutputFile()
        {
            // make sure we have an existing file with the same name of dark output directory
            string invalidDirectoryName = Path.Combine(Environment.CurrentDirectory,"file.txt");
            System.IO.File.Create(invalidDirectoryName);

            Dark dark = new Dark();
            dark.InputFile = Path.Combine(WixTests.SharedBaselinesDirectory, @"MSIs\BasicProduct.msi");
            dark.OutputFile = Path.Combine(invalidDirectoryName,"output.wxs");
            string expectedErrorMessage = string.Format("Error writing to the path: '{0}'. Error message: 'Cannot create \"{1}\" because a file or directory with the same name already exists.'", dark.OutputFile, invalidDirectoryName);
            dark.ExpectedWixMessages.Add(new WixMessage(283, expectedErrorMessage, WixMessage.MessageTypeEnum.Error));
            dark.ExpectedExitCode = 283;
            dark.Run();
        }
        public static string Decompile(
            string inputFile,
            string binaryPath = null,
            WixMessage[] expectedWixMessages = null,
            string[] extensions                  = null,
            bool noTidy                          = false,
            bool noLogo                          = false,
            string otherArguments                = null,
            bool setOutputFileIfNotSpecified     = true,
            bool suppressDroppingEmptyTables     = false,
            bool suppressRelativeActionSequences = false,
            bool suppressUITables                = false,
            int[] suppressWarnings               = null,
            bool treatWarningsAsErrors           = false,
            bool verbose                         = false,
            bool xmlOutput                       = false)
        {
            Dark dark = new Dark();

            // set the passed arrguments
            dark.InputFile  = inputFile;
            dark.BinaryPath = binaryPath;
            if (null != expectedWixMessages)
            {
                dark.ExpectedWixMessages.AddRange(expectedWixMessages);
            }
            if (null != extensions)
            {
                dark.Extensions.AddRange(extensions);
            }
            dark.NoTidy         = noTidy;
            dark.NoLogo         = noLogo;
            dark.OtherArguments = otherArguments;
            dark.SetOutputFileIfNotSpecified     = setOutputFileIfNotSpecified;
            dark.SuppressDroppingEmptyTables     = suppressDroppingEmptyTables;
            dark.SuppressRelativeActionSequences = suppressRelativeActionSequences;
            dark.SuppressUITables = suppressUITables;
            if (null != suppressWarnings)
            {
                dark.SuppressWarnings.AddRange(suppressWarnings);
            }
            dark.TreatWarningsAsErrors = treatWarningsAsErrors;
            dark.Verbose   = verbose;
            dark.XmlOutput = xmlOutput;

            dark.Run();

            return(dark.OutputFile);
        }
Exemplo n.º 9
0
        public static string Decompile(
            string inputFile,
            string binaryPath = null,
            WixMessage[] expectedWixMessages = null,
            string[] extensions = null,
            bool noTidy = false,
            bool noLogo = false,
            string otherArguments = null,
            bool setOutputFileIfNotSpecified = true,
            bool suppressDroppingEmptyTables = false,
            bool suppressRelativeActionSequences = false,
            bool suppressUITables = false,
            int[] suppressWarnings = null,
            bool treatWarningsAsErrors = false,
            bool verbose = false,
            bool xmlOutput = false)
        {
            Dark dark = new Dark();

            // set the passed arrguments
            dark.InputFile = inputFile;
            dark.BinaryPath = binaryPath;
            if (null != expectedWixMessages)
            {
                dark.ExpectedWixMessages.AddRange(expectedWixMessages);
            }
            if (null != extensions)
            {
                dark.Extensions.AddRange(extensions);
            }
            dark.NoTidy = noTidy;
            dark.NoLogo = noLogo;
            dark.OtherArguments = otherArguments;
            dark.SetOutputFileIfNotSpecified = setOutputFileIfNotSpecified;
            dark.SuppressDroppingEmptyTables = suppressDroppingEmptyTables;
            dark.SuppressRelativeActionSequences = suppressRelativeActionSequences;
            dark.SuppressUITables = suppressUITables;
            if (null != suppressWarnings)
            {
                dark.SuppressWarnings.AddRange(suppressWarnings);
            }
            dark.TreatWarningsAsErrors = treatWarningsAsErrors;
            dark.Verbose = verbose;
            dark.XmlOutput = xmlOutput;

            dark.Run();

            return dark.OutputFile;
        }
Exemplo n.º 10
0
        public void ExportBinariesToReadOnlyPath()
        {
            // Create a directory in temporary directory and set its property to read only
            DirectoryInfo binaryDirectory = Directory.CreateDirectory(Path.Combine(Path.GetTempPath(), "ReadOnlyDirectory"));
            System.Security.AccessControl.DirectorySecurity binaryDirectorySecurity = new System.Security.AccessControl.DirectorySecurity();
            binaryDirectorySecurity.AddAccessRule(new System.Security.AccessControl.FileSystemAccessRule("everyone", System.Security.AccessControl.FileSystemRights.CreateDirectories, System.Security.AccessControl.AccessControlType.Deny));
            Directory.SetAccessControl(binaryDirectory.FullName, binaryDirectorySecurity);

            Dark dark = new Dark();
            dark.InputFile = Builder.BuildPackage(Path.Combine(BinaryPathTests.TestDataDirectory, @"Product.wxs"));
            dark.BinaryPath = binaryDirectory.FullName;
            dark.ExpectedExitCode = 1;
            dark.ExpectedWixMessages.Add(new WixMessage(1, string.Format("Access to the path '{0}' is denied.", Path.Combine(dark.BinaryPath, "Binary")), WixMessage.MessageTypeEnum.Error));
            dark.Run();
        }
Exemplo n.º 11
0
        public void InvalidArgument()
        {
            Dark dark = new Dark();
            dark.InputFile = Path.Combine(WixTests.SharedBaselinesDirectory, @"MSIs\BasicProduct.msi");
            dark.OtherArguments = " -abc ";
            dark.ExpectedWixMessages.Add(new WixMessage(1098, "'abc' is not a valid command line argument.", WixMessage.MessageTypeEnum.Warning));
            dark.Run();

            // uppercase version of valid command arrguments
            dark = new Dark();
            dark.InputFile = Path.Combine(WixTests.SharedBaselinesDirectory, @"MSIs\BasicProduct.msi");
            dark.OtherArguments = " -SW1098 ";
            dark.ExpectedWixMessages.Add(new WixMessage(1098, "'SW1098' is not a valid command line argument.", WixMessage.MessageTypeEnum.Warning));
            dark.Run();
        }
Exemplo n.º 12
0
        /// <summary>
        /// Build bootstrapper packages for bundle input
        /// </summary>
        /// <param name="outputDirectory">The output directory for Candle and Light</param>
        /// <param name="sourceFile">The .wxs files to compile</param>
        /// <param name="extractEmbeddedResourcesToOutputDirectory">If true, extract embeded resources and copy them to output directory</param>
        /// <returns>The path to the output .exe file</returns>
        public static string BuildBundlePackage(string outputDirectory, string sourceFile, string[] wixExtensions, string otherCandleArguments, string otherLightArguments, bool extractEmbeddedResourcesToOutputDirectory)
        {
            string outputFileName = String.Concat(Path.GetFileNameWithoutExtension(sourceFile), ".exe");

            otherLightArguments = string.IsNullOrEmpty(otherLightArguments) ? " -notidy " : otherLightArguments + " -notidy ";

            string extensionArguments = string.Empty;

            if (null != wixExtensions)
            {
                foreach (string wixExtension in wixExtensions)
                {
                    extensionArguments += string.Format(" -ext {0} ", wixExtension);
                }
            }
            otherCandleArguments += extensionArguments;
            otherLightArguments  += extensionArguments;

            // build package
            string bootstrapper = Builder.BuildPackage(outputDirectory, sourceFile, outputFileName, otherCandleArguments, otherLightArguments);

            // copy all the resulting files to the output directory
            if (extractEmbeddedResourcesToOutputDirectory)
            {
                if (!File.Exists(bootstrapper))
                {
                    throw new ApplicationException(string.Format("Bootrapper file '{0}' was not created as expected.", bootstrapper));
                }

                // call dark.exe to extract the package contents to the output folder
                Dark dark = new Dark(outputDirectory);
                dark.InputFile  = bootstrapper;
                dark.BinaryPath = outputDirectory;
                dark.Run();
            }

            return(bootstrapper);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Build bootstrapper packages for bundle input
        /// </summary>
        /// <param name="outputDirectory">The output directory for Candle and Light</param>
        /// <param name="sourceFile">The .wxs files to compile</param>
        /// <param name="extractEmbeddedResourcesToOutputDirectory">If true, extract embeded resources and copy them to output directory</param>
        /// <returns>The path to the output .exe file</returns>
        public static string BuildBundlePackage(string outputDirectory, string sourceFile, string[] wixExtensions, string otherCandleArguments, string otherLightArguments, bool extractEmbeddedResourcesToOutputDirectory)
        {
            string outputFileName = String.Concat(Path.GetFileNameWithoutExtension(sourceFile), ".exe");
            otherLightArguments = string.IsNullOrEmpty(otherLightArguments) ? " -notidy " : otherLightArguments + " -notidy ";

            string extensionArguments = string.Empty;
            if (null != wixExtensions)
            {
                foreach (string wixExtension in wixExtensions)
                {
                    extensionArguments += string.Format(" -ext {0} ", wixExtension);
                }
            }
            otherCandleArguments += extensionArguments;
            otherLightArguments += extensionArguments;

            // build package
            string bootstrapper = Builder.BuildPackage(outputDirectory, sourceFile, outputFileName, otherCandleArguments, otherLightArguments);

            // copy all the resulting files to the output directory
            if (extractEmbeddedResourcesToOutputDirectory)
            {
                if (!File.Exists(bootstrapper))
                {
                    throw new ApplicationException(string.Format("Bootrapper file '{0}' was not created as expected.", bootstrapper));
                }

                // call dark.exe to extract the package contents to the output folder
                Dark dark = new Dark(outputDirectory);
                dark.InputFile = bootstrapper;
                dark.BinaryPath = outputDirectory;
                dark.Run();
            }

            return bootstrapper;
        }