public static string HashSignatureFromMSIX(string packageFilePath) { // Obtain MakeAppX Executable Path string pathToSDK = SDKDetector.Instance.LatestSDKBinPath; string makeappxExecutable = Path.Combine(pathToSDK, "makeappx.exe"); // Generate temp path to unpack MSIX package FileInfo fileInfo = new FileInfo(packageFilePath); string packageName = Path.GetFileNameWithoutExtension(fileInfo.Name); string tempPath = Path.GetTempPath(); string extractedPackageDest = Path.Combine(tempPath, packageName); // Delete existing extracted package directories to avoid stalling MakeAppX command if (Directory.Exists(extractedPackageDest)) { TestIndexSetup.DeleteDirectoryContents(Directory.CreateDirectory(extractedPackageDest)); Directory.Delete(extractedPackageDest); } TestIndexSetup.RunCommand(makeappxExecutable, $"unpack /nv /p {packageFilePath} /d {extractedPackageDest}"); string packageSignaturePath = Path.Combine(extractedPackageDest, "AppxSignature.p7x"); return(HashFile(packageSignaturePath)); }
/// <summary> /// Copies log files to the path %TEMP%\E2ETestLogs /// </summary> public static void PublishE2ETestLogs() { string tempPath = Path.GetTempPath(); string localAppDataPath = Environment.GetEnvironmentVariable("LocalAppData"); string testLogsSourcePath = Path.Combine(localAppDataPath, Constants.E2ETestLogsPath); string testLogsDestPath = Path.Combine(tempPath, "E2ETestLogs"); if (Directory.Exists(testLogsDestPath)) { TestIndexSetup.DeleteDirectoryContents(new DirectoryInfo(testLogsDestPath)); Directory.Delete(testLogsDestPath); } if (Directory.Exists(testLogsSourcePath)) { TestIndexSetup.CopyDirectory(testLogsSourcePath, testLogsDestPath); } }
public void Setup() { // Read TestParameters and set runtime variables TestCommon.PackagedContext = TestContext.Parameters.Exists(Constants.PackagedContextParameter) && TestContext.Parameters.Get(Constants.PackagedContextParameter).Equals("true", StringComparison.OrdinalIgnoreCase); TestCommon.VerboseLogging = TestContext.Parameters.Exists(Constants.VerboseLoggingParameter) && TestContext.Parameters.Get(Constants.VerboseLoggingParameter).Equals("true", StringComparison.OrdinalIgnoreCase); TestCommon.LooseFileRegistration = TestContext.Parameters.Exists(Constants.LooseFileRegistrationParameter) && TestContext.Parameters.Get(Constants.LooseFileRegistrationParameter).Equals("true", StringComparison.OrdinalIgnoreCase); TestCommon.InvokeCommandInDesktopPackage = TestContext.Parameters.Exists(Constants.InvokeCommandInDesktopPackageParameter) && TestContext.Parameters.Get(Constants.InvokeCommandInDesktopPackageParameter).Equals("true", StringComparison.OrdinalIgnoreCase); if (TestContext.Parameters.Exists(Constants.AICLIPathParameter)) { TestCommon.AICLIPath = TestContext.Parameters.Get(Constants.AICLIPathParameter); } else { if (TestCommon.PackagedContext) { // For packaged context, default to AppExecutionAlias TestCommon.AICLIPath = "WinGetDev.exe"; } else { TestCommon.AICLIPath = TestCommon.GetTestFile("AppInstallerCli.exe"); } } if (TestContext.Parameters.Exists(Constants.AICLIPackagePathParameter)) { TestCommon.AICLIPackagePath = TestContext.Parameters.Get(Constants.AICLIPackagePathParameter); } else { TestCommon.AICLIPackagePath = TestCommon.GetTestFile("AppInstallerCLIPackage.appxbundle"); } if (TestCommon.LooseFileRegistration && TestCommon.InvokeCommandInDesktopPackage) { TestCommon.AICLIPath = Path.Combine(TestCommon.AICLIPackagePath, TestCommon.AICLIPath); } ShouldDisableDevModeOnExit = EnableDevMode(true); ShouldRevertDefaultFileTypeRiskOnExit = DecreaseFileTypeRisk(".exe", false); Assert.True(TestCommon.RunCommand("certutil.exe", "-addstore -f \"TRUSTEDPEOPLE\" " + TestCommon.GetTestDataFile(Constants.AppInstallerTestCert)), "Add AppInstallerTestCert"); Assert.True(TestCommon.RunCommand("certutil.exe", "-addstore -f \"ROOT\" " + TestCommon.GetTestDataFile(Constants.IndexPackageRootCert)), "Add IndexPackageRootCert"); if (TestCommon.PackagedContext) { if (TestCommon.LooseFileRegistration) { Assert.True(TestCommon.InstallMsixRegister(TestCommon.AICLIPackagePath), "InstallMsixRegister"); } else { Assert.True(TestCommon.InstallMsix(TestCommon.AICLIPackagePath), "InstallMsix"); } } if (TestContext.Parameters.Exists(Constants.StaticFileRootPathParameter)) { TestCommon.StaticFileRootPath = TestContext.Parameters.Get(Constants.StaticFileRootPathParameter); } else { TestCommon.StaticFileRootPath = Path.GetTempPath(); } if (TestContext.Parameters.Exists(Constants.PackageCertificatePathParameter)) { TestCommon.PackageCertificatePath = TestContext.Parameters.Get(Constants.PackageCertificatePathParameter); } ReadTestInstallerPaths(); TestIndexSetup.GenerateTestDirectory(); }