static void Main(string[] args) { if (args.Length != 1) { ShowHelp(); return; } try { var command = args[0]; var versionManager = new DotNetVersionManager(Directory.GetCurrentDirectory()); var response = versionManager.Version(command); if (response.Items.Any()) { Console.WriteLine("Updated the following versions:"); foreach (var item in response.Items) { if (!string.IsNullOrEmpty(item.ErrorMessage)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine($"{item.CsprojFile}: {item.ErrorMessage}"); Console.ResetColor(); } else { Console.WriteLine($"{item.CsprojFile}: {item.OldVersion} -> {item.NewVersion}"); } } } else { Console.WriteLine("No *.csproj files found..."); } } catch (ArgumentException aex) { Console.WriteLine($"Error: {aex.Message}"); return; } }
public void GivenCommand_SetVersion_AndSaveFile(string path, string command, string expVersion, string testFile) { var absPath = Path.Combine(Directory.GetCurrentDirectory(), path); var cpPath = Path.Combine(Directory.GetCurrentDirectory(), $"{testFile}.csproj"); try { File.Copy(absPath, cpPath); var sut = new DotNetVersionManager(cpPath); sut.Version(command); new CsprojFile(cpPath).AssemblyVersion.ShouldBe(expVersion); } finally { if (File.Exists(cpPath)) { File.Delete(cpPath); } } }