internal static void WriteTo(Action <string> writeAction) { string version = string.Empty; Assembly assembly = Assembly.GetExecutingAssembly(); VersionWriter.WriteTo(assembly, v => version = v); string message = "GitVersion " + version + @" Use convention to derive a SemVer product version from a GitFlow or GitHub based repository. GitVersion [path] path The directory containing .git. If not defined current directory is used. (Must be first argument) init Configuration utility for gitversion /version Displays the version of GitVersion /diag Runs GitVersion with additional diagnostic information (requires git.exe to be installed) /h or /? Shows Help /targetpath Same as 'path', but not positional /output Determines the output to the console. Can be either 'json' or 'buildserver', will default to 'json'. /showvariable Used in conjuntion with /output json, will output just a particular variable. eg /output json /showvariable SemVer - will output `1.2.3+beta.4` /l Path to logfile. /config Path to config file (defaults to GitVersion.yml) /showconfig Outputs the effective GitVersion config (defaults + custom from GitVersion.yml) in yaml format /overrideconfig Overrides GitVersion config values inline (semicolon-separated key value pairs e.g. /overrideconfig tag-prefix=Foo) Currently supported config overrides: tag-prefix /nocache Bypasses the cache, result will not be written to the cache. # AssemblyInfo updating /updateassemblyinfo Will recursively search for all 'AssemblyInfo.cs' files in the git repo and update them /updateassemblyinfofilename Specify name of AssemblyInfo file. Can also /updateAssemblyInfo GlobalAssemblyInfo.cs as a shorthand /ensureassemblyinfo If the assembly info file specified with /updateassemblyinfo or /updateassemblyinfofilename is not found, it be created with these attributes: AssemblyFileVersion, AssemblyVersion and AssemblyInformationalVersion --- Supports writing version info for: C#, F#, VB # Create or update Wix version file /updatewixversionfile All the GitVersion variables are written to 'GitVersion_WixVersion.wxi'. The variables can then be referenced in other WiX project files for versioning. # Remote repository args /url Url to remote git repository. /b Name of the branch to use on the remote repository, must be used in combination with /url. /u Username in case authentication is required. /p Password in case authentication is required. /c The commit id to check. If not specified, the latest available commit on the specified branch will be used. /dynamicRepoLocation By default dynamic repositories will be cloned to %tmp%. Use this switch to override /nofetch Disables 'git fetch' during version calculation. Might cause GitVersion to not calculate your version as expected. # Execute build args /exec Executes target executable making GitVersion variables available as environmental variables /execargs Arguments for the executable specified by /exec /proj Build a msbuild file, GitVersion variables will be passed as msbuild properties /projargs Additional arguments to pass to msbuild /verbosity Set Verbosity level (debug, info, warn, error, none). Default is info gitversion init Configuration utility for gitversion "; writeAction(message); }
static int VerifyArgumentsAndRun() { Arguments arguments = null; try { var fileSystem = new FileSystem(); var argumentsWithoutExeName = GetArgumentsWithoutExeName(); try { arguments = ArgumentParser.ParseArguments(argumentsWithoutExeName); } catch (Exception exception) { Console.WriteLine("Failed to parse arguments: {0}", string.Join(" ", argumentsWithoutExeName)); if (!string.IsNullOrWhiteSpace(exception.Message)) { Console.WriteLine(); Console.WriteLine(exception.Message); Console.WriteLine(); } HelpWriter.Write(); return(1); } if (arguments.IsVersion) { var assembly = Assembly.GetExecutingAssembly(); VersionWriter.Write(assembly); return(0); } if (arguments.IsHelp) { HelpWriter.Write(); return(0); } if (arguments.Diag) { arguments.NoCache = true; arguments.Output = OutputType.BuildServer; } ConfigureLogging(arguments); if (arguments.Diag) { Logger.WriteInfo("Dumping commit graph: "); LibGitExtensions.DumpGraph(arguments.TargetPath, Logger.WriteInfo, 100); } if (!Directory.Exists(arguments.TargetPath)) { Logger.WriteWarning($"The working directory '{arguments.TargetPath}' does not exist."); } else { Logger.WriteInfo("Working directory: " + arguments.TargetPath); } VerifyConfiguration(arguments, fileSystem); if (arguments.Init) { ConfigurationProvider.Init(arguments.TargetPath, fileSystem, new ConsoleAdapter(), arguments.ConfigFileLocator); return(0); } if (arguments.ShowConfig) { Console.WriteLine(ConfigurationProvider.GetEffectiveConfigAsString(arguments.TargetPath, fileSystem, arguments.ConfigFileLocator)); return(0); } if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec)) { arguments.Output = OutputType.BuildServer; } SpecifiedArgumentRunner.Run(arguments, fileSystem); } catch (WarningException exception) { var error = $"An error occurred:\r\n{exception.Message}"; Logger.WriteWarning(error); return(1); } catch (Exception exception) { var error = $"An unexpected error occurred:\r\n{exception}"; Logger.WriteError(error); if (arguments != null) { Logger.WriteInfo(string.Empty); Logger.WriteInfo("Attempting to show the current git graph (please include in issue): "); Logger.WriteInfo("Showing max of 100 commits"); try { LibGitExtensions.DumpGraph(arguments.TargetPath, Logger.WriteInfo, 100); } catch (Exception dumpGraphException) { Logger.WriteError("Couldn't dump the git graph due to the following error: " + dumpGraphException); } } return(1); } return(0); }