public void PackNuGetPackages(ILogger log, NuGetPackTaskOptions options, CommandHelper cmd, FileSystemHelper fs) { foreach (var project in fs.Files(options.ProjectGlobs)) { log.LogTrace("Packing {0}", project.FullName); var args = new List <string>(); args.Add(project.FullName); args.Add("--output"); args.Add(options.OutputRoot); args.Add("--no-build"); if (!string.IsNullOrEmpty(options.VersionSuffix)) { args.Add("--version-suffix"); args.Add(options.VersionSuffix); } cmd.Exec(DotNetCli.Default.Pack(args)); } }
public void SetVersionSuffix(ILogger log, DotNetBuildTaskOptions buildOptions, NuGetPackTaskOptions packOptions) { if (string.IsNullOrEmpty(buildOptions.VersionSuffix)) { var versionSuffix = Environment.GetEnvironmentVariable("DOTNET_BUILD_VERSION"); if (!string.IsNullOrEmpty(versionSuffix)) { buildOptions.VersionSuffix = versionSuffix; } } if (string.IsNullOrEmpty(buildOptions.VersionSuffix)) { // Generate a timestamp based version var timestamp = DateTime.UtcNow.ToString("yyyyMMddHHmmss"); buildOptions.VersionSuffix = $"t-{timestamp}"; } packOptions.VersionSuffix = buildOptions.VersionSuffix; log.LogInformation($"Version Suffix: {buildOptions.VersionSuffix}"); }