Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
            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"));
            }
Exemplo n.º 3
0
            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"));
            }
Exemplo n.º 4
0
            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"));
            }
Exemplo n.º 5
0
            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"));
            }