public void Default(string packageVersion) { try { SemanticVersion.Parse(packageVersion); defaultVersion = packageVersion; } catch (ArgumentException) { if (packageVersion.Contains(":")) { throw new ArgumentException("Invalid package version format. Use the package parameter if you need to specify the step name and version."); } throw; } }
public void Add(string stepName, string packageVersion) { string current; if (stepNameToVersion.TryGetValue(stepName, out current)) { var newVersion = SemanticVersion.Parse(packageVersion); var currentVersion = SemanticVersion.Parse(current); if (newVersion < currentVersion) { return; } } stepNameToVersion[stepName] = packageVersion; }
public void Add(string stepName, string packageReferenceName, string packageVersion) { // Double wild card == default value if (stepName == WildCard && packageReferenceName == WildCard) { Default(packageVersion); return; } var key = new PackageKey(stepName, packageReferenceName ?? string.Empty); if (stepNameToVersion.TryGetValue(key, out var current)) { var newVersion = SemanticVersion.Parse(packageVersion); var currentVersion = SemanticVersion.Parse(current); if (newVersion < currentVersion) { return; } } stepNameToVersion[key] = packageVersion; }
public Task Execute(string[] commandLineArguments) { return(Task.Run(() => { optionGroups.Parse(commandLineArguments); if (string.IsNullOrWhiteSpace(id)) { throw new CommandException("An ID is required"); } if (includes.All(string.IsNullOrWhiteSpace)) { includes.Add("**"); } if (string.IsNullOrWhiteSpace(basePath)) { basePath = Path.GetFullPath(Directory.GetCurrentDirectory()); } if (string.IsNullOrWhiteSpace(outFolder)) { outFolder = Path.GetFullPath(Directory.GetCurrentDirectory()); } if (version == null) { var now = DateTime.Now; version = SemanticVersion.Parse($"{now.Year}.{now.Month}.{now.Day}.{now.Hour*10000 + now.Minute*100 + now.Second}"); } if (authors.All(string.IsNullOrWhiteSpace)) { authors.Add(Environment.GetEnvironmentVariable("USERNAME") + "@" + Environment.GetEnvironmentVariable("USERDOMAIN")); } if (string.IsNullOrWhiteSpace(description)) { description = "A deployment package created from files on disk."; } string allReleaseNotes = null; if (!string.IsNullOrWhiteSpace(releaseNotesFile)) { if (!File.Exists(releaseNotesFile)) { log.Warning("The release notes file '{Path:l}' could not be found", releaseNotesFile); } else { allReleaseNotes = fileSystem.ReadFile(releaseNotesFile); } } if (!string.IsNullOrWhiteSpace(releaseNotes)) { if (allReleaseNotes != null) { allReleaseNotes += Environment.NewLine + releaseNotes; } else { allReleaseNotes = releaseNotes; } } if (string.IsNullOrWhiteSpace(version.OriginalString)) { throw new Exception("Somehow we created a SemanticVersion without the OriginalString value being preserved. We want to use the OriginalString so we can preserve the version as intended by the caller."); } var metadata = new ManifestMetadata { Id = id, Authors = authors, Description = description, Version = NuGetVersion.Parse(version.OriginalString) }; if (!string.IsNullOrWhiteSpace(allReleaseNotes)) { metadata.ReleaseNotes = allReleaseNotes; } if (!string.IsNullOrWhiteSpace(title)) { metadata.Title = title; } if (verbose) { log.Information("Verbose logging"); } log.Information("Packing {id:l} version {Version}...", id, version); packageBuilder.BuildPackage(basePath, includes, metadata, outFolder, overwrite, verbose); log.Information("Done."); })); }