Skip to content

Commit

Permalink
Replace unused -verbose with -verbosity in ./build
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed Jan 21, 2020
1 parent 183f552 commit b5f93be
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 23 deletions.
17 changes: 15 additions & 2 deletions tools/builder/models/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,21 @@ public class BuildContext
[Argument(0, "targets", Description = "The target(s) to run (default: 'PR'; values: 'Build', 'CI', 'Packages', 'PR', 'Restore', 'Test', 'TestCore', 'TestFx')")]
public BuildTarget[] Targets { get; } = new[] { BuildTarget.PR };

[Option("-v|--verbose", Description = "Enable verbose output")]
public bool Verbose { get; }
[Option("-v|--verbosity", Description = "Set verbosity level (default: 'minimal'; values: 'q[uiet]', 'm[inimal]', 'n[ormal]', 'd[etailed]', and 'diag[nostic]'")]
public BuildVerbosity Verbosity { get; } = BuildVerbosity.minimal;

internal BuildVerbosity VerbosityNuGet
{
get
{
switch (Verbosity)
{
case BuildVerbosity.diagnostic: return BuildVerbosity.detailed;
case BuildVerbosity.minimal: return BuildVerbosity.normal;
default: return Verbosity;
}
}
}

// Helper methods for build target consumption

Expand Down
15 changes: 15 additions & 0 deletions tools/builder/models/BuildVerbosity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public enum BuildVerbosity
{
quiet,
minimal,
normal,
detailed,
diagnostic,

// Shortcut names to match with msbuild/dotnet build
q = quiet,
m = minimal,
n = normal,
d = detailed,
diag = diagnostic
}
2 changes: 1 addition & 1 deletion tools/builder/targets/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public static async Task OnExecute(BuildContext context)
{
context.BuildStep("Compiling binaries");

await context.Exec("dotnet", $"build --no-restore --configuration {context.ConfigurationText}");
await context.Exec("dotnet", $"build --no-restore --configuration {context.ConfigurationText} --verbosity {context.Verbosity}");
}
}
18 changes: 10 additions & 8 deletions tools/builder/targets/Packages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,19 @@ public static async Task OnExecute(BuildContext context)
{
context.BuildStep("Creating NuGet packages");

var versionOverride = string.Format("{0}.{1}+{2}",
Environment.GetEnvironmentVariable("NBGV_CloudBuildNumber"),
Environment.GetEnvironmentVariable("NBGV_VersionHeight"),
Environment.GetEnvironmentVariable("NBGV_GitCommitIdShort"));
var versionOverride = string.Format(
"{0}.{1}+{2}",
Environment.GetEnvironmentVariable("NBGV_CloudBuildNumber"),
Environment.GetEnvironmentVariable("NBGV_VersionHeight"),
Environment.GetEnvironmentVariable("NBGV_GitCommitIdShort"));
var versionOption = versionOverride == ".+" ? string.Empty : $"-Version \"{versionOverride}\"";

var nuspecFiles = Directory.GetFiles(context.BaseFolder, "*.nuspec", SearchOption.AllDirectories)
.OrderBy(x => x)
.Select(x => x.Substring(context.BaseFolder.Length + 1));
var nuspecFiles =
Directory.GetFiles(context.BaseFolder, "*.nuspec", SearchOption.AllDirectories)
.OrderBy(x => x)
.Select(x => x.Substring(context.BaseFolder.Length + 1));

foreach (var nuspecFile in nuspecFiles)
await context.Exec(context.NuGetExe, $"pack {nuspecFile} -NonInteractive -NoPackageAnalysis -OutputDirectory {context.PackageOutputFolder} -Properties Configuration={context.ConfigurationText} {versionOption}");
await context.Exec(context.NuGetExe, $"pack {nuspecFile} -NonInteractive -NoPackageAnalysis -OutputDirectory {context.PackageOutputFolder} -Properties Configuration={context.ConfigurationText} -Verbosity {context.VerbosityNuGet} {versionOption}");
}
}
7 changes: 4 additions & 3 deletions tools/builder/targets/PublishPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public static async Task OnExecute(BuildContext context)
return;
}

var packageFiles = Directory.GetFiles(context.PackageOutputFolder, "*.nupkg", SearchOption.AllDirectories)
.OrderBy(x => x)
.Select(x => x.Substring(context.BaseFolder.Length + 1));
var packageFiles =
Directory.GetFiles(context.PackageOutputFolder, "*.nupkg", SearchOption.AllDirectories)
.OrderBy(x => x)
.Select(x => x.Substring(context.BaseFolder.Length + 1));

foreach (var packageFile in packageFiles)
{
Expand Down
4 changes: 2 additions & 2 deletions tools/builder/targets/Restore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ public static async Task OnExecute(BuildContext context)
{
context.BuildStep("Restoring NuGet packages");

await context.Exec("dotnet", "restore");
await context.Exec("dotnet", $"restore --verbosity {context.Verbosity}");

context.BuildStep("Restoring .NET Core command-line tools");

await context.Exec("dotnet", "tool restore");
await context.Exec("dotnet", $"tool restore --verbosity {context.Verbosity}");
}
}
12 changes: 7 additions & 5 deletions tools/builder/targets/SignPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ public static async Task OnExecute(BuildContext context)
return;
}

var packageFiles = Directory.GetFiles(context.PackageOutputFolder, "*.nupkg", SearchOption.AllDirectories)
.OrderBy(x => x)
.Select(x => x.Substring(context.BaseFolder.Length + 1));
var packageFiles =
Directory.GetFiles(context.PackageOutputFolder, "*.nupkg", SearchOption.AllDirectories)
.OrderBy(x => x)
.Select(x => x.Substring(context.BaseFolder.Length + 1));

var signClientAppSettings = Path.Combine(context.BaseFolder, "tools", "SignClient", "appsettings.json");
foreach (var packageFile in packageFiles)
{
var args = $"SignClient sign -c \"{signClientAppSettings}\" -r \"{signClientUser}\" -s \"{signClientSecret}\" -n \"xUnit.net\" -d \"xUnit.net\" -u \"https://github.com/xunit/xunit\" -i \"{packageFile}\"";
var redactedArgs = args.Replace(signClientUser, "[redacted]")
.Replace(signClientSecret, "[redacted]");
var redactedArgs =
args.Replace(signClientUser, "[redacted]")
.Replace(signClientSecret, "[redacted]");

await context.Exec("dotnet", args, redactedArgs);
}
Expand Down
2 changes: 1 addition & 1 deletion tools/builder/targets/TestCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public static Task OnExecute(BuildContext context)
var resultPath = Path.Combine(context.BaseFolder, "artifacts", "test");
File.Delete(Path.Combine(resultPath, "netcore.trx"));

return context.Exec("dotnet", $"test test/xunit.analyzers.tests --framework netcoreapp2.1 --configuration {context.ConfigurationText} --no-build --logger trx;LogFileName=netcore.trx --results-directory \"{resultPath}\"");
return context.Exec("dotnet", $"test test/xunit.analyzers.tests --framework netcoreapp2.1 --configuration {context.ConfigurationText} --no-build --logger trx;LogFileName=netcore.trx --results-directory \"{resultPath}\" --verbosity {context.Verbosity}");
}
}
2 changes: 1 addition & 1 deletion tools/builder/targets/TestFx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public static Task OnExecute(BuildContext context)
var resultPath = Path.Combine(context.BaseFolder, "artifacts", "test");
File.Delete(Path.Combine(resultPath, "netfx.trx"));

return context.Exec("dotnet", $"test test/xunit.analyzers.tests --framework net472 --configuration {context.ConfigurationText} --no-build --logger trx;LogFileName=netfx.trx --results-directory \"{resultPath}\"");
return context.Exec("dotnet", $"test test/xunit.analyzers.tests --framework net472 --configuration {context.ConfigurationText} --no-build --logger trx;LogFileName=netfx.trx --results-directory \"{resultPath}\" --verbosity {context.Verbosity}");
}
}

0 comments on commit b5f93be

Please sign in to comment.