コード例 #1
0
ファイル: ZipData.cs プロジェクト: layomia/dotnet_arcade
        private void RepackWixPack(TaskLoggingHelper log, string tempDir, string wixToolsPath)
        {
            string workingDir     = Path.Combine(tempDir, "extract", Guid.NewGuid().ToString());
            string outputDir      = Path.Combine(tempDir, "output", Guid.NewGuid().ToString());
            string createFileName = Path.Combine(workingDir, "create.cmd");
            string outputFileName = Path.Combine(outputDir, FileSignInfo.FileName);

            try
            {
                Directory.CreateDirectory(outputDir);
                ZipFile.ExtractToDirectory(FileSignInfo.WixContentFilePath, workingDir);

                var fileList = Directory.GetFiles(workingDir, "*", SearchOption.AllDirectories);
                foreach (var file in fileList)
                {
                    var relativeName = file.Substring($"{workingDir}\\".Length).Replace('\\', '/');
                    var signedPart   = FindNestedPart(relativeName);
                    if (!signedPart.HasValue)
                    {
                        log.LogMessage(MessageImportance.Low, $"Didn't find signed part for nested file: {FileSignInfo.FullPath} -> {relativeName}");
                        continue;
                    }
                    log.LogMessage(MessageImportance.Low, $"Copying signed stream from {signedPart.Value.FileSignInfo.FullPath} to {file}.");
                    File.Copy(signedPart.Value.FileSignInfo.FullPath, file, true);
                }

                if (!BatchSignUtil.RunWixTool(createFileName, outputDir, workingDir, wixToolsPath, log))
                {
                    log.LogError($"Packaging of wix file '{FileSignInfo.FullPath}' failed");
                    return;
                }

                if (!File.Exists(outputFileName))
                {
                    log.LogError($"Wix tool execution passed, but output file '{outputFileName}' was not found.");
                    return;
                }

                log.LogMessage($"Created wix file {outputFileName}, replacing '{FileSignInfo.FullPath}' with '{outputFileName}'");
                File.Copy(outputFileName, FileSignInfo.FullPath, true);
            }
            finally
            {
                // Delete the intermediates
                Directory.Delete(workingDir, true);
                Directory.Delete(outputDir, true);
            }
        }
コード例 #2
0
        private void RepackWixPack(TaskLoggingHelper log, string tempDir, string wixToolsPath)
        {
            if (wixToolsPath == null)
            {
                log.LogError("WixToolsPath must be defined to repack wixpacks. Wixpacks are used to produce signed msi's during release pipeline builds.  If this is not a release pipeline build, you may avoid this error by removing '*.wixpack.zip' from your ItemsToSign.");
                return;
            }

            string workingDir     = Path.Combine(tempDir, "extract", Guid.NewGuid().ToString());
            string outputDir      = Path.Combine(tempDir, "output", Guid.NewGuid().ToString());
            string createFileName = Path.Combine(workingDir, "create.cmd");
            string outputFileName = Path.Combine(outputDir, FileSignInfo.FileName);

            Directory.CreateDirectory(outputDir);
            ZipFile.ExtractToDirectory(FileSignInfo.WixContentFilePath, workingDir);

            var fileList = Directory.GetFiles(workingDir, "*", SearchOption.AllDirectories);

            foreach (var file in fileList)
            {
                var relativeName = file.Substring($"{workingDir}\\".Length).Replace('\\', '/');
                var signedPart   = FindNestedPart(relativeName);
                if (!signedPart.HasValue)
                {
                    log.LogMessage(MessageImportance.Low, $"Didn't find signed part for nested file: {FileSignInfo.FullPath} -> {relativeName}");
                    continue;
                }
                log.LogMessage(MessageImportance.Low, $"Copying signed stream from {signedPart.Value.FileSignInfo.FullPath} to {file}.");
                File.Copy(signedPart.Value.FileSignInfo.FullPath, file, true);
            }

            int exitCode = BatchSignUtil.RunWixTool(createFileName, outputDir, workingDir, wixToolsPath);

            if (exitCode != 0)
            {
                log.LogError($"packaging of wix file '{FileSignInfo.FullPath}' failed");
                return;
            }

            Debug.Assert(File.Exists(outputFileName));
            log.LogMessage($"Created wix file {outputFileName}, replacing '{FileSignInfo.FullPath}' with '{outputFileName}'");
            File.Copy(outputFileName, FileSignInfo.FullPath, true);

            // Delete the intermediates
            Directory.Delete(workingDir, true);
            Directory.Delete(outputDir, true);
        }
コード例 #3
0
ファイル: SignToolTask.cs プロジェクト: maririos/arcade
        public void ExecuteImpl()
        {
            if (!DryRun)
            {
                if (typeof(object).Assembly.GetName().Name != "mscorlib" && !File.Exists(MSBuildPath))
                {
                    Log.LogError($"MSBuild was not found at this path: '{MSBuildPath}'.");
                    return;
                }

                if (String.IsNullOrEmpty(LogDir) || !Directory.Exists(LogDir))
                {
                    Log.LogError($"Invalid LogDir informed: {LogDir}");
                    return;
                }
            }

            var signInfos           = ParseStrongNameSignInfo();
            var overridingSignInfos = ParseFileSignInfo();

            if (Log.HasLoggedErrors)
            {
                return;
            }

            var signToolArgs = new SignToolArgs(TempDir, MicroBuildCorePath, TestSign, MSBuildPath, LogDir);
            var signTool     = DryRun ? new ValidationOnlySignTool(signToolArgs) : (SignTool) new RealSignTool(signToolArgs);
            var signingInput = new Configuration(TempDir, ItemsToSign, signInfos, overridingSignInfos, PublishUrl, Log).GenerateListOfFiles();

            if (Log.HasLoggedErrors)
            {
                return;
            }

            var util = new BatchSignUtil(BuildEngine, Log, signTool, signingInput, OrchestrationManifestPath);

            if (Log.HasLoggedErrors)
            {
                return;
            }

            util.Go();
        }
コード例 #4
0
ファイル: SignToolTask.cs プロジェクト: natemcmaster/arcade
        private void ExecuteImpl()
        {
            if (!DryRun && typeof(object).Assembly.GetName().Name != "mscorlib")
            {
                if (!File.Exists(MSBuildPath))
                {
                    Log.LogError($"File '{MSBuildPath}' not found.");
                    return;
                }
            }

            var signToolArgs = new SignToolArgs(
                outputPath: OutputDir,
                tempPath: TempDir,
                microBuildCorePath: MicroBuildCorePath,
                testSign: TestSign);

            var signTool  = DryRun ? new ValidationOnlySignTool(signToolArgs) : (SignTool) new RealSignTool(signToolArgs, MSBuildPath, LogDir);
            var batchData = Configuration.ReadConfigFile(signToolArgs.OutputDir, ConfigFilePath, Log);
            var util      = new BatchSignUtil(BuildEngine, Log, signTool, batchData, null);

            util.Go();
        }