public override void DefineOptions(ArgumentSyntax syntax) { base.DefineOptions(syntax); string manifest = "manifest.json"; syntax.DefineOption("manifest", ref manifest, "Path to json file which describes the repo"); Manifest = manifest; string registryOverride = null; syntax.DefineOption("registry-override", ref registryOverride, "Alternative registry which overrides the manifest"); RegistryOverride = registryOverride; IReadOnlyList <string> repos = Array.Empty <string>(); syntax.DefineOptionList("repo", ref repos, "Repos to operate on (Default is all)"); Repos = repos; string repoPrefix = null; syntax.DefineOption("repo-prefix", ref repoPrefix, "Prefix to add to the repo names specified in the manifest"); RepoPrefix = repoPrefix; IReadOnlyList <string> variables = Array.Empty <string>(); syntax.DefineOptionList("var", ref variables, "Named variables to substitute into the manifest (<name>=<value>)"); Variables = variables .Select(pair => pair.Split(new char[] { '=' }, 2)) .ToDictionary(split => split[0], split => split[1]); }
public void DefineOptions(ArgumentSyntax syntax) { string architecture = DockerHelper.Architecture.GetDockerName(); syntax.DefineOption( "architecture", ref architecture, "Architecture of Dockerfiles to operate on - wildcard chars * and ? supported (default is current OS architecture)"); Architecture = architecture; string osType = DockerHelper.OS.GetDockerName(); syntax.DefineOption( "os-type", ref osType, "OS type (linux/windows) of the Dockerfiles to build - wildcard chars * and ? supported (default is the Docker OS)"); OsType = osType; IReadOnlyList <string> osVersions = Array.Empty <string>(); syntax.DefineOptionList( OsVersionOptionName, ref osVersions, "OS versions of the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)"); OsVersions = osVersions; IReadOnlyList <string> paths = Array.Empty <string>(); syntax.DefineOptionList( PathOptionName, ref paths, "Directory paths containing the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)"); Paths = paths; }
public virtual void ParseCommandLine(ArgumentSyntax syntax) { ArgumentCommand command = syntax.DefineCommand(CommandName, this); command.Help = CommandHelp; bool isDryRun = false; syntax.DefineOption("dry-run", ref isDryRun, "Dry run of what images get built and order they would get built in"); IsDryRun = isDryRun; string manifest = "manifest.json"; syntax.DefineOption("manifest", ref manifest, "Path to json file which describes the repo"); Manifest = manifest; string registryOverride = null; syntax.DefineOption("registry-override", ref registryOverride, "Alternative registry which overrides the manifest"); RegistryOverride = registryOverride; string repo = null; syntax.DefineOption("repo", ref repo, "Repo to operate on (Default is all)"); Repo = repo; IReadOnlyList <string> repoOverrides = Array.Empty <string>(); syntax.DefineOptionList("repo-override", ref repoOverrides, "Alternative repos which overrides the manifest (<target repo>=<override>)"); RepoOverrides = repoOverrides .Select(pair => pair.Split(new char[] { '=' }, 2)) .ToDictionary(split => split[0], split => split[1]); string repoPrefix = null; syntax.DefineOption("repo-prefix", ref repoPrefix, "Prefix to add to the repo names specified in the manifest"); RepoPrefix = repoPrefix; IReadOnlyList <string> variables = Array.Empty <string>(); syntax.DefineOptionList("var", ref variables, "Named variables to substitute into the manifest (<name>=<value>)"); Variables = variables .Select(pair => pair.Split(new char[] { '=' }, 2)) .ToDictionary(split => split[0], split => split[1]); bool isVerbose = false; syntax.DefineOption("verbose", ref isVerbose, "Show details about the tasks run"); IsVerbose = isVerbose; }
private CertificateOptions DefineCertificateCommand(ArgumentSyntax syntax) { var options = new CertificateOptions(); syntax.DefineCommand("cert", ref command, Command.Certificate, "Authorization"); syntax.DefineOption("n|name", ref options.Name, "Friendly name of the cert."); syntax.DefineOption("dn|distinguished-name", ref options.DistinguishedName, $"The distinguished name of the cert."); syntax.DefineOptionList("v|value", ref options.Values, $"The distinguished name of the cert."); syntax.DefineOption("value-path", ref options.ValuesFile, $"The subject alt names."); syntax.DefineOption("cer|export-cer", ref options.ExportCer, "Path to export PEM cer."); syntax.DefineOption("export-key", ref options.ExportKey, "Path to export PEM key."); syntax.DefineOption("pfx|export-pfx", ref options.ExportPfx, "Path to export pfx."); syntax.DefineOption("revoke", ref options.RevokeCer, "Revoke certificate."); syntax.DefineOption("pw|password", ref options.Password, "Password for the pfx."); syntax.DefineOption("full-chain-off", ref options.NoChain, "Skip full cert chain."); syntax.DefineOption("server", ref options.Server, s => new Uri(s), $"ACME Directory Resource URI. (default: {options.Server})"); syntax.DefineOption("p|path", ref options.Path, $"File path used to load/save the registration. (default: {options.Path})"); syntax.DefineOption("f|force", ref options.Force, $"Force"); return(options); }
public override void ParseCommandLine(ArgumentSyntax syntax) { base.ParseCommandLine(syntax); Architecture = DefineArchitectureOption(syntax); string path = null; syntax.DefineOption("path", ref path, "Path of the directory to build (Default is to build all)"); Path = path; bool isPushEnabled = false; syntax.DefineOption("push", ref isPushEnabled, "Push built images to Docker registry"); IsPushEnabled = isPushEnabled; bool isSkipPullingEnabled = false; syntax.DefineOption("skip-pulling", ref isSkipPullingEnabled, "Skip explicitly pulling the base images of the Dockerfiles"); IsSkipPullingEnabled = isSkipPullingEnabled; bool isTestRunDisabled = false; syntax.DefineOption("skip-test", ref isTestRunDisabled, "Skip running the tests"); IsTestRunDisabled = isTestRunDisabled; IReadOnlyList <string> nameValuePairs = Array.Empty <string>(); syntax.DefineOptionList("test-var", ref nameValuePairs, "Named variables to substitute into the test commands (name=value)"); TestVariables = nameValuePairs .Select(pair => pair.Split(new char[] { '=' }, 2)) .ToDictionary(split => split[0], split => split[1]); }
protected static void DefineManifestFilterOptions(ArgumentSyntax syntax, IManifestFilterOptions filterOptions) { string architecture = DockerHelper.Architecture.ToString().ToLowerInvariant(); syntax.DefineOption( "architecture", ref architecture, "Architecture of Dockerfiles to operate on - wildcard chars * and ? supported (default is current OS architecture)"); filterOptions.Architecture = architecture; string osType = DockerHelper.OS.ToString().ToLowerInvariant(); syntax.DefineOption( "os-type", ref osType, "OS type (linux/windows) of the Dockerfiles to build - wildcard chars * and ? supported (default is the Docker OS)"); filterOptions.OsType = osType; string osVersion = null; syntax.DefineOption( "os-version", ref osVersion, "OS version of the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)"); filterOptions.OsVersion = osVersion; IReadOnlyList <string> paths = Array.Empty <string>(); syntax.DefineOptionList( "path", ref paths, "Directory paths containing the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)"); filterOptions.Paths = paths; }
public static CommonCompilerOptions Parse(ArgumentSyntax syntax) { IReadOnlyList <string> defines = null; string languageVersion = null; string platform = null; bool? allowUnsafe = null; bool? warningsAsErrors = null; bool? optimize = null; string keyFile = null; bool? delaySign = null; bool? publicSign = null; bool? emitEntryPoint = null; Func <string, bool?> nullableBoolConverter = v => bool.Parse(v); syntax.DefineOptionList(s_definesTemplate.LongName, ref defines, "Preprocessor definitions"); syntax.DefineOption(s_languageVersionTemplate.LongName, ref languageVersion, "The version of the language used to compile"); syntax.DefineOption(s_platformTemplate.LongName, ref platform, "The target platform"); syntax.DefineOption(s_allowUnsafeTemplate.LongName, ref allowUnsafe, nullableBoolConverter, "Allow unsafe code"); syntax.DefineOption(s_warningsAsErrorsTemplate.LongName, ref warningsAsErrors, nullableBoolConverter, "Turn all warnings into errors"); syntax.DefineOption(s_optimizeTemplate.LongName, ref optimize, nullableBoolConverter, "Enable compiler optimizations"); syntax.DefineOption(s_keyFileTemplate.LongName, ref keyFile, "Path to file containing the key to strong-name sign the output assembly"); syntax.DefineOption(s_delaySignTemplate.LongName, ref delaySign, nullableBoolConverter, "Delay-sign the output assembly"); syntax.DefineOption(s_publicSignTemplate.LongName, ref publicSign, nullableBoolConverter, "Public-sign the output assembly"); syntax.DefineOption(s_emitEntryPointTemplate.LongName, ref emitEntryPoint, nullableBoolConverter, "Output an executable console program"); return(new CommonCompilerOptions { Defines = defines, LanguageVersion = languageVersion, Platform = platform, AllowUnsafe = allowUnsafe, WarningsAsErrors = warningsAsErrors, Optimize = optimize, KeyFile = keyFile, DelaySign = delaySign, PublicSign = publicSign, EmitEntryPoint = emitEntryPoint }); }
public static CommonCompilerOptions Parse(ArgumentSyntax syntax) { IReadOnlyList<string> defines = null; string languageVersion = null; string platform = null; bool? allowUnsafe = null; bool? warningsAsErrors = null; bool? optimize = null; string keyFile = null; bool? delaySign = null; bool? strongName = null; bool? emitEntryPoint = null; Func<string, bool?> nullableBoolConverter = v => bool.Parse(v); syntax.DefineOptionList(s_definesTemplate.LongName, ref defines, "Preprocessor definitions"); syntax.DefineOption(s_languageVersionTemplate.LongName, ref languageVersion, "The version of the language used to compile"); syntax.DefineOption(s_platformTemplate.LongName, ref platform, "The target platform"); syntax.DefineOption(s_allowUnsafeTemplate.LongName, ref allowUnsafe, nullableBoolConverter, "Allow unsafe code"); syntax.DefineOption(s_warningsAsErrorsTemplate.LongName, ref warningsAsErrors, nullableBoolConverter, "Turn all warnings into errors"); syntax.DefineOption(s_optimizeTemplate.LongName, ref optimize, nullableBoolConverter, "Enable compiler optimizations"); syntax.DefineOption(s_keyFileTemplate.LongName, ref keyFile, "Path to file containing the key to strong-name sign the output assembly"); syntax.DefineOption(s_delaySignTemplate.LongName, ref delaySign, nullableBoolConverter, "Delay-sign the output assembly"); syntax.DefineOption(s_ossSignTemplate.LongName, ref strongName, nullableBoolConverter, "OSS sign the output assembly"); syntax.DefineOption(s_emitEntryPointTemplate.LongName, ref emitEntryPoint, nullableBoolConverter, "Output an executable console program"); return new CommonCompilerOptions { Defines = defines, LanguageVersion = languageVersion, Platform = platform, AllowUnsafe = allowUnsafe, WarningsAsErrors = warningsAsErrors, Optimize = optimize, KeyFile = keyFile, DelaySign = delaySign, UseOssSigning = strongName, EmitEntryPoint = emitEntryPoint }; }
protected override void ParseOptions(ArgumentSyntax syntax) { syntax.DefineOption("w|watch", ref _watch, "Watches the input folder for any changes."); _preview = syntax.DefineOption("p|preview", ref _previewPort, false, "Start the preview web server on the specified port (default is " + _previewPort + ").").IsSpecified; if (syntax.DefineOption("force-ext", ref _previewForceExtension, "Force the use of extensions in the preview web server (by default, extensionless URLs may be used).").IsSpecified&& !_preview) { syntax.ReportError("force-ext can only be specified if the preview server is running."); } if (syntax.DefineOption("preview-root", ref _previewRoot, DirectoryPath.FromString, "The path to the root of the preview server, if not the output folder.").IsSpecified&& !_preview) { syntax.ReportError("preview-root can only be specified if the preview server is running."); } syntax.DefineOptionList("i|input", ref _configOptions.InputPaths, DirectoryPath.FromString, "The path(s) of input files, can be absolute or relative to the current folder."); syntax.DefineOption("o|output", ref _configOptions.OutputPath, DirectoryPath.FromString, "The path to output files, can be absolute or relative to the current folder."); syntax.DefineOption("c|config", ref _configOptions.ConfigFilePath, FilePath.FromString, "Configuration file (by default, config.wyam is used)."); syntax.DefineOption("u|update-packages", ref _configOptions.UpdatePackages, "Check the NuGet server for more recent versions of each package and update them if applicable."); syntax.DefineOption("use-local-packages", ref _configOptions.UseLocalPackages, "Toggles the use of a local NuGet packages folder."); syntax.DefineOption("use-global-sources", ref _configOptions.UseGlobalSources, "Toggles the use of the global NuGet sources (default is false)."); syntax.DefineOption("packages-path", ref _configOptions.PackagesPath, DirectoryPath.FromString, "The packages path to use (only if use-local is true)."); syntax.DefineOption("output-script", ref _configOptions.OutputScript, "Outputs the config script after it's been processed for further debugging."); syntax.DefineOption("verify-config", ref _verifyConfig, false, "Compile the configuration but do not execute."); syntax.DefineOption("noclean", ref _configOptions.NoClean, "Prevents cleaning of the output path on each execution."); syntax.DefineOption("nocache", ref _configOptions.NoCache, "Prevents caching information during execution (less memory usage but slower execution)."); _logFilePath = $"wyam-{DateTime.Now:yyyyMMddHHmmssfff}.txt"; if (!syntax.DefineOption("l|log", ref _logFilePath, FilePath.FromString, false, "Log all trace messages to the specified log file (by default, wyam-[datetime].txt).").IsSpecified) { _logFilePath = null; } // Metadata IReadOnlyList <string> globalMetadata = null; if (syntax.DefineOptionList("g|global", ref globalMetadata, "Specifies global metadata as a sequence of key=value pairs. Use the syntax [x,y] to specify array values.").IsSpecified) { _configOptions.GlobalMetadata = MetadataParser.Parse(globalMetadata); } IReadOnlyList <string> initialMetadata = null; if (syntax.DefineOptionList("initial", ref initialMetadata, "Specifies initial document metadata as a sequence of key=value pairs. Use the syntax [x,y] to specify array values.").IsSpecified) { _configOptions.InitialMetadata = MetadataParser.Parse(initialMetadata); } }
protected override void ParseOptions(ArgumentSyntax syntax) { syntax.DefineOption("w|watch", ref _watch, "Watches the input folder for any changes."); _preview = syntax.DefineOption("p|preview", ref _previewPort, false, "Start the preview web server on the specified port (default is " + _previewPort + ").").IsSpecified; if (syntax.DefineOption("force-ext", ref _previewForceExtension, "Force the use of extensions in the preview web server (by default, extensionless URLs may be used).").IsSpecified && !_preview) { syntax.ReportError("force-ext can only be specified if the preview server is running."); } if (syntax.DefineOption("preview-root", ref _previewRoot, DirectoryPath.FromString, "The path to the root of the preview server, if not the output folder.").IsSpecified && !_preview) { syntax.ReportError("preview-root can only be specified if the preview server is running."); } syntax.DefineOptionList("i|input", ref _configOptions.InputPaths, DirectoryPath.FromString, "The path(s) of input files, can be absolute or relative to the current folder."); syntax.DefineOption("o|output", ref _configOptions.OutputPath, DirectoryPath.FromString, "The path to output files, can be absolute or relative to the current folder."); syntax.DefineOption("c|config", ref _configOptions.ConfigFilePath, FilePath.FromString, "Configuration file (by default, config.wyam is used)."); syntax.DefineOption("u|update-packages", ref _configOptions.UpdatePackages, "Check the NuGet server for more recent versions of each package and update them if applicable."); syntax.DefineOption("use-local-packages", ref _configOptions.UseLocalPackages, "Toggles the use of a local NuGet packages folder."); syntax.DefineOption("use-global-sources", ref _configOptions.UseGlobalSources, "Toggles the use of the global NuGet sources (default is false)."); syntax.DefineOption("packages-path", ref _configOptions.PackagesPath, DirectoryPath.FromString, "The packages path to use (only if use-local is true)."); syntax.DefineOption("output-script", ref _configOptions.OutputScript, "Outputs the config script after it's been processed for further debugging."); syntax.DefineOption("verify-config", ref _verifyConfig, false, "Compile the configuration but do not execute."); syntax.DefineOption("noclean", ref _configOptions.NoClean, "Prevents cleaning of the output path on each execution."); syntax.DefineOption("nocache", ref _configOptions.NoCache, "Prevents caching information during execution (less memory usage but slower execution)."); _logFilePath = $"wyam-{DateTime.Now:yyyyMMddHHmmssfff}.txt"; if (!syntax.DefineOption("l|log", ref _logFilePath, FilePath.FromString, false, "Log all trace messages to the specified log file (by default, wyam-[datetime].txt).").IsSpecified) { _logFilePath = null; } // Metadata IReadOnlyList<string> globalMetadata = null; if (syntax.DefineOptionList("g|global", ref globalMetadata, "Specifies global metadata as a sequence of key=value pairs.").IsSpecified) { _configOptions.GlobalMetadata = MetadataParser.Parse(globalMetadata); } IReadOnlyList<string> initialMetadata = null; if (syntax.DefineOptionList("initial", ref initialMetadata, "Specifies initial document metadata as a sequence of key=value pairs.").IsSpecified) { _configOptions.InitialMetadata = MetadataParser.Parse(initialMetadata); } }
protected override void ParseOptions(ArgumentSyntax syntax) { syntax.DefineOption("p|port", ref _port, "Start the preview web server on the specified port (default is " + _port + ")."); syntax.DefineOption("force-ext", ref _forceExtension, "Force the use of extensions in the preview web server (by default, extensionless URLs may be used)."); syntax.DefineOption("virtual-dir", ref _virtualDirectory, DirectoryPathFromArg, "Serve files in the preview web server under the specified virtual directory."); IReadOnlyList <string> contentTypes = null; if (syntax.DefineOptionList("content-type", ref contentTypes, "Specifies additional supported content types for the preview server as extension=contenttype.").IsSpecified) { AddContentTypes(contentTypes, _contentTypes, syntax); } }
public void Parse(ArgumentSyntax syntax, Preprocessor preprocessor) { // Global options if (GlobalArguments) { syntax.DefineOption("v|verbose", ref _verbose, "Turns on verbose output showing additional trace message useful for debugging."); syntax.DefineOption("attach", ref _attach, "Pause execution at the start of the program until a debugger is attached."); } // Command options ParseOptions(syntax); // Directives if (SupportedDirectives != null) { foreach (IDirective directive in preprocessor.Directives .Where(x => SupportedDirectives.Contains(x.Name, StringComparer.OrdinalIgnoreCase))) { // Get the option name and help text string optionName = (string.IsNullOrEmpty(directive.ShortName) ? string.Empty : directive.ShortName + "|") + directive.Name; string optionHelp = $"{directive.Description}{(string.IsNullOrEmpty(directive.GetHelpText()) ? string.Empty : " See below for syntax details.")}"; // Single or multiple? if (directive.SupportsMultiple) { // Multiple IReadOnlyList <string> directiveValues = null; syntax.DefineOptionList(optionName, ref directiveValues, optionHelp); if (directiveValues != null) { foreach (string directiveValue in directiveValues) { preprocessor.AddValue(new DirectiveValue(directive.Name, directiveValue)); } } } else { // Single string directiveValue = null; syntax.DefineOption(optionName, ref directiveValue, optionHelp); if (directiveValue != null) { preprocessor.AddValue(new DirectiveValue(directive.Name, directiveValue)); } } } } // Command parameters ParseParameters(syntax); }
public void Parse(ArgumentSyntax syntax, Preprocessor preprocessor) { // Global options if(GlobalArguments) { syntax.DefineOption("v|verbose", ref _verbose, "Turns on verbose output showing additional trace message useful for debugging."); syntax.DefineOption("attach", ref _attach, "Pause execution at the start of the program until a debugger is attached."); } // Command options ParseOptions(syntax); // Directives if (SupportedDirectives != null) { foreach (IDirective directive in preprocessor.Directives .Where(x => SupportedDirectives.Contains(x.Name, StringComparer.OrdinalIgnoreCase))) { // Get the option name and help text string optionName = (string.IsNullOrEmpty(directive.ShortName) ? string.Empty : directive.ShortName + "|") + directive.Name; string optionHelp = $"{directive.Description}{(string.IsNullOrEmpty(directive.GetHelpText()) ? string.Empty : " See below for syntax details.")}"; // Single or multiple? if (directive.SupportsMultiple) { // Multiple IReadOnlyList<string> directiveValues = null; syntax.DefineOptionList(optionName, ref directiveValues, optionHelp); if (directiveValues != null) { foreach (string directiveValue in directiveValues) { preprocessor.AddValue(new DirectiveValue(directive.Name, directiveValue)); } } } else { // Single string directiveValue = null; syntax.DefineOption(optionName, ref directiveValue, optionHelp); if (directiveValue != null) { preprocessor.AddValue(new DirectiveValue(directive.Name, directiveValue)); } } } } // Command parameters ParseParameters(syntax); }
protected static void DefineManifestFilterOptions(ArgumentSyntax syntax, IManifestFilterOptions filterOptions) { filterOptions.Architecture = DefineArchitectureOption(syntax); string osVersion = null; syntax.DefineOption( "os-version", ref osVersion, "OS version of the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)"); filterOptions.OsVersion = osVersion; IReadOnlyList <string> paths = Array.Empty <string>(); syntax.DefineOptionList( "path", ref paths, "Directory paths containing the Dockerfiles to build - wildcard chars * and ? supported (default is to build all)"); filterOptions.Paths = paths; }
private AuthorizationOptions DefineAuthorizationCommand(ArgumentSyntax syntax) { var options = new AuthorizationOptions(); syntax.DefineCommand("authz", ref command, Command.Authorization, "Perform identifier authorization."); syntax.DefineOption("t|type", ref options.Type, "Type of authorization challenge to process. (default: None)"); syntax.DefineOptionList("v|value", ref options.Values, $"One or more names for authorization."); syntax.DefineOption("value-path", ref options.ValuesFile, $"The path of file contains one or more names for authorization."); syntax.DefineOption("complete-authz", ref options.Complete, $"Complete authz."); syntax.DefineOption("k|key-authz", ref options.KeyAuthentication, $"Print key authz."); syntax.DefineOption("r|refresh", ref options.Refresh, $"Print key authz."); syntax.DefineOption("server", ref options.Server, s => new Uri(s), $"ACME Directory Resource URI. (default: {options.Server})"); syntax.DefineOption("p|path", ref options.Path, $"File path used to load/save the registration. (default: {options.Path})"); syntax.DefineOption("f|force", ref options.Force, $"Force"); return(options); }
protected override void Define(ArgumentSyntax syntax, Settings settings) { syntax.DefineOption("p|prerelease", ref settings.Prerelease, "Specifies that prerelease packages are allowed."); syntax.DefineOption("u|unlisted", ref settings.Unlisted, "Specifies that unlisted packages are allowed."); syntax.DefineOption("v|version", ref settings.VersionRange, "Specifies the version range of the package to use."); if (syntax.DefineOption("l|latest", ref settings.Latest, "Specifies that the latest available version of the package should be used (this will always trigger a request to the sources).").IsSpecified && !string.IsNullOrEmpty(settings.VersionRange)) { syntax.ReportError("latest cannot be specified if a version range is specified."); } syntax.DefineOptionList("s|source", ref settings.Sources, "Specifies the package source(s) to get the package from."); if (syntax.DefineOption("e|exclusive", ref settings.Exclusive, "Indicates that only the specified package source(s) should be used to find the package.").IsSpecified && settings.Sources == null) { syntax.ReportError("exclusive can only be used if sources are specified."); } if (!syntax.DefineParameter("package", ref settings.Package, "The package to install.").IsSpecified) { syntax.ReportError("a package must be specified."); } }
public override void DefineOptions(ArgumentSyntax syntax) { base.DefineOptions(syntax); const string DefaultSubscriptionsPath = "subscriptions.json"; string subscriptionsPath = DefaultSubscriptionsPath; syntax.DefineOption( "subscriptions-path", ref subscriptionsPath, $"Path to the subscriptions file (defaults to '{DefaultSubscriptionsPath}')."); SubscriptionsPath = subscriptionsPath; IReadOnlyList <string> allSubscriptionImagePaths = Array.Empty <string>(); syntax.DefineOptionList( "image-paths", ref allSubscriptionImagePaths, "JSON string mapping a subscription ID to the image paths to be built (from the output variable of getStaleImages)"); AllSubscriptionImagePaths = allSubscriptionImagePaths; }
public override void DefineOptions(ArgumentSyntax syntax) { base.DefineOptions(syntax); FilterOptions.DefineOptions(syntax); MatrixType matrixType = MatrixType.PlatformDependencyGraph; syntax.DefineOption( "type", ref matrixType, value => (MatrixType)Enum.Parse(typeof(MatrixType), value, true), $"Type of matrix to generate. {EnumHelper.GetHelpTextOptions(matrixType)}"); MatrixType = matrixType; IReadOnlyList <string> customBuildLegGroups = Array.Empty <string>(); syntax.DefineOptionList( "custom-build-leg-group", ref customBuildLegGroups, "Name of custom build leg group to use."); CustomBuildLegGroups = customBuildLegGroups; int productVersionComponents = 2; syntax.DefineOption( "product-version-components", ref productVersionComponents, "Number of components of the product version considered to be significant"); ProductVersionComponents = productVersionComponents; string imageInfoPath = null; syntax.DefineOption( "image-info", ref imageInfoPath, "Path to image info file"); ImageInfoPath = imageInfoPath; }
public static CommonCompilerOptions Parse(ArgumentSyntax syntax) { IReadOnlyList<string> defines = null; IReadOnlyList<string> suppressWarnings = null; string languageVersion = null; string platform = null; string debugType = null; bool? allowUnsafe = null; bool? warningsAsErrors = null; bool? optimize = null; string keyFile = null; bool? delaySign = null; bool? publicSign = null; bool? emitEntryPoint = null; bool? generateXmlDocumentation = null; string outputName = null; IReadOnlyList<string> additionalArguments = null; Func<string, bool?> nullableBoolConverter = v => bool.Parse(v); syntax.DefineOptionList(s_definesTemplate.LongName, ref defines, "Preprocessor definitions"); syntax.DefineOptionList(s_suppressWarningTemplate.LongName, ref suppressWarnings, "Suppresses the specified warning"); syntax.DefineOptionList(s_additionalArgumentsTemplate.LongName, ref additionalArguments, "Pass the additional argument directly to the compiler"); syntax.DefineOption(s_debugTypeTemplate.LongName, ref debugType, "The type of PDB to emit: portable or full"); syntax.DefineOption(s_languageVersionTemplate.LongName, ref languageVersion, "The version of the language used to compile"); syntax.DefineOption(s_platformTemplate.LongName, ref platform, "The target platform"); syntax.DefineOption(s_allowUnsafeTemplate.LongName, ref allowUnsafe, nullableBoolConverter, "Allow unsafe code"); syntax.DefineOption(s_warningsAsErrorsTemplate.LongName, ref warningsAsErrors, nullableBoolConverter, "Turn all warnings into errors"); syntax.DefineOption(s_optimizeTemplate.LongName, ref optimize, nullableBoolConverter, "Enable compiler optimizations"); syntax.DefineOption(s_keyFileTemplate.LongName, ref keyFile, "Path to file containing the key to strong-name sign the output assembly"); syntax.DefineOption(s_delaySignTemplate.LongName, ref delaySign, nullableBoolConverter, "Delay-sign the output assembly"); syntax.DefineOption(s_publicSignTemplate.LongName, ref publicSign, nullableBoolConverter, "Public-sign the output assembly"); syntax.DefineOption(s_emitEntryPointTemplate.LongName, ref emitEntryPoint, nullableBoolConverter, "Output an executable console program"); syntax.DefineOption(s_generateXmlDocumentation.LongName, ref generateXmlDocumentation, nullableBoolConverter, "Generate XML documentation file"); syntax.DefineOption(s_outputNameTemplate.LongName, ref outputName, "Output assembly name"); return new CommonCompilerOptions { Defines = defines, SuppressWarnings = suppressWarnings, LanguageVersion = languageVersion, Platform = platform, AllowUnsafe = allowUnsafe, WarningsAsErrors = warningsAsErrors, Optimize = optimize, KeyFile = keyFile, DelaySign = delaySign, PublicSign = publicSign, DebugType = debugType, EmitEntryPoint = emitEntryPoint, GenerateXmlDocumentation = generateXmlDocumentation, OutputName = outputName, AdditionalArguments = additionalArguments }; }
public static CommonCompilerOptions Parse(ArgumentSyntax syntax) { IReadOnlyList <string> defines = null; IReadOnlyList <string> suppressWarnings = null; string languageVersion = null; string platform = null; string debugType = null; bool? allowUnsafe = null; bool? warningsAsErrors = null; bool? optimize = null; string keyFile = null; bool? delaySign = null; bool? publicSign = null; bool? emitEntryPoint = null; bool? generateXmlDocumentation = null; IReadOnlyList <string> additionalArguments = null; Func <string, bool?> nullableBoolConverter = v => bool.Parse(v); syntax.DefineOptionList(s_definesTemplate.LongName, ref defines, "Preprocessor definitions"); syntax.DefineOptionList(s_suppressWarningTemplate.LongName, ref suppressWarnings, "Suppresses the specified warning"); syntax.DefineOptionList(s_additionalArgumentsTemplate.LongName, ref additionalArguments, "Pass the additional argument directly to the compiler"); syntax.DefineOption(s_debugTypeTemplate.LongName, ref debugType, "The type of PDB to emit: portable or full"); syntax.DefineOption(s_languageVersionTemplate.LongName, ref languageVersion, "The version of the language used to compile"); syntax.DefineOption(s_platformTemplate.LongName, ref platform, "The target platform"); syntax.DefineOption(s_allowUnsafeTemplate.LongName, ref allowUnsafe, nullableBoolConverter, "Allow unsafe code"); syntax.DefineOption(s_warningsAsErrorsTemplate.LongName, ref warningsAsErrors, nullableBoolConverter, "Turn all warnings into errors"); syntax.DefineOption(s_optimizeTemplate.LongName, ref optimize, nullableBoolConverter, "Enable compiler optimizations"); syntax.DefineOption(s_keyFileTemplate.LongName, ref keyFile, "Path to file containing the key to strong-name sign the output assembly"); syntax.DefineOption(s_delaySignTemplate.LongName, ref delaySign, nullableBoolConverter, "Delay-sign the output assembly"); syntax.DefineOption(s_publicSignTemplate.LongName, ref publicSign, nullableBoolConverter, "Public-sign the output assembly"); syntax.DefineOption(s_emitEntryPointTemplate.LongName, ref emitEntryPoint, nullableBoolConverter, "Output an executable console program"); syntax.DefineOption(s_generateXmlDocumentation.LongName, ref generateXmlDocumentation, nullableBoolConverter, "Generate XML documentation file"); return(new CommonCompilerOptions { Defines = defines, SuppressWarnings = suppressWarnings, LanguageVersion = languageVersion, Platform = platform, AllowUnsafe = allowUnsafe, WarningsAsErrors = warningsAsErrors, Optimize = optimize, KeyFile = keyFile, DelaySign = delaySign, PublicSign = publicSign, DebugType = debugType, EmitEntryPoint = emitEntryPoint, GenerateXmlDocumentation = generateXmlDocumentation, AdditionalArguments = additionalArguments }); }
protected override void ParseOptions(ArgumentSyntax syntax) { syntax.DefineOption("w|watch", ref _watch, "Watches the input folder for any changes."); _preview = syntax.DefineOption("p|preview", ref _previewPort, false, "Start the preview web server on the specified port (default is " + _previewPort + ").").IsSpecified; if (syntax.DefineOption("force-ext", ref _previewForceExtension, "Force the use of extensions in the preview web server (by default, extensionless URLs may be used).").IsSpecified&& !_preview) { syntax.ReportError("force-ext can only be specified if the preview server is running."); } if (syntax.DefineOption("virtual-dir", ref _previewVirtualDirectory, DirectoryPathFromArg, "Serve files in the preview web server under the specified virtual directory.").IsSpecified&& !_preview) { syntax.ReportError("virtual-dir can only be specified if the preview server is running."); } if (syntax.DefineOption("preview-root", ref _previewRoot, DirectoryPathFromArg, "The path to the root of the preview server, if not the output folder.").IsSpecified&& !_preview) { syntax.ReportError("preview-root can only be specified if the preview server is running."); } if (syntax.DefineOption("noreload", ref _noReload, "Turns off LiveReload support in the preview server.").IsSpecified&& (!_preview || !_watch)) { syntax.ReportError("noreload can only be specified if both the preview server is running and watching is enabled."); } IReadOnlyList <string> contentTypes = null; if (syntax.DefineOptionList("content-type", ref contentTypes, "Specifies additional supported content types for the preview server as extension=contenttype.").IsSpecified) { if (!_preview) { syntax.ReportError("content-type can only be specified if the preview server is running."); } else { PreviewCommand.AddContentTypes(contentTypes, _contentTypes, syntax); } } syntax.DefineOptionList("i|input", ref _configOptions.InputPaths, DirectoryPathFromArg, "The path(s) of input files, can be absolute or relative to the current folder."); syntax.DefineOption("o|output", ref _configOptions.OutputPath, DirectoryPathFromArg, "The path to output files, can be absolute or relative to the current folder."); syntax.DefineOption("c|config", ref _configOptions.ConfigFilePath, FilePath.FromString, "Configuration file (by default, config.wyam is used)."); syntax.DefineOption("u|update-packages", ref _configOptions.UpdatePackages, "Check the NuGet server for more recent versions of each package and update them if applicable."); syntax.DefineOption("use-local-packages", ref _configOptions.UseLocalPackages, "Toggles the use of a local NuGet packages folder."); syntax.DefineOption("use-global-sources", ref _configOptions.UseGlobalSources, "Toggles the use of the global NuGet sources (default is false)."); syntax.DefineOption("ignore-default-sources", ref _configOptions.IgnoreDefaultSources, "Ignores default NuGet sources like the NuGet Gallery (default is false)."); syntax.DefineOption("packages-path", ref _configOptions.PackagesPath, DirectoryPathFromArg, "The packages path to use (only if use-local is true)."); syntax.DefineOption("no-output-config-assembly", ref _configOptions.NoOutputConfigAssembly, "Disable caching configuration file compulation."); syntax.DefineOption("ignore-config-hash", ref _configOptions.IgnoreConfigHash, "Force evaluating the configuration file, even when no changes were detected."); syntax.DefineOption("output-script", ref _configOptions.OutputScript, "Outputs the config script after it's been processed for further debugging. The directive --ignore-config-hash is required when using this option."); syntax.DefineOption("verify-config", ref _verifyConfig, false, "Compile the configuration but do not execute. The directive --ignore-config-hash is required when using this option."); if (_configOptions.OutputScript && !_configOptions.IgnoreConfigHash) { syntax.ReportError("The directive --output-script can only be specified if --ignore-config-hash is also specified."); } if (_verifyConfig && !_configOptions.IgnoreConfigHash) { syntax.ReportError("The directive --verify-config can only be specified if --ignore-config-hash is also specified."); } syntax.DefineOption("noclean", ref _configOptions.NoClean, "Prevents cleaning of the output path on each execution."); syntax.DefineOption("nocache", ref _configOptions.NoCache, "Prevents caching information during execution (less memory usage but slower execution)."); _logFilePath = $"wyam-{DateTime.Now:yyyyMMddHHmmssfff}.txt"; if (!syntax.DefineOption("l|log", ref _logFilePath, FilePath.FromString, false, "Log all trace messages to the specified log file (by default, wyam-[datetime].txt).").IsSpecified) { _logFilePath = null; } // Metadata // TODO: Remove this dictionary and initial/global options Dictionary <string, object> settingsDictionary = new Dictionary <string, object>(); IReadOnlyList <string> globalMetadata = null; if (syntax.DefineOptionList("g|global", ref globalMetadata, "Deprecated, do not use.").IsSpecified) { Trace.Warning("-g/--global is deprecated and will be removed in a future version. Please use -s/--setting instead."); AddSettings(settingsDictionary, globalMetadata); } IReadOnlyList <string> initialMetadata = null; if (syntax.DefineOptionList("initial", ref initialMetadata, "Deprecated, do not use.").IsSpecified) { Trace.Warning("--initial is deprecated and will be removed in a future version. Please use -s/--setting instead."); AddSettings(settingsDictionary, initialMetadata); } IReadOnlyList <string> settings = null; if (syntax.DefineOptionList("s|setting", ref settings, "Specifies a setting as a key=value pair. Use the syntax [x,y] to specify an array value.").IsSpecified) { // _configOptions.Settings = MetadataParser.Parse(settings); TODO: Use this when AddSettings() is removed AddSettings(settingsDictionary, settings); } if (settingsDictionary.Count > 0) { _configOptions.Settings = settingsDictionary; } }
void DefineArgumentSyntax(ArgumentSyntax syntax) { bool activeCommandIsCommandAssociatedWithTraceProcessing = false; syntax.ApplicationName = typeof(Program).Assembly.GetName().Name.ToString(); // HandleHelp writes to error, fails fast with crash dialog and lacks custom formatting. syntax.HandleHelp = false; syntax.HandleErrors = false; string command = ""; void CommonOptions() { string traceFile = null; syntax.DefineOption( name: "t|trace", value: ref traceFile, help: "Specify the trace file to be parsed.", requireValue: true); if (traceFile != null) { TraceFile = new FileInfo(traceFile); } OutputOption(); int pidLocal = 0; if (syntax.DefineOption( name: "pid", value: ref pidLocal, help: "The pid within the trace of the process to examine. If this is a multi-process trace, at least one of --pid or --process-name must be specified", requireValue: true).IsSpecified) { Pid = pidLocal; } syntax.DefineOption( name: "process-name", value: ref ProcessName, help: "The process name within the trace of the process to examine. If this is a multi-process trace, at least one of --pid or --process-name must be specified.", requireValue: false); int clrInstanceIdLocal = 0; if (syntax.DefineOption( name: "clr-instance-id", value: ref clrInstanceIdLocal, help: "If the process contains multiple .NET runtimes, the instance ID must be specified.", requireValue: true).IsSpecified) { ClrInstanceId = clrInstanceIdLocal; } Reference = DefineFileOptionList(name: "r|reference", help: "If a reference is not located on disk at the same location as used in the process, it may be specified with a --reference parameter. Multiple --reference parameters may be specified. The wild cards * and ? are supported by this option."); ExcludeEventsBefore = Double.MinValue; syntax.DefineOption( name: "exclude-events-before", value: ref ExcludeEventsBefore, help: "Exclude data from events before specified time. Time is specified as milliseconds from the start of the trace.", valueConverter: Convert.ToDouble, requireValue: true); ExcludeEventsAfter = Double.MaxValue; syntax.DefineOption( name: "exclude-events-after", value: ref ExcludeEventsAfter, help: "Exclude data from events after specified time. Time is specified as milliseconds from the start of the trace.", valueConverter: Convert.ToDouble, requireValue: true); VerbosityOption(); } void OutputOption() { string outputFile = null; syntax.DefineOption( name: "o|output", value: ref outputFile, help: "Specify the output filename to be created.", requireValue: true); if (outputFile != null) { OutputFileName = new FileInfo(outputFile); } } void VerbosityOption() { Verbosity verbosity = Verbosity.normal; syntax.DefineOption(name: "v|verbosity", value: ref verbosity, help: "Adjust verbosity level. Supported levels are minimal, normal, detailed, and diagnostic.", valueConverter: VerbosityConverter, requireValue: true); BasicProgressMessages = (int)verbosity >= (int)Verbosity.normal; Warnings = (int)verbosity >= (int)Verbosity.normal; VerboseWarnings = (int)verbosity >= (int)Verbosity.detailed; DetailedProgressMessages = (int)verbosity >= (int)Verbosity.detailed; DisplayProcessedEvents = (int)verbosity >= (int)Verbosity.diagnostic; } void CompressedOption() { bool compressed = false; syntax.DefineOption(name: "compressed", value: ref compressed, help: "Generate compressed mibc", requireValue: false); Uncompressed = !compressed; } void HelpOption() { syntax.DefineOption("h|help", ref Help, "Display this usage message."); } var mibcCommand = syntax.DefineCommand(name: "create-mibc", value: ref command, help: "Transform a trace file into a Mibc profile data file."); if (mibcCommand.IsActive) { activeCommandIsCommandAssociatedWithTraceProcessing = true; HelpArgs = new string[] { "create-mibc", "--help", "--trace", "trace", "--output", "output" }; FileType = PgoFileType.mibc; GenerateCallGraph = true; ProcessJitEvents = true; ProcessR2REvents = true; #if DEBUG ValidateOutputFile = true; #else ValidateOutputFile = false; #endif CommonOptions(); CompressedOption(); string preciseDebugInfoFile = null; syntax.DefineOption(name: "precise-debug-info-file", ref preciseDebugInfoFile, "Name of file of newline separated JSON objects containing precise debug info"); if (preciseDebugInfoFile != null) { PreciseDebugInfoFile = new FileInfo(preciseDebugInfoFile); } syntax.DefineOption(name: "spgo", value: ref Spgo, help: "Base profile on samples in the input. Uses last branch records if available and otherwise raw IP samples.", requireValue: false); syntax.DefineOption(name: "spgo-min-samples", value: ref SpgoMinSamples, help: $"The minimum number of total samples a function must have before generating profile data for it with SPGO. Default: {SpgoMinSamples}", requireValue: false); syntax.DefineOption(name: "include-full-graphs", value: ref IncludeFullGraphs, help: "Include all blocks and edges in the written .mibc file, regardless of profile counts", requireValue: false); HelpOption(); } JitTraceOptions = JitTraceOptions.none; #if DEBUG // Usage of the jittrace format requires using logic embedded in the runtime repository and isn't suitable for general consumer use at this time // Build it in debug and check builds to ensure that it doesn't bitrot, and remains available for use by developers willing to build the repo var jittraceCommand = syntax.DefineCommand(name: "create-jittrace", value: ref command, help: "Transform a trace file into a jittrace runtime file."); if (jittraceCommand.IsActive) { activeCommandIsCommandAssociatedWithTraceProcessing = true; HelpArgs = new string[] { "create-jittrace", "--help", "--trace", "trace", "--output", "output" }; FileType = PgoFileType.jittrace; ProcessJitEvents = true; ProcessR2REvents = false; ValidateOutputFile = false; CommonOptions(); bool sorted = false; syntax.DefineOption(name: "sorted", value: ref sorted, help: "Generate sorted output.", requireValue: false); if (sorted) { JitTraceOptions |= JitTraceOptions.sorted; } bool showtimestamp = false; syntax.DefineOption(name: "showtimestamp", value: ref showtimestamp, help: "Show timestamps in output.", requireValue: false); if (showtimestamp) { JitTraceOptions |= JitTraceOptions.showtimestamp; } syntax.DefineOption(name: "includeReadyToRun", value: ref ProcessR2REvents, help: "Include ReadyToRun methods in the trace file.", requireValue: false); HelpOption(); } #endif var mergeCommand = syntax.DefineCommand(name: "merge", value: ref command, help: "Merge multiple Mibc profile data files into one file."); if (mergeCommand.IsActive) { HelpArgs = new string[] { "merge", "--help", "--output", "output", "--input", "input" }; InputFilesToMerge = DefineFileOptionList(name: "i|input", help: "Input .mibc files to be merged. Multiple input arguments are specified as --input file1.mibc --input file2.mibc"); OutputOption(); IReadOnlyList <string> assemblyNamesAsStrings = null; syntax.DefineOptionList(name: "include-reference", value: ref assemblyNamesAsStrings, help: "If specified, include in Mibc file only references to the specified assemblies. Assemblies are specified as assembly names, not filenames. For instance, `System.Private.CoreLib` not `System.Private.CoreLib.dll`. Multiple --include-reference options may be specified.", requireValue: true); if (assemblyNamesAsStrings != null) { foreach (string asmName in assemblyNamesAsStrings) { try { IncludedAssemblies.Add(new AssemblyName(asmName)); } catch { throw new FormatException($"Unable to parse '{asmName}' as an Assembly Name."); } } } syntax.DefineOption(name: "inherit-timestamp", value: ref InheritTimestamp, help: "If specified, set the output's timestamp to the max timestamp of the input files"); VerbosityOption(); CompressedOption(); HelpOption(); #if DEBUG ValidateOutputFile = true; #else ValidateOutputFile = false; #endif } var dumpCommand = syntax.DefineCommand(name: "dump", value: ref command, help: "Dump the contents of a Mibc file."); if (dumpCommand.IsActive) { DumpMibc = true; HelpArgs = new string[] { "dump", "--help", "input", "output" }; VerbosityOption(); HelpOption(); string inputFileToDump = null; syntax.DefineParameter(name: "input", ref inputFileToDump, "Name of the input mibc file to dump."); if (inputFileToDump != null) { InputFileToDump = new FileInfo(inputFileToDump); } string outputFile = null; syntax.DefineParameter(name: "output", ref outputFile, "Name of the output dump file."); if (outputFile != null) { OutputFileName = new FileInfo(outputFile); } } var compareMibcCommand = syntax.DefineCommand(name: "compare-mibc", value: ref command, help: "Compare two .mibc files"); if (compareMibcCommand.IsActive) { HelpArgs = new[] { "compare-mibc", "--input", "first.mibc", "--input", "second.mibc" }; CompareMibc = DefineFileOptionList(name: "i|input", help: "The input .mibc files to be compared. Specify as --input file1.mibc --input file2.mibc"); if (CompareMibc.Count != 2) { Help = true; } syntax.DefineOption(name: "dump-worst-overlap-graphs", value: ref DumpWorstOverlapGraphs, help: "Number of graphs to dump to .dot format in dump-worst-overlap-graphs-to directory"); string dumpWorstOverlapGraphsTo = null; syntax.DefineOption(name: "dump-worst-overlap-graphs-to", value: ref dumpWorstOverlapGraphsTo, help: "Number of graphs to dump to .dot format in dump-worst-overlap-graphs-to directory"); if (dumpWorstOverlapGraphsTo != null) { DumpWorstOverlapGraphsTo = new DirectoryInfo(dumpWorstOverlapGraphsTo); } } if (syntax.ActiveCommand == null) { // No command specified Help = true; } if (activeCommandIsCommandAssociatedWithTraceProcessing) { HelpText = @$ "{syntax.GetHelpText()} Example tracing commands used to generate the input to this tool: " "dotnet-trace collect -p 73060 --providers Microsoft-Windows-DotNETRuntime:0x1E000080018:4" " - Capture events from process 73060 where we capture both JIT and R2R events using EventPipe tracing " "dotnet-trace collect -p 73060 --providers Microsoft-Windows-DotNETRuntime:0x1C000080018:4" " - Capture events from process 73060 where we capture only JIT events using EventPipe tracing " "perfview collect -LogFile:logOfCollection.txt -DataFile:jittrace.etl -Zip:false -merge:false -providers:Microsoft-Windows-DotNETRuntime:0x1E000080018:4" " - Capture Jit and R2R events via perfview of all processes running using ETW tracing "; } else { HelpText = syntax.GetHelpText(); } List <FileInfo> DefineFileOptionList(string name, string help) { IReadOnlyList <string> filesAsStrings = null; syntax.DefineOptionList(name: name, value: ref filesAsStrings, help: help, requireValue: true); List <FileInfo> referenceList = new List <FileInfo>(); if (filesAsStrings != null) { foreach (string pattern in filesAsStrings) { Dictionary <string, string> paths = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); Helpers.AppendExpandedPaths(paths, pattern, false); foreach (string file in paths.Values) { referenceList.Add(new FileInfo(file)); } } } return(referenceList); } }
void DefineArgumentSyntax(ArgumentSyntax syntax) { bool activeCommandIsCommandAssociatedWithTraceProcessing = false; syntax.ApplicationName = typeof(Program).Assembly.GetName().Name.ToString(); // HandleHelp writes to error, fails fast with crash dialog and lacks custom formatting. syntax.HandleHelp = false; syntax.HandleErrors = false; string command = ""; void CommonOptions() { string traceFile = null; FailIfUnspecified(syntax.DefineOption( name: "t|trace", value: ref traceFile, help: "Specify the trace file to be parsed.", requireValue: true)); if (traceFile != null) { TraceFile = new FileInfo(traceFile); } string outputFile = null; FailIfUnspecified(syntax.DefineOption( name: "o|output", value: ref outputFile, help: "Specify the output filename to be created.", requireValue: true)); if (outputFile != null) { OutputFileName = new FileInfo(outputFile); } int pidLocal = 0; if (syntax.DefineOption( name: "pid", value: ref pidLocal, help: "The pid within the trace of the process to examine. If this is a multi-process trace, at least one of --pid or --process-name must be specified", requireValue: true).IsSpecified) { Pid = pidLocal; } syntax.DefineOption( name: "process-name", value: ref ProcessName, help: "The process name within the trace of the process to examine. If this is a multi-process trace, at least one of --pid or --process-name must be specified.", requireValue: false); int clrInstanceIdLocal = 0; if (syntax.DefineOption( name: "clr-instance-id", value: ref clrInstanceIdLocal, help: "If the process contains multiple .NET runtimes, the instance ID must be specified.", requireValue: true).IsSpecified) { ClrInstanceId = clrInstanceIdLocal; } IReadOnlyList <string> referencesAsStrings = null; syntax.DefineOptionList(name: "r|reference", value: ref referencesAsStrings, help: "If a reference is not located on disk at the same location as used in the process, it may be specified with a --reference parameter. Multiple --reference parameters may be specified. The wild cards * and ? are supported by this option.", requireValue: true); List <FileInfo> referenceList = new List <FileInfo>(); Reference = referenceList; if (referencesAsStrings != null) { foreach (string pattern in referencesAsStrings) { Dictionary <string, string> paths = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); Helpers.AppendExpandedPaths(paths, pattern, false); foreach (string file in paths.Values) { referenceList.Add(new FileInfo(file)); } } } syntax.DefineOption( name: "exclude-events-before", value: ref ExcludeEventsBefore, help: "Exclude data from events before specified time. Time is specified as milliseconds from the start of the trace.", valueConverter: Convert.ToDouble, requireValue: true); syntax.DefineOption( name: "exclude-events-after", value: ref ExcludeEventsAfter, help: "Exclude data from events after specified time. Time is specified as milliseconds from the start of the trace.", valueConverter: Convert.ToDouble, requireValue: true); Verbosity verbosity = default(Verbosity); syntax.DefineOption(name: "v|verbosity", value: ref verbosity, help: "Adjust verbosity level. Supported levels are minimal, normal, detailed, and diagnostic.", valueConverter: VerbosityConverter, requireValue: true); BasicProgressMessages = (int)verbosity >= (int)Verbosity.normal; Warnings = (int)verbosity >= (int)Verbosity.normal; VerboseWarnings = (int)verbosity >= (int)Verbosity.detailed; DisplayProcessedEvents = (int)verbosity >= (int)Verbosity.diagnostic; } void HelpOption() { syntax.DefineOption("h|help", ref Help, "Display this usage message."); } var mibcCommand = syntax.DefineCommand(name: "create-mibc", value: ref command, help: "Transform a trace file into a Mibc profile data file."); if (mibcCommand.IsActive) { activeCommandIsCommandAssociatedWithTraceProcessing = true; HelpArgs = new string[] { "create-mibc", "--help", "--trace", "trace", "--output", "output" }; FileType = PgoFileType.mibc; GenerateCallGraph = true; ProcessJitEvents = true; ProcessR2REvents = true; #if Debug ValidateOutputFile = true; #else ValidateOutputFile = false; #endif CommonOptions(); bool compressed = false; syntax.DefineOption(name: "compressed", value: ref compressed, help: "Generate compressed mibc", requireValue: false); Uncompressed = !compressed; HelpOption(); } JitTraceOptions = jittraceoptions.none; #if DEBUG // Usage of the jittrace format requires using logic embedded in the runtime repository and isn't suitable for general consumer use at this time // Build it in debug and check builds to ensure that it doesn't bitrot, and remains available for use by developers willing to build the repo var jittraceCommand = syntax.DefineCommand(name: "create-jittrace", value: ref command, help: "Transform a trace file into a jittrace runtime file."); if (jittraceCommand.IsActive) { activeCommandIsCommandAssociatedWithTraceProcessing = true; HelpArgs = new string[] { "create-jittrace", "--help", "--trace", "trace", "--output", "output" }; FileType = PgoFileType.jittrace; ProcessJitEvents = true; ProcessR2REvents = false; ValidateOutputFile = false; CommonOptions(); bool sorted = false; syntax.DefineOption(name: "sorted", value: ref sorted, help: "Generate sorted output.", requireValue: false); if (sorted) { JitTraceOptions |= jittraceoptions.sorted; } bool showtimestamp = false; syntax.DefineOption(name: "showtimestamp", value: ref showtimestamp, help: "Show timestamps in output.", requireValue: false); if (showtimestamp) { JitTraceOptions |= jittraceoptions.showtimestamp; } syntax.DefineOption(name: "includeReadyToRun", value: ref ProcessR2REvents, help: "Include ReadyToRun methods in the trace file.", requireValue: false); HelpOption(); } #endif if (syntax.ActiveCommand == null) { // No command specified Help = true; } if (activeCommandIsCommandAssociatedWithTraceProcessing) { HelpText = @$ "{syntax.GetHelpText()} Example tracing commands used to generate the input to this tool: " "dotnet-trace collect -p 73060 --providers Microsoft-Windows-DotNETRuntime:0x1E000080018:4" " - Capture events from process 73060 where we capture both JIT and R2R events using EventPipe tracing " "dotnet-trace collect -p 73060 --providers Microsoft-Windows-DotNETRuntime:0x1C000080018:4" " - Capture events from process 73060 where we capture only JIT events using EventPipe tracing " "perfview collect -LogFile:logOfCollection.txt -DataFile:jittrace.etl -Zip:false -merge:false -providers:Microsoft-Windows-DotNETRuntime:0x1E000080018:4" " - Capture Jit and R2R events via perfview of all processes running using ETW tracing "; } else { HelpText = syntax.GetHelpText(); } }