Exemple #1
0
        private void UpdateVersionWithAppendValue(XContainer nuSpec)
        {
            if (string.IsNullOrWhiteSpace(AppendToVersion))
            {
                return;
            }

            var version = GetVersionElementFromNuSpec(nuSpec);

            version.Value  = $"{PackageVersion ?? version.Value}-{AppendToVersion.Trim()}";
            PackageVersion = version.Value;
        }
        private void UpdateVersionWithAppendValue(XContainer nuSpec)
        {
            if (string.IsNullOrWhiteSpace(AppendToVersion))
            {
                return;
            }

            var package = nuSpec.ElementAnyNamespace("package");

            if (package == null)
            {
                throw new Exception(string.Format("The NuSpec file does not contain a <package> XML element. The NuSpec file appears to be invalid."));
            }

            var metadata = package.ElementAnyNamespace("metadata");

            if (metadata == null)
            {
                throw new Exception(string.Format("The NuSpec file does not contain a <metadata> XML element. The NuSpec file appears to be invalid."));
            }

            var version = metadata.ElementAnyNamespace("version");

            if (version == null)
            {
                throw new Exception(string.Format("The NuSpec file does not contain a <version> XML element. The NuSpec file appears to be invalid."));
            }

            version.Value  = string.Format("{0}-{1}", PackageVersion ?? version.Value, AppendToVersion.Trim());
            PackageVersion = version.Value;
        }