Add KoreBuild properties section

This commit is contained in:
Ryan Brandenburg 2017-12-28 11:53:46 -08:00
Родитель 9b0fac6180
Коммит 314c98e453
5 изменённых файлов: 80 добавлений и 8 удалений

Просмотреть файл

@ -10,14 +10,24 @@ KoreBuild is a set of MSBuild targets, tasks, and console commands used to defin
KoreBuild commands allow you to take wider and more granular actions.
Previously repositories were runable in only one way, by doing `.\build.cmd`. But now, you can run multiple options.
Command | Purpose | Example
-------------|------------------------------------------------------------------|----------
install-tools| Installs dotnet, CLI and Shared runtimes. | .\run.ps1 install-tools
docker-build | Runs the build inside docker. | .\run.ps1 docker-build {jessie\|winservercore} /t:SomeTarget /p:Parameters
default-build| Runs install-tools followed by msbuild (like build.cmd used to). | .\run.ps1 default-build /t:SomeTarget /p:Parameters
msbuild | Runs the build normally. | .\run.ps1 msbuild /t:SomeTarget /p:Parameters
upgrade deps | Upgrade the dependencies.props of this project. | .\run.ps1 upgrade deps
generate deps| Generate a dependencies.props for this project. | .\run.ps1 generate deps
Command | Purpose | Example
----------------------|------------------------------------------------------------------|----------
install-tools | Installs dotnet, CLI and Shared runtimes. | .\run.ps1 install-tools
docker-build | Runs the build inside docker. | .\run.ps1 docker-build {jessie\|winservercore} /t:SomeTarget /p:Parameters
default-build | Runs install-tools followed by msbuild (like build.cmd used to). | .\run.ps1 default-build /t:SomeTarget /p:Parameters
msbuild | Runs the build normally. | .\run.ps1 msbuild /t:SomeTarget /p:Parameters
upgrade deps | Upgrade the dependencies.props of this project. | .\run.ps1 upgrade deps
generate deps | Generate a dependencies.props for this project. | .\run.ps1 generate deps
generate api-baseline | Re-generate baselines for all projects. | .\run.ps1 generate api-baseline
### KoreBuild properties
Below is a list of some of the properties that KoreBuild recognizes which you might find useful.
Property | Purpose
------------------|--------
GenerateBaselines | Toggles the (re-)generation of baselines for all projects.
VSTestBlame | Turns on the '--blame' option of vstest, useful for diagnosing test host failures.
### KoreBuild config

Просмотреть файл

@ -13,6 +13,8 @@ param(
$ErrorActionPreference = 'Stop'
& git clean .\artifacts -xdf
if (!$NoBuild) {
& .\build.ps1 '-p:SkipTests=true'
}

Просмотреть файл

@ -0,0 +1,50 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.CommandLineUtils;
namespace KoreBuild.Console.Commands
{
internal class ApiBaselinesGenerateCommand : SubCommandBase
{
public ApiBaselinesGenerateCommand(CommandContext context) : base(context)
{
}
public override void Configure(CommandLineApplication application)
{
application.Description = "Generates baselines for all projects in this repo.";
base.Configure(application);
}
protected override int Execute()
{
var args = new List<string>
{
"msbuild",
"/nologo",
"/m",
$"/p:KoreBuildVersion={this.Context.KoreBuildVersion}",
$"/p:RepositoryRoot=\"{this.Context.RepoPath}/\"",
"\"/p:GenerateBaselines=true\"",
"\"/p:SkipTests=true\"",
"/clp:Summary",
Path.Combine(Context.KoreBuildDir, "KoreBuild.proj")
};
if (Reporter.IsVerbose)
{
args.Add("\"/v:n\"");
}
else
{
args.Add("\"/v:m\"");
}
return RunDotnet(args, Context.RepoPath);
}
}
}

Просмотреть файл

@ -55,6 +55,8 @@ namespace KoreBuild.Console.Commands
public string ToolsSource => _toolsSourceOption.HasValue() ? _toolsSourceOption.Value() : _defaultToolsSource;
public string SDKVersion => GetDotnetSDKVersion();
public string KoreBuildVersion => GetKoreBuildVersion();
public IReporter Reporter => new ConsoleReporter(PhysicalConsole.Singleton, _verbose != null, false);
private string GetDotnetSDKVersion()
@ -98,6 +100,12 @@ namespace KoreBuild.Console.Commands
return result;
}
private string GetKoreBuildVersion()
{
var dir = new DirectoryInfo(FindKoreBuildDirectory());
return dir.Parent.Name;
}
private string FindKoreBuildDirectory()
{
if (_korebuildOverrideOpt.HasValue())

Просмотреть файл

@ -35,7 +35,9 @@ namespace KoreBuild.Console.Commands
application.Command("generate", c =>
{
c.HelpOption("-h|--help");
c.Command("deps", new DependenciesGenerateCommand(context).Configure, throwOnUnexpectedArg: false);
c.Command("api-baselines", new ApiBaselinesGenerateCommand(context).Configure, throwOnUnexpectedArg: false);
c.OnExecute(() =>
{