// bug: https://sourceforge.net/tracker/?func=detail&aid=2824407&group_id=105970&atid=642714
        public void FileShare_ExistingShare()
        {
            string sourceFile = Path.Combine(FileShareTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            // create the share
            string testFolderPath         = Path.Combine(@"\\" + System.Environment.MachineName, "TestShareName");
            string testForderPhysicalPath = Utilities.FileUtilities.GetUniqueFileName();

            Directory.CreateDirectory(testForderPhysicalPath);
            FileUtilities.CreateShare(testForderPhysicalPath, "TestShareName");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify Fileshare still Exists.
            Assert.True(Directory.Exists(testFolderPath), String.Format("Share '{0}' was not created on Install.", testFolderPath));

            // Verify Fileshare Permissions.
            PermissionsVerifier.VerifySharePermession(Environment.GetEnvironmentVariable("tempdomain") + "\\ddrelqa1", testFolderPath, PermissionsVerifier.ACCESS_MASK.READ_CONTROL | PermissionsVerifier.ACCESS_MASK.WRITE_DAC | PermissionsVerifier.ACCESS_MASK.WRITE_OWNER | PermissionsVerifier.ACCESS_MASK.DELETE);
            PermissionsVerifier.VerifySharePermession(Environment.GetEnvironmentVariable("tempdomain") + "\\ddrelqa2", testFolderPath, PermissionsVerifier.ACCESS_MASK.READ_CONTROL);

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify Fileshare is removed.
            Assert.False(Directory.Exists(testFolderPath), String.Format("Share '{0}' was not removed on Uninstall.", testFolderPath));
        }
Exemple #2
0
        public void XmlFile_ExistingFile()
        {
            string sourceFile = Path.Combine(XmlFileTests.TestDataDirectory, @"product.wxs");
            string targetFile = Utilities.FileUtilities.GetUniqueFileName();

            // Create new test.xml file to be used.
            File.Copy(Path.Combine(XmlFileTests.TestDataDirectory, @"test.xml"), targetFile, true);
            FileInfo file = new FileInfo(targetFile);

            if (file.IsReadOnly)
            {
                file.IsReadOnly = false;
            }

            // build the msi and pass targetfile as a param to the .wxs file
            string msiFile = Builder.BuildPackage(Environment.CurrentDirectory, sourceFile, "test.msi", string.Format("-dTargetFile=\"{0}\" -ext WixUtilExtension", targetFile), "-ext WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify XML File Transformation.
            VerifyXMLFileTransformation(targetFile);

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify that the file was removed
            Assert.True(File.Exists(targetFile), String.Format("XMLFile '{0}' was removed on Uninstall.", targetFile));

            // Verify that the changes were reverted except for permenant changes
            XMLVerifier.VerifyXMLFile(targetFile, Path.Combine(XmlFileTests.TestDataDirectory, @"expected.xml"));
        }
        public void WixInternetShortcut_Install_64bit()
        {
            string sourceFile = Path.Combine(WixInternetShortcutTests.TestDataDirectory, @"product_64.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            string link1Location = Path.Combine(Environment.ExpandEnvironmentVariables(@"%ProgramW6432%\WiX Sample"), "notepad.lnk");
            string link1Target   = Environment.ExpandEnvironmentVariables(@"%SystemDrive%\Windows\System32\notepad.exe");
            string link2Location = Path.Combine(Environment.ExpandEnvironmentVariables(@"%ProgramW6432%\WiX Sample"), "notepad2.url");
            string link2Target   = Environment.ExpandEnvironmentVariables("file:///%SystemDrive%/Windows/system32/notepad.exe");

            // Verify that the Internet short cuts were created
            Assert.True(WixInternetShortcutTests.InterNetShortCutExists(link1Location), String.Format("Shortcut '{0}' was not created on Install.", link1Location));
            Assert.True(WixInternetShortcutTests.InterNetShortCutExists(link2Location), String.Format("Shortcut '{0}' was not created on Install.", link2Location));

            // verify the shortcuts have the right targets
            WixInternetShortcutTests.VerifyInterNetShortCutTarget(link1Location, link1Target, LinkType.Link);
            WixInternetShortcutTests.VerifyInterNetShortCutTarget(link2Location, link2Target, LinkType.URL);

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify that the Internet short cuts were removed
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link1Location), String.Format("Shortcut '{0}' was not removed on Uninstall.", link1Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link2Location), String.Format("Shortcut '{0}' was not removed on Uninstall.", link2Location));
        }
        public void WixInternetShortcut_InstallFailure()
        {
            string sourceFile = Path.Combine(WixInternetShortcutTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            string desktopPath     = string.Format(@"{0}\Users\Public\Desktop", Environment.ExpandEnvironmentVariables(@"%SystemDrive%"));
            string secretLinksPath = string.Format(@"{0}\WiX Sample\Secret Links", Environment.ExpandEnvironmentVariables(@"%ProgramFiles%"));
            string programMenuPath = string.Format(@"{0}\ProgramData\Microsoft\Windows\Start Menu\Programs", Environment.ExpandEnvironmentVariables(@"%SystemDrive%"));

            string link1Location  = Path.Combine(desktopPath, "Joy of Setup.lnk");
            string link2Location  = Path.Combine(secretLinksPath, "InternetShortcuts announcement.lnk");
            string link3Location  = Path.Combine(programMenuPath, "Aaron Stebner WebLog.lnk");
            string link4Location  = Path.Combine(programMenuPath, "Heath Stewart's Blog.lnk");
            string link5Location  = Path.Combine(programMenuPath, "Peter Marcu's Blog.lnk");
            string link6Location  = Path.Combine(programMenuPath, "Rob Mensching Openly Uninstalled.lnk");
            string link7Location  = Path.Combine(programMenuPath, "Setup Sense and Sensibility.lnk");
            string link8Location  = Path.Combine(programMenuPath, "votive, wix, vsip, and all things microsoft.lnk");
            string link9Location  = Path.Combine(programMenuPath, "Windows Installer Team Blog.url");
            string link10Location = Path.Combine(programMenuPath, "ARP.url");

            // Verify that the Internet short cuts were removed
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link1Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link1Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link2Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link2Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link3Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link3Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link4Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link4Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link5Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link5Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link6Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link6Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link7Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link7Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link8Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link8Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link9Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link9Location));
            Assert.False(WixInternetShortcutTests.InterNetShortCutExists(link10Location), String.Format("Shortcut '{0}' was not removed on Rollback.", link10Location));
        }
        public void CAQuietExec_Install()
        {
            string sourceFile = Path.Combine(CAQuietExecTests.TestDataDirectory, @"product.wxs");

            string immediateFileName       = Path.Combine(Path.GetTempPath(), "ImmediateCommand.cmd");
            string immediateOutputFileName = Path.Combine(Path.GetTempPath(), "immediate.txt");

            string deferredFileName       = Path.Combine(Path.GetTempPath(), "DeferredCommand.cmd");
            string deferredOutputFileName = Path.Combine(Path.GetTempPath(), "deferred.txt");

            File.Copy(Path.Combine(CAQuietExecTests.TestDataDirectory, @"ImmediateCommand.cmd"), immediateFileName, true);
            File.Copy(Path.Combine(CAQuietExecTests.TestDataDirectory, @"DeferredCommand.cmd"), deferredFileName, true);

            if (File.Exists(immediateOutputFileName))
            {
                File.Delete(immediateOutputFileName);
            }
            if (File.Exists(deferredOutputFileName))
            {
                File.Delete(deferredOutputFileName);
            }

            string msiFile = Builder.BuildPackage(Environment.CurrentDirectory, sourceFile, "test.msi", string.Format("-dimmediate={0} -ddeferred={1} -ext WixUtilExtension", immediateFileName, deferredFileName), "-ext WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.True(File.Exists(immediateOutputFileName), String.Format("Immediate Command was not executed. File '{0}' does not exist.", immediateOutputFileName));
            Assert.True(File.Exists(deferredOutputFileName), String.Format("Deferred Command was not executed. File '{0}' does not exist.", deferredOutputFileName));

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);
        }
        public void FileShare_Install_64bit()
        {
            string sourceFile = Path.Combine(FileShareTests.TestDataDirectory, @"product_64.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify Directory Exists.
            string physicalTestFolderPath = Path.Combine(Environment.ExpandEnvironmentVariables(@"%ProgramW6432%"), @"WixTestFolder");

            Assert.True(Directory.Exists(physicalTestFolderPath), String.Format("Test folder '{0}' was not created on Install.", physicalTestFolderPath));

            // Verify Fileshare Exists.
            string testFolderPath = Path.Combine(@"\\" + System.Environment.MachineName, "TestShareName");

            Assert.True(Directory.Exists(testFolderPath), String.Format("Share '{0}' was not created on Install.", testFolderPath));

            // Verify Fileshare Permissions.
            PermissionsVerifier.VerifySharePermession(Environment.GetEnvironmentVariable("tempdomain") + "\\ddrelqa1", testFolderPath, PermissionsVerifier.ACCESS_MASK.READ_CONTROL | PermissionsVerifier.ACCESS_MASK.WRITE_DAC | PermissionsVerifier.ACCESS_MASK.WRITE_OWNER | PermissionsVerifier.ACCESS_MASK.DELETE);
            PermissionsVerifier.VerifySharePermession(Environment.GetEnvironmentVariable("tempdomain") + "\\ddrelqa2", testFolderPath, PermissionsVerifier.ACCESS_MASK.READ_CONTROL);

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify Fileshare is removed.
            Assert.False(Directory.Exists(testFolderPath), String.Format("Share '{0}' was not removed on Uninstall.", testFolderPath));
        }
        public void SqlString_ReInstall()
        {
            string sourceFile = Path.Combine(SqlStringTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixSqlExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.IsTrue(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15"), "Database '{0}' was not created on Install", "BlankDB15");
            Assert.IsTrue(SqlVerifier.TableExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15", "TestTable1"), "Table '{0}:{1}' was not created on Install", "BlankDB15", "TestTable1");

            // insert a record in the new database
            string sqlInsertString = "INSERT INTO TestTable1(name, value) Values('test', 'nooverwrite')";

            SqlVerifier.ExecuteSQlCommand(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15", sqlInsertString);

            string sqlqueryString = "Select * from TestTable1 where name ='test' and value ='nooverwrite'";

            Assert.IsTrue(SqlVerifier.SqlObjectExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15", sqlqueryString), "Query '{0}' Results were not created on Install", sqlqueryString);

            MSIExec.RepairProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // verify the change is still in the database
            Assert.IsTrue(SqlVerifier.SqlObjectExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB15", sqlqueryString), "Query '{0}' Results were not created on Install", sqlqueryString);

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            SqlStringTests.DropDatabase("BlankDB10");
        }
        public void SqlString_Install()
        {
            string sourceFile = Path.Combine(SqlStringTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixSqlExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.IsTrue(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB10"), "Database '{0}' was not created on Install", "BlankDB10");
            Assert.IsTrue(SqlVerifier.TableExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "ScottDB22", "TestTable1"), "Table '{0}:{1}' was not created on Install", "ScottDB22", "TestTable1");
            Assert.IsTrue(SqlVerifier.TableExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB10", "TestTable2"), "Table '{0}:{1}' was not created on Install", "BlankDB10", "TestTable2");
            string sqlQuery = "Select * from TestTable2 where name ='FIRST' and value ='Kurtzeborn'";

            Assert.IsTrue(SqlVerifier.SqlObjectExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB10", sqlQuery), "Query '{0}' Results were not created on Install", sqlQuery);


            // Verify The Database BlankDB4 was not created
            Assert.IsFalse(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB44"), "Database '{0}' was created on Install", "BlankDB44");

            MSIExec.RepairProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify The Database was added
            Assert.IsTrue(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB44"), "Database '{0}' was Not created on Repair", "BlankDB44");

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.IsTrue(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB10"), "Database '{0}' was dropped on Uninstall", "BlankDB10");

            Assert.IsFalse(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB44"), "Database '{0}' was not dropped on Uninstall", "BlankDB44");

            SqlStringTests.DropDatabase("BlankDB10");
        }
Exemple #9
0
        public void PermissionEx_Install()
        {
            string sourceFile = Path.Combine(PermissionExTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify File Permessions
            string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"WixTestFolder\MynewService.exe");

            PermissionsVerifier.VerifyFilePermession(@"BUILTIN\Guests", fileName, FileSystemRights.FullControl);
            PermissionsVerifier.VerifyFilePermession(@"Everyone", fileName, FileSystemRights.FullControl);
            PermissionsVerifier.VerifyFilePermession(@"NT AUTHORITY\LOCAL SERVICE", fileName, FileSystemRights.FullControl);

            // Verify Folder Permessions
            string folderName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"WixTestFolder\Create Folder");

            PermissionsVerifier.VerifyFolderPermession(@"Everyone", folderName, FileSystemRights.ReadAttributes | FileSystemRights.WriteAttributes | FileSystemRights.ChangePermissions | FileSystemRights.Synchronize);
            PermissionsVerifier.VerifyFolderPermession(@"BUILTIN\Guests", folderName, FileSystemRights.ReadAttributes);

            // Verify Registry Permessions
            PermissionsVerifier.VerifyRegistryKeyPermission(@"BUILTIN\Guests", Microsoft.Win32.Registry.LocalMachine, @"SOFTWARE\Microsoft\Office\Delivery\MynewService", RegistryRights.QueryValues | RegistryRights.SetValue | RegistryRights.CreateSubKey | RegistryRights.EnumerateSubKeys | RegistryRights.Notify | RegistryRights.CreateLink);

            // Verify Service Permessions
            // TODO: Check for Service permissions

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);
        }
        public void XmlConfig_InstallFailure()
        {
            string sourceFile = Path.Combine(XmlConfigTests.TestDataDirectory, @"product_fail.wxs");
            string targetFile = Utilities.FileUtilities.GetUniqueFileName();

            // Create new test.xml file to be used.
            File.Copy(Path.Combine(XmlConfigTests.TestDataDirectory, @"test.xml"), targetFile, true);
            FileInfo file = new FileInfo(targetFile);

            if (file.IsReadOnly)
            {
                file.IsReadOnly = false;
            }

            // build the msi and pass targetfile as a param to the .wxs file
            string msiFile = Builder.BuildPackage(Environment.CurrentDirectory, sourceFile, "test.msi", string.Format("-dTargetFile=\"{0}\" -ext WixUtilExtension", targetFile), "-ext WixUtilExtension -sice:ICE03");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            // Verify that the file was removed
            Assert.True(File.Exists(targetFile), string.Format("XML file '{0}' was removed on Rollback.", targetFile));

            // Verify XML File has not changed.
            XMLVerifier.VerifyXMLFile(targetFile, Path.Combine(XmlConfigTests.TestDataDirectory, @"test.xml"));
        }
        public void User_Repair()
        {
            string sourceFile = Path.Combine(UserTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            UserVerifier.DeleteLocalUser("testName1");
            UserVerifier.SetUserInformation(string.Empty, "testName2", true, false, false);

            MSIExec.RepairProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Validate New User Information.
            UserVerifier.VerifyUserInformation(string.Empty, "testName1", true, false, false);
            UserVerifier.VerifyUserIsMemberOf(string.Empty, "testName1", "Administrators", "Power Users");

            UserVerifier.VerifyUserInformation(string.Empty, "testName2", true, true, true);
            UserVerifier.VerifyUserIsMemberOf(string.Empty, "testName2", "Power Users");

            UserVerifier.VerifyUserIsMemberOf(Environment.GetEnvironmentVariable("tempdomain"), Environment.GetEnvironmentVariable("tempusername"), "Power Users");

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify Users marked as RemoveOnUninstall were removed.
            Assert.IsFalse(UserVerifier.UserExists(string.Empty, "testName1"), "User '{0}' was not removed on Uninstall", "testName1");
            Assert.IsTrue(UserVerifier.UserExists(string.Empty, "testName2"), "User '{0}' was removed on Uninstall", "testName2");

            // clean up
            UserVerifier.DeleteLocalUser("testName2");

            UserVerifier.VerifyUserIsNotMemberOf(Environment.GetEnvironmentVariable("tempdomain"), Environment.GetEnvironmentVariable("tempusername"), "Power Users");
        }
Exemple #12
0
        public void IISWebPropertyLogInUTF8_Install()
        {
            string sourceFile = Path.Combine(IISWebPropertyTests.TestDataDirectory, @"product_LogInUTF8.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixIIsExtension");

            // get original value for the property
            bool originalEtagPropertyValue = (bool)IISVerifier.GetMetaBasePropertyValue("LogInUTF8");

            // Install  Msi
            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify Etag property was set correctelly on install
            bool acctualEtagPropertyValue  = (bool)IISVerifier.GetMetaBasePropertyValue("LogInUTF8");
            bool expectedEtagPropertyValue = true;

            Assert.True(acctualEtagPropertyValue == expectedEtagPropertyValue, String.Format("LogInUTF8 Property value does not meat expected. Acctual: '{0}'. Expected: '{1}'.", acctualEtagPropertyValue, expectedEtagPropertyValue));

            // UnInstall Msi
            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify WebDir was removed
            acctualEtagPropertyValue  = (bool)IISVerifier.GetMetaBasePropertyValue("LogInUTF8");
            expectedEtagPropertyValue = originalEtagPropertyValue;
            Assert.True(acctualEtagPropertyValue == expectedEtagPropertyValue, String.Format("LogInUTF8 Property value does not meat expected. Acctual: '{0}'. Expected: '{1}'.", acctualEtagPropertyValue, expectedEtagPropertyValue));
        }
        public void User_NonVitalUserGroup()
        {
            string sourceFile = Path.Combine(UserTests.TestDataDirectory, @"NonVitalUserGroup.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);
        }
        public void ServiceConfig_Repair()
        {
            string sourceFile = Path.Combine(ServiceConfigTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Change the service details
            ServiceFailureActionType[] expectedFailureActions = new ServiceFailureActionType[] { ServiceFailureActionType.RestartService, ServiceFailureActionType.RestartService, ServiceFailureActionType.RestartService };
            ServiceVerifier.SetServiceInformation("MynewService", 4, expectedFailureActions);

            MSIExec.RepairProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Validate Existing Service Information.
            expectedFailureActions = new ServiceFailureActionType[] { ServiceFailureActionType.RestartService, ServiceFailureActionType.RebootComputer, ServiceFailureActionType.None };
            ServiceVerifier.VerifyServiceInformation("W32Time", 1, expectedFailureActions);

            // Validate New Service Information.
            expectedFailureActions = new ServiceFailureActionType[] { ServiceFailureActionType.RebootComputer, ServiceFailureActionType.RestartService, ServiceFailureActionType.None };
            ServiceVerifier.VerifyServiceInformation("MynewService", 3, expectedFailureActions);

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Validate New Service Does NOT exist any more.
            Assert.False(ServiceVerifier.ServiceExists("MynewService"), String.Format("Service '{0}' was NOT removed on Uninstall.", "MynewService"));
        }
Exemple #15
0
        public void IISWebPropertyEtag_Install()
        {
            string sourceFile = Path.Combine(IISWebPropertyTests.TestDataDirectory, @"product_etag.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixIIsExtension");

            // get original value for the property
            int originalEtagPropertyValue;

            if (!int.TryParse(IISVerifier.GetMetaBasePropertyValue("MD_ETAG_CHANGENUMBER").ToString(), out originalEtagPropertyValue))
            {
                originalEtagPropertyValue = -1;  // default is null
            }

            // Install  Msi
            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify Etag property was set correctelly on install
            int acctualEtagPropertyValue  = (int)IISVerifier.GetMetaBasePropertyValue("MD_ETAG_CHANGENUMBER");
            int expectedEtagPropertyValue = 1234;

            Assert.True(acctualEtagPropertyValue == expectedEtagPropertyValue, String.Format("Etag Property value does not meat expected. Acctual: '{0}'. Expected: '{1}'.", acctualEtagPropertyValue, expectedEtagPropertyValue));

            // UnInstall Msi
            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            // Verify WebDir was removed
            if (!int.TryParse(IISVerifier.GetMetaBasePropertyValue("MD_ETAG_CHANGENUMBER").ToString(), out acctualEtagPropertyValue))
            {
                acctualEtagPropertyValue = -1;  // default
            }
            expectedEtagPropertyValue = originalEtagPropertyValue;
            Assert.True(acctualEtagPropertyValue == expectedEtagPropertyValue, String.Format("Etag Property value does not meat expected. Acctual: '{0}'. Expected: '{1}'.", acctualEtagPropertyValue, expectedEtagPropertyValue));
        }
        public void DependencyExtension_MissingDependency()
        {
            string packageB = BuildPackage("B", null);

            string logB = MSIExec.InstallProduct(packageB, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            Assert.IsTrue(LogVerifier.MessageInLogFile(logB, @"WixDependencyRequire:  The dependency ""Microsoft.WiX.DependencyExtension_MissingDependency.A,v1.0"" is missing or is not the required version."));
        }
Exemple #17
0
        public void WixCloseApplication_ApplicationDoesNotExisit()
        {
            string sourceFile = Path.Combine(WixCloseApplicationTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);
        }
Exemple #18
0
        public void SqlScript_InvalidSqlScript()
        {
            string sourceFile = Path.Combine(SqlScriptTests.TestDataDirectory, @"InvalidSqlScript.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixSqlExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            Assert.IsFalse(SqlVerifier.DatabaseExists(SqlScriptTests.SQLServerHostName, SqlScriptTests.SQLServerInstanceName, "BlankDB12"), "Database '{0}' was not dropped on Rollback", "BlankDB12");
        }
        public void SqlString_InstallFailure()
        {
            string sourceFile = Path.Combine(SqlStringTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixSqlExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            Assert.False(SqlVerifier.DatabaseExists(SqlStringTests.SQLServerHostName, SqlStringTests.SQLServerInstanceName, "BlankDB110"), String.Format("Database '{0}' was Not dropped on Rollback", "BlankDB110"));
        }
        public void ServiceConfig_NonExistingService()
        {
            string sourceFile = Path.Combine(ServiceConfigTests.TestDataDirectory, @"NonExistingService.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            Assert.False(ServiceVerifier.ServiceExists("NonExistingService"), String.Format("Service '{0}' was created on Rollback.", "NonExistingService"));
        }
        public void DependencyExtension_MissingDependencyOverride()
        {
            string packageB = BuildPackage("B", null);

            string logB = InstallProductWithProperties(packageB, MSIExec.MSIExecReturnCode.SUCCESS, "DISABLEDEPENDENCYCHECK=1");

            Assert.IsTrue(LogVerifier.MessageInLogFile(logB, @"Skipping action: WixDependencyRequire (condition is false)"));

            MSIExec.UninstallProduct(packageB, MSIExec.MSIExecReturnCode.SUCCESS);
        }
        public void NativeImage_VerifyCommandLineParameters()
        {
            string sourceFile = Path.Combine(NativeImageTests.TestDataDirectory, @"product.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixNetFXExtension");

            string logFile = MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);

            Assert.True(LogVerifier.MessageInLogFileRegex(logFile, @"ngen[\.]exe\sinstall(.*)WiXTasks[\.]dll(.*)/Debug\s/Profile\s/NoDependencies"), String.Format("Could not find expected CommandLine paramters in log file: '{0}'.", logFile));

            MSIExec.UninstallProduct(msiFile, MSIExec.MSIExecReturnCode.SUCCESS);
        }
Exemple #23
0
        public void IISWebAppPool_InstallFailure()
        {
            string sourceFile = Path.Combine(IISWebAppPoolTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", new string[] { "WixIIsExtension", "WixUtilExtension" });

            // Install  Msi
            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            // Verify that the app pool was removed
            Assert.IsFalse(IISVerifier.AppPoolExists("App Pool 1"), "AppPool '{0}' was not removed on Rollback", "App Pool 1");
        }
        public void IISVirtualDir_InstallFailure()
        {
            string sourceFile = Path.Combine(IISVirtualDirTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixIIsExtension");

            // Install  Msi
            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            // Verify that the Virtual directory was removed
            Assert.False(IISVerifier.VirtualDirExist("test1", "Test web server"), String.Format("VirtualDir '{0}' in site '{1}' was not removed on Rollback", "test1", "Test web server"));
        }
        public void IISWebDir_InstallFailure()
        {
            string sourceFile = Path.Combine(IISWebDirTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixIIsExtension");

            // Install  Msi
            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            // Verify WebDir was not created
            Assert.False(IISVerifier.WebDirExist("webdir", "Test web server"), String.Format("WebDir '{0}' in site '{1}' was created on failed install", "webdir", "Test web server"));
        }
        public void PerfCounterManifest_InstallFailure()
        {
            string sourceFile = Path.Combine(PerfCounterManifestTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            string keyName = @"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\_V2Providers\{42aaeb49-78e7-4d78-81a0-6f35bfde65bc}";

            // Verify that the file was removed
            Assert.IsFalse(RegistryVerifier.RegistryKeyExists(RegistryHive.LocalMachine, keyName), "Registry Key '{0}' was not removed on uninstall.", keyName);
        }
        public void FileShare_InstallFailure()
        {
            string sourceFile = Path.Combine(FileShareTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            // Verify Fileshare is removed.
            string testFolderPath = Path.Combine(@"\\" + System.Environment.MachineName, "TestShareName");

            Assert.False(Directory.Exists(testFolderPath), String.Format("Share '{0}' was not removed on Rollback.", testFolderPath));
        }
Exemple #28
0
        public void XmlFile_InstallFailure()
        {
            string sourceFile = Path.Combine(XmlFileTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            // Verify that the file was removed
            string fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"WixTestFolder\test.xml");

            Assert.False(File.Exists(fileName), String.Format("XMLFile '{0}' was not removed on Rollback.", fileName));
        }
        public void NativeImage_InstallFailure()
        {
            string sourceFile = Path.Combine(NativeImageTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixNetFXExtension");

            string logFile = MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            // make sure all the assymblies have been ngened
            NgenQueuedBinaries(NetFXVerifier.FrameworkArch.x86);

            Assert.False(NetFXVerifier.NativeImageExists("WixTasks.dll", NetFXVerifier.FrameworkVersion.NetFX20, NetFXVerifier.FrameworkArch.x86), String.Format("Native Image '{0}' was not removed on Rollback", "WixTasks.dll"));
        }
        public void PerformanceCategory_InstallFailure()
        {
            string sourceFile = Path.Combine(PerformanceCategoryTests.TestDataDirectory, @"product_fail.wxs");
            string msiFile    = Builder.BuildPackage(sourceFile, "test.msi", "WixUtilExtension");

            MSIExec.InstallProduct(msiFile, MSIExec.MSIExecReturnCode.ERROR_INSTALL_FAILURE);

            string registryKey = @"system\currentcontrolset\services\InstrumentationDemo";

            // Verify that the file was not created
            Assert.IsFalse(RegistryVerifier.RegistryKeyExists(RegistryHive.LocalMachine, registryKey), "Registry Key '{0}' was not removed on Rollback.", registryKey);
        }
Exemple #31
0
        /// <summary>
        /// Executes the bundle with optional arguments.
        /// </summary>
        /// <param name="expectedExitCode">Expected exit code.</param>
        /// <param name="mode">Install mode.</param>
        /// <param name="arguments">Optional arguments to pass to the tool.</param>
        /// <returns>Path to the generated log file.</returns>
        private string RunBundleWithArguments(int expectedExitCode, MSIExec.MSIExecMode mode, params string[] arguments)
        {
            TestTool bundle = new TestTool(this.Bundle, null);
            StringBuilder sb = new StringBuilder();

            // Be sure to run silent.
            sb.Append(" -quiet");

            // Generate the log file name.
            string logFile = Path.Combine(Path.GetTempPath(), String.Format("{0}_{1:yyyyMMddhhmmss}_{3}_{2}.log", this.TestName, DateTime.UtcNow, Path.GetFileNameWithoutExtension(this.Bundle), mode));
            sb.AppendFormat(" -log \"{0}\"", logFile);

            // Set operation.
            switch (mode)
            {
                case MSIExec.MSIExecMode.Modify:
                    sb.Append(" -modify");
                    break;

                case MSIExec.MSIExecMode.Repair:
                    sb.Append(" -repair");
                    break;

                case MSIExec.MSIExecMode.Uninstall:
                    sb.Append(" -uninstall");
                    break;
            }

            // Add additional arguments.
            if (null != arguments)
            {
                sb.Append(" ");
                sb.Append(String.Join(" ", arguments));
            }

            // Set the arguments.
            bundle.Arguments = sb.ToString();

            // Run the tool and assert the expected code.
            bundle.ExpectedExitCode = expectedExitCode;
            bundle.Run();

            // Return the log file name.
            return logFile;
        }
 /// <summary>
 /// Uninstalls the product and passes zero or more property settings.
 /// </summary>
 /// <param name="path">The path to the MSI to install.</param>
 /// <param name="expectedExitCode">The expected exit code.</param>
 /// <param name="properties">Zero or more properties to pass to the install.</param>
 /// <returns>The path to the log file.</returns>
 private string UninstallProductWithProperties(string path, MSIExec.MSIExecReturnCode expectedExitCode, params string[] properties)
 {
     return RunMSIWithProperties(path, expectedExitCode, MSIExec.MSIExecMode.Uninstall, properties);
 }
        /// <summary>
        /// Runs msiexec on the given <paramref name="path"/> with zero or more property settings.
        /// </summary>
        /// <param name="path">The path to the MSI to run.</param>
        /// <param name="expectedExitCode">The expected exit code.</param>
        /// <param name="mode">The installation mode for the MSI.</param>
        /// <param name="properties">Zero or more properties to pass to the install.</param>
        /// <returns>The path to the log file.</returns>
        private string RunMSIWithProperties(string path, MSIExec.MSIExecReturnCode expectedExitCode, MSIExec.MSIExecMode mode, params string[] properties)
        {
            MSIExec exec = new MSIExec();
            exec.ExecutionMode = mode;
            exec.ExpectedExitCode = expectedExitCode;
            exec.OtherArguments = null != properties ? String.Join(" ", properties) : null;
            exec.Product = path;

            // Get the name of the calling method.
            StackTrace stack = new StackTrace();
            string caller = stack.GetFrame(2).GetMethod().Name;

            // Generate the log file name.
            string logFile = String.Format("{0}_{1:yyyyMMddhhmmss}_{3}_{2}.log", caller, DateTime.UtcNow, Path.GetFileNameWithoutExtension(path), mode);
            exec.LogFile = Path.Combine(Path.GetTempPath(), logFile);

            exec.Run();

            return exec.LogFile;
        }