Пример #1
0
        internal static ISignTool Create(SignToolArgs args)
        {
            if (args.Test)
            {
                return(new TestSignTool(args));
            }

            return(new RealSignTool(args));
        }
 internal SignToolBase(SignToolArgs args)
 {
     _args = args;
 }
Пример #3
0
        internal static bool ParseCommandLineArguments(
            IHost host,
            string[] args,
            out SignToolArgs signToolArgs)
        {
            signToolArgs = default;

            string intermediateOutputPath   = null;
            string outputPath               = null;
            string msbuildPath              = null;
            string nugetPackagesPath        = null;
            string configFile               = null;
            string outputConfigFile         = null;
            string msbuildBinaryLogFilePath = null;
            var    test     = false;
            var    testSign = false;

            var i = 0;

            while (i + 1 < args.Length)
            {
                var current = args[i].ToLower();
                switch (current)
                {
                case "-test":
                    test = true;
                    i++;
                    break;

                case "-testsign":
                    testSign = true;
                    i++;
                    break;

                case "-intermediateoutputpath":
                    if (!ParsePathOption(args, ref i, current, out intermediateOutputPath))
                    {
                        return(false);
                    }
                    break;

                case "-msbuildpath":
                    if (!ParsePathOption(args, ref i, current, out msbuildPath))
                    {
                        return(false);
                    }
                    break;

                case "-msbuildbinarylog":
                    if (!ParsePathOption(args, ref i, current, out msbuildBinaryLogFilePath))
                    {
                        return(false);
                    }
                    break;

                case "-nugetpackagespath":
                    if (!ParsePathOption(args, ref i, current, out nugetPackagesPath))
                    {
                        return(false);
                    }
                    break;

                case "-config":
                    if (!ParsePathOption(args, ref i, current, out configFile))
                    {
                        return(false);
                    }
                    break;

                case "-outputconfig":
                    if (!ParsePathOption(args, ref i, current, out outputConfigFile))
                    {
                        return(false);
                    }
                    outputConfigFile = outputConfigFile.TrimEnd('\"').TrimStart('\"');
                    break;

                default:
                    Console.Error.WriteLine($"Unrecognized option {current}");
                    return(false);
                }
            }

            if (i + 1 != args.Length)
            {
                Console.Error.WriteLine("Need a value for outputPath");
                return(false);
            }

            if (msbuildPath == null && !test)
            {
                Console.Error.WriteLine("-msbuildpath argument must be specified unless running in validation-only mode.");
                return(false);
            }

            outputPath = args[i];

            intermediateOutputPath = intermediateOutputPath ?? Path.Combine(Path.GetDirectoryName(outputPath), "Obj");

            if (string.IsNullOrWhiteSpace(nugetPackagesPath))
            {
                nugetPackagesPath = host.GetEnvironmentVariable("NUGET_PACKAGES");
                if (string.IsNullOrWhiteSpace(nugetPackagesPath))
                {
                    nugetPackagesPath = Path.Combine(
                        host.GetFolderPath(Environment.SpecialFolder.UserProfile),
                        @".nuget\packages");
                }
            }

            if (configFile == null)
            {
                var sourcesPath = GetSourcesPath(host, outputPath);
                if (sourcesPath != null)
                {
                    configFile = Path.Combine(sourcesPath, @"build\config\SignToolData.json");
                }
            }

            signToolArgs = new SignToolArgs(
                outputPath: outputPath,
                msbuildPath: msbuildPath,
                msbuildBinaryLogFilePath: msbuildBinaryLogFilePath,
                intermediateOutputPath: intermediateOutputPath,
                nugetPackagesPath: nugetPackagesPath,
                appPath: AppContext.BaseDirectory,
                configFile: configFile,
                test: test,
                testSign: testSign,
                orchestrationManifestPath: outputConfigFile);
            return(true);
        }
Пример #4
0
                + sizeof(Int64);  // metadata directory

            internal RealSignTool(SignToolArgs args) : base(args)
            {
            }
Пример #5
0
        internal static bool ParseCommandLineArguments(
            IHost host,
            string[] args,
            out SignToolArgs signToolArgs)
        {
            signToolArgs = default(SignToolArgs);

            string intermediateOutputPath = null;
            string outputPath             = null;
            string msbuildPath            = null;
            string nugetPackagesPath      = null;
            string configFile             = null;
            var    test = false;

            var i = 0;

            while (i + 1 < args.Length)
            {
                var current = args[i].ToLower();
                switch (current)
                {
                case "-test":
                    test = true;
                    i++;
                    break;

                case "-intermediateoutputpath":
                    if (!ParsePathOption(args, ref i, current, out intermediateOutputPath))
                    {
                        return(false);
                    }
                    break;

                case "-msbuildpath":
                    if (!ParsePathOption(args, ref i, current, out msbuildPath))
                    {
                        return(false);
                    }
                    break;

                case "-nugetpackagespath":
                    if (!ParsePathOption(args, ref i, current, out nugetPackagesPath))
                    {
                        return(false);
                    }
                    break;

                case "-config":
                    if (!ParsePathOption(args, ref i, current, out configFile))
                    {
                        return(false);
                    }
                    break;

                default:
                    Console.WriteLine($"Unrecognized option {current}");
                    return(false);
                }
            }

            if (i + 1 != args.Length)
            {
                Console.WriteLine("Need a value for outputPath");
                return(false);
            }

            outputPath = args[i];

            // Get defaults for all of the optional values that weren't specified
            if (msbuildPath == null && !test)
            {
                var vsInstallDir = LocateVS.Instance.GetInstallPath("15.0", new[] { "Microsoft.Component.MSBuild" });
                msbuildPath = Path.Combine(vsInstallDir, "MSBuild", "15.0", "Bin", "msbuild.exe");
            }

            intermediateOutputPath = intermediateOutputPath ?? Path.Combine(Path.GetDirectoryName(outputPath), "Obj");

            if (string.IsNullOrWhiteSpace(nugetPackagesPath))
            {
                nugetPackagesPath = host.GetEnvironmentVariable("NUGET_PACKAGES");
                if (string.IsNullOrWhiteSpace(nugetPackagesPath))
                {
                    nugetPackagesPath = Path.Combine(
                        host.GetFolderPath(Environment.SpecialFolder.UserProfile),
                        @".nuget\packages");
                }
            }

            if (configFile == null)
            {
                var sourcesPath = GetSourcesPath(host, outputPath);
                if (sourcesPath != null)
                {
                    configFile = Path.Combine(sourcesPath, @"build\config\SignToolData.json");
                }
            }

            signToolArgs = new SignToolArgs(
                outputPath: outputPath,
                msbuildPath: msbuildPath,
                intermediateOutputPath: intermediateOutputPath,
                nugetPackagesPath: nugetPackagesPath,
                appPath: AppContext.BaseDirectory,
                configFile: configFile,
                test: test);
            return(true);
        }
Пример #6
0
 internal RealSignTool(SignToolArgs args) : base(args)
 {
     TestSign = args.TestSign;
 }
Пример #7
0
 internal TestSignTool(SignToolArgs args) : base(args)
 {
 }