public static void SetVersion(string file, Semver version) { if (!File.Exists(file)) { return; } Program.VerboseOut(Verbose.Version, "Setting nuspec version {0} of {1}", version.ToString("P"), file); var lines = File.ReadAllLines(file); var newLines = new List <string>(); foreach (var line in lines) { if (VersionMatcher.IsMatch(line)) { newLines.Add(VersionMatcher.Replace(line, "${1}" + version.ToString("P") + "$2")); } else { newLines.Add(line); } } FileUtil.AssertWritable(file); File.WriteAllLines(file, newLines, Encoding.UTF8); }
public void should_display_normal_version_when_called_with_P_argument_and_version_is_not_prerelease() { var semver = new Semver(1, 2, 3, "", "build"); Assert.Equal("1.2.3", semver.ToString("P")); }
public void should_throw_format_exception_when_format_is_not_a_valid_value() { var semver = new Semver(1, 2, 3, "pre", "build"); Assert.Throws <FormatException>(() => semver.ToString("X")); }
public void should_display_normal_version_when_called_with_V_argument() { var semver = new Semver(1, 2, 3, "pre", "build"); Assert.Equal("1.2.3", semver.ToString("V")); }
public void should_display_full_version_when_called_with_F_argument() { var semver = new Semver(1, 2, 3, "pre", "build"); Assert.Equal("1.2.3-pre+build", semver.ToString("F")); }