Beispiel #1
0
        public async Task UninstallTestMsi()
        {
            if (string.IsNullOrEmpty(TestCommon.MsiInstallerPath))
            {
                Assert.Ignore("MSI installer not available");
            }

            // Find package
            var searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.MsiInstallerPackageId);

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            installOptions.PreferredInstallLocation = installDir;

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);

            // Find package again, but this time it should detect the installed version
            searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.MsiInstallerPackageId);
            Assert.NotNull(searchResult.CatalogPackage.InstalledVersion);

            // Uninstall
            var uninstallResult = await packageManager.UninstallPackageAsync(searchResult.CatalogPackage, TestFactory.CreateUninstallOptions());

            Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status);
            Assert.True(TestCommon.VerifyTestMsiUninstalled(installDir));
        }
Beispiel #2
0
        public async Task UninstallNotIndexed()
        {
            const string customProductCode = "{f08fc03c-0b7e-4fca-9b3c-3a384d18a9f3}";

            // Find package
            var searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.ExeInstallerPackageId);

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            installOptions.ReplacementInstallerArguments = $"/ProductID {customProductCode} /InstallDir {installDir}";

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);

            // Find package again, but this time it should detect the installed version
            searchResult = FindOnePackage(compositeSource, PackageMatchField.ProductCode, PackageFieldMatchOption.Equals, customProductCode);
            Assert.NotNull(searchResult.CatalogPackage.InstalledVersion);

            // Uninstall
            var uninstallResult = await packageManager.UninstallPackageAsync(searchResult.CatalogPackage, TestFactory.CreateUninstallOptions());

            Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status);
            Assert.True(TestCommon.VerifyTestExeUninstalled(installDir));
        }
Beispiel #3
0
        public async Task UninstallTestExe()
        {
            // Find package
            var searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.ExeInstallerPackageId);

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            installOptions.PackageInstallMode       = PackageInstallMode.Silent;
            installOptions.PreferredInstallLocation = installDir;

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);

            // Find package again, but this time it should detect the installed version
            searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.ExeInstallerPackageId);
            Assert.NotNull(searchResult.CatalogPackage.InstalledVersion);

            // Uninstall
            var uninstallResult = await packageManager.UninstallPackageAsync(searchResult.CatalogPackage, TestFactory.CreateUninstallOptions());

            Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status);
            Assert.True(TestCommon.VerifyTestExeUninstalled(installDir));
        }
Beispiel #4
0
        public async Task UninstallPortableWithProductCode()
        {
            string installDir     = Path.Combine(Environment.GetEnvironmentVariable(Constants.LocalAppData), "Microsoft", "WinGet", "Packages");
            string packageDirName = Constants.PortableExePackageDirName;
            string productCode    = Constants.PortableExePackageDirName;
            string commandAlias   = Constants.AppInstallerTestExeInstallerExe;
            string fileName       = Constants.AppInstallerTestExeInstallerExe;

            // Find package
            var searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.PortableExePackageId);

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);

            // Find package again, but this time it should detect the installed version
            searchResult = FindOnePackage(compositeSource, PackageMatchField.ProductCode, PackageFieldMatchOption.Equals, productCode);
            Assert.NotNull(searchResult.CatalogPackage.InstalledVersion);

            // Uninstall
            var uninstallResult = await packageManager.UninstallPackageAsync(searchResult.CatalogPackage, TestFactory.CreateUninstallOptions());

            Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status);
            TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, false);
        }
Beispiel #5
0
        public async Task UninstallPortableModifiedSymlink()
        {
            string packageId        = Constants.PortableExePackageId;
            string commandAlias     = Constants.AppInstallerTestExeInstallerExe;
            string symlinkDirectory = Path.Combine(Environment.GetEnvironmentVariable(Constants.LocalAppData), "Microsoft", "WinGet", "Links");
            string symlinkPath      = Path.Combine(symlinkDirectory, commandAlias);

            // Find package
            var searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId);

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);

            // Replace symlink with modified symlink
            File.Delete(symlinkPath);
            FileSystemInfo modifiedSymlinkInfo = File.CreateSymbolicLink(symlinkPath, "fakeTargetExe");

            // Find package again, but this time it should detect the installed version
            searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId);
            Assert.NotNull(searchResult.CatalogPackage.InstalledVersion);

            // Uninstall
            var uninstallResult = await packageManager.UninstallPackageAsync(searchResult.CatalogPackage, TestFactory.CreateUninstallOptions());

            Assert.AreEqual(UninstallResultStatus.Ok, uninstallResult.Status);
            Assert.True(modifiedSymlinkInfo.Exists, "Modified symlink should still exist");

            // Remove modified symlink as to not interfere with other tests
            modifiedSymlinkInfo.Delete();
        }
Beispiel #6
0
        public async Task InstallPortableFailsWithCleanup()
        {
            if (TestFactory.Context == ClsidContext.InProc)
            {
                // Task to investigate validation error when running in-process
                // TODO: https://task.ms/40489822
                Assert.Ignore();
            }

            string winGetDir         = Path.Combine(Environment.GetEnvironmentVariable(Constants.LocalAppData), "Microsoft", "WinGet");
            string installDir        = Path.Combine(winGetDir, "Packages");
            string symlinkDirectory  = Path.Combine(winGetDir, "Links");
            string packageDirName    = Constants.PortableExePackageDirName;
            string productCode       = Constants.PortableExePackageDirName;
            string commandAlias      = Constants.AppInstallerTestExeInstallerExe;
            string fileName          = Constants.AppInstallerTestExeInstallerExe;
            string conflictDirectory = Path.Combine(symlinkDirectory, commandAlias);

            // Create a directory with the same name as the symlink in order to cause install to fail.
            Directory.CreateDirectory(conflictDirectory);

            // Find package
            var searchResult = FindOnePackage(testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.PortableExePackageId);

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            // Assert
            Assert.AreEqual(InstallResultStatus.InstallError, installResult.Status);
            TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, false);
            Directory.Delete(conflictDirectory, true);
        }
Beispiel #7
0
        public async Task InstallPortableToExistingDirectory()
        {
            var existingDir = Path.Combine(installDir, "testDirectory");

            Directory.CreateDirectory(existingDir);

            string productCode  = Constants.PortableExePackageDirName;
            string commandAlias = Constants.AppInstallerTestExeInstallerExe;
            string fileName     = Constants.AppInstallerTestExeInstallerExe;

            // Find package
            var searchResult = FindOnePackage(testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.PortableExePackageId);

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            installOptions.PreferredInstallLocation = existingDir;

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            // Assert
            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
            TestCommon.VerifyPortablePackage(existingDir, commandAlias, fileName, productCode, true);
        }
Beispiel #8
0
        public async Task InstallMSIXWithSignatureHashMismatch()
        {
            // Find package
            var searchResult = FindOnePackage(testSource, PackageMatchField.Name, PackageFieldMatchOption.Equals, "TestMsixSignatureHashMismatch");

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            // Assert
            Assert.AreEqual(InstallResultStatus.DownloadError, installResult.Status);
            Assert.False(TestCommon.VerifyTestMsixInstalledAndCleanup());
        }
Beispiel #9
0
        public async Task UpgradePortableForcedOverride()
        {
            string installDir     = Path.Combine(Environment.GetEnvironmentVariable(Constants.LocalAppData), "Microsoft", "WinGet", "Packages");
            string packageId      = Constants.PortableExePackageId;
            string packageDirName = Constants.PortableExePackageDirName;
            string productCode    = Constants.PortableExePackageDirName;
            string commandAlias   = Constants.AppInstallerTestExeInstallerExe;
            string fileName       = Constants.AppInstallerTestExeInstallerExe;

            // Find package
            var searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId);

            // Configure install options
            var installOptions = TestFactory.CreateInstallOptions();

            installOptions.PackageVersionId = First(searchResult.CatalogPackage.AvailableVersions, (i => i.Version == "1.0.0.0"));

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);

            // Modify packageId and sourceId to cause mismatch.
            TestCommon.ModifyPortableARPEntryValue(productCode, Constants.WinGetPackageIdentifier, "testPackageId");
            TestCommon.ModifyPortableARPEntryValue(productCode, Constants.WinGetSourceIdentifier, "testSourceId");

            // Find package again, but this time it should detect the installed version
            searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId);
            Assert.NotNull(searchResult.CatalogPackage.InstalledVersion);

            // Configure upgrade options
            var upgradeOptions = TestFactory.CreateInstallOptions();

            upgradeOptions.PackageVersionId  = First(searchResult.CatalogPackage.AvailableVersions, (i => i.Version == "2.0.0.0"));
            upgradeOptions.AllowHashMismatch = true;

            // Upgrade
            var upgradeResult = await packageManager.UpgradePackageAsync(searchResult.CatalogPackage, upgradeOptions);

            Assert.AreEqual(InstallResultStatus.Ok, upgradeResult.Status);

            // Find package again, but this time it should detect the upgraded installed version
            searchResult = FindOnePackage(compositeSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, packageId);
            Assert.AreEqual(searchResult.CatalogPackage.InstalledVersion?.Version, "2.0.0.0");
            TestCommon.VerifyPortablePackage(Path.Combine(installDir, packageDirName), commandAlias, fileName, productCode, true);
        }
Beispiel #10
0
        public async Task InstallExe()
        {
            // Find package
            var searchResult = FindOnePackage(testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, "AppInstallerTest.TestExeInstaller");

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            installOptions.PackageInstallMode       = PackageInstallMode.Silent;
            installOptions.PreferredInstallLocation = installDir;

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            // Assert
            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
        }
Beispiel #11
0
        public async Task InstallWithInno()
        {
            // Find package
            var searchResult = FindOnePackage(testSource, PackageMatchField.Name, PackageFieldMatchOption.Equals, "TestInnoInstaller");

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            installOptions.PackageInstallMode       = PackageInstallMode.Silent;
            installOptions.PreferredInstallLocation = installDir;

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            // Assert
            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
            Assert.True(TestCommon.VerifyTestExeInstalledAndCleanup(installDir));
        }
Beispiel #12
0
        public async Task InstallPortableExe()
        {
            string installDir   = Path.Combine(Environment.GetEnvironmentVariable(Constants.LocalAppData), "Microsoft", "WinGet", "Packages");
            string productCode  = Constants.PortableExePackageDirName;
            string commandAlias = $"{Constants.ExeInstaller}.exe";
            string fileName     = $"{Constants.ExeInstaller}.exe";

            // Find package
            var searchResult = FindOnePackage(testSource, PackageMatchField.Id, PackageFieldMatchOption.Equals, Constants.PortableExePackageId);

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            // Assert
            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
            TestCommon.VerifyPortablePackage(Path.Combine(installDir, Constants.PortableExePackageDirName), commandAlias, fileName, productCode, true);
        }
Beispiel #13
0
        public async Task InstallMSIXWithSignature()
        {
            // Task to investigate installation error
            // TODO: https://task.ms/40489822
            Assert.Ignore();

            // Find package
            var searchResult = FindOnePackage(testSource, PackageMatchField.Name, PackageFieldMatchOption.Equals, "TestMsixWithSignatureHash");

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            installOptions.PackageInstallMode       = PackageInstallMode.Silent;
            installOptions.PreferredInstallLocation = installDir;

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            // Assert
            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
            Assert.True(TestCommon.VerifyTestMsixInstalledAndCleanup());
        }
Beispiel #14
0
        public async Task InstallMSI()
        {
            if (string.IsNullOrEmpty(TestCommon.MsiInstallerPath))
            {
                Assert.Ignore("MSI installer not available");
            }

            // Find package
            var searchResult = FindOnePackage(testSource, PackageMatchField.Name, PackageFieldMatchOption.Equals, "TestMsiInstaller");

            // Configure installation
            var installOptions = TestFactory.CreateInstallOptions();

            installOptions.PackageInstallMode       = PackageInstallMode.Silent;
            installOptions.PreferredInstallLocation = installDir;

            // Install
            var installResult = await packageManager.InstallPackageAsync(searchResult.CatalogPackage, installOptions);

            // Assert
            Assert.AreEqual(InstallResultStatus.Ok, installResult.Status);
            Assert.True(TestCommon.VerifyTestMsiInstalledAndCleanup(installDir));
        }