public static string GetStringValue(this VersionType enumValue) { switch (enumValue) { case VersionType.Internal: return("internal"); case VersionType.External: return("external"); case VersionType.ExternalGte: return("external_gte"); } throw new ArgumentException($"'{enumValue.ToString()}' is not a valid value for enum 'VersionType'"); }
public void Execute(string rootPath, string msbuildPath, AlgMsBuildSetting algMsBuildSetting, VersionType versionType, Lang lang) { if (!CanExecute(versionType, lang)) { return; } // compile exe var compileArgs = algMsBuildSetting.BaseMsBuildParams + " " + SettingItem.AddMsBuilsParams + " \"" + Path.Combine(rootPath, algMsBuildSetting.SolutionPath) + "\""; var processStartInfo = new ProcessStartInfo(msbuildPath, compileArgs) { UseShellExecute = false, RedirectStandardOutput = true, StandardOutputEncoding = System.Text.Encoding.GetEncoding(866), RedirectStandardError = true, StandardErrorEncoding = System.Text.Encoding.GetEncoding(866), }; var process = Process.Start(processStartInfo); var outputs = process.StandardOutput.ReadToEnd(); var errors = process.StandardError.ReadToEnd(); process.WaitForExit(); if (process.ExitCode > 0) { throw new Exception("process compil failed\n\n" + outputs + "\n\n" + errors); } // copy exe to output folder var destinationFileName = string.Format(Constants.ExesNamePattern, versionType.ToString(), lang.ToString()); File.Copy(Path.Combine(rootPath, algMsBuildSetting.FinalExePath), Path.Combine(rootPath, Constants.ExesFolderName, destinationFileName), true); }
public override string ToString() { return(string.Format("{0}.{1}.{2}{3}{4}", major, minor, patch, type.ToString().ToLower()[0], build)); }
static void Main(string[] args) { var assApp = typeof(AssemblyInfoUpdater).Assembly; var assAppName = assApp.GetName(); var verApp = assAppName.Version; var caption = @" Increase version ( "; caption += verApp + " )"; var captionLine = @" -="; for (var i = 0; i <= caption.Length - 5; i++) { captionLine += "="; } captionLine += "=-"; Console.WriteLine(""); Console.WriteLine(caption); Console.WriteLine(captionLine); Console.WriteLine(""); foreach (var argument in args) { if (argument.StartsWith(_major)) { _versionType = VersionType.Major; } if (argument.StartsWith(_minor)) { _versionType = VersionType.Minor; } if (argument.StartsWith(_build)) { _versionType = VersionType.Build; } if (argument.StartsWith(_revision)) { _versionType = VersionType.Revision; } else { _fileName = argument; } } if (_fileName == "" || _versionType == VersionType.Invalid) { Console.WriteLine("Usage: AssemblyInfoUpdater < path to AssemblyInfo.cs > [options]"); Console.WriteLine("Options: "); Console.WriteLine(" {0} - increases the major index and resets the other", _major); Console.WriteLine(" {0} - increases the minor index and resets the build and revision", _minor); Console.WriteLine(" {0} - increases the build index and resets the revision", _build); Console.WriteLine(" {0} - increases the revision index", _revision); Console.WriteLine(""); return; } if (!File.Exists(_fileName)) { Console.WriteLine("Error: Can not find file \"" + _fileName + "\""); Console.WriteLine(""); return; } Console.WriteLine(" Processing \"" + _fileName + "\"..."); Console.WriteLine(""); var reader = new StreamReader(_fileName); var writer = new StreamWriter(_fileName + ".out"); string line; while ((line = reader.ReadLine()) != null) { line = ProcessLine(line); writer.WriteLine(line); } reader.Close(); writer.Close(); File.Delete(_fileName); File.Move(_fileName + ".out", _fileName); Console.WriteLine(@" Version part: {0}", _versionType.ToString()); Console.WriteLine(@" Old version: {0}", _oldVersion); Console.WriteLine(@" New version: {0}", _newVersion); Console.WriteLine(""); Console.WriteLine(" Done!"); Console.WriteLine(""); }
private static string GetVersionVariableName(VersionType versionType, string productName, string dockerfileVersion) => $"{productName}|{dockerfileVersion}|{versionType.ToString().ToLowerInvariant()}-version";