Update Universe to use the MSBuild-first KoreBuild

This commit is contained in:
Nate McMaster 2017-02-28 15:00:46 -08:00
parent 1cf3be07d0
commit d60d10e16b
4 changed files with 64 additions and 68 deletions

View File

@ -63,4 +63,4 @@ if (!(Test-Path $buildFolder)) {
} }
} }
&"$buildFile" $args &"$buildFile" @args

6
build/repo.props Normal file
View File

@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<DisableDefaultItems>true</DisableDefaultItems>
<DisableDefaultTargets>true</DisableDefaultTargets>
</PropertyGroup>
</Project>

46
build/repo.targets Normal file
View File

@ -0,0 +1,46 @@
<Project>
<PropertyGroup>
<_SakeTargets Condition="'$(Configuration)' == 'Release'">--config-release</_SakeTargets>
</PropertyGroup>
<!-- workaround. Using Sake as the intermediate means this property doesn't flow into repo builds. -->
<Target Name="SetBuildNumber" Condition="'$(BuildNumber)' != ''">
<SetEnvironmentVariable Variable="BuildNumber" Value="$(BuildNumber)" />
</Target>
<Target Name="CIBuild" DependsOnTargets="SetBuildNumber">
<PropertyGroup>
<_SakeTargets>$(_SakeTargets):ci-build</_SakeTargets>
</PropertyGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="Sake"
Properties="SakeTargets=$(_SakeTargets);RepositoryRoot=$(RepositoryRoot)" />
</Target>
<Target Name="CITest" DependsOnTargets="SetBuildNumber">
<PropertyGroup>
<_SakeTargets>$(_SakeTargets):ci-test</_SakeTargets>
</PropertyGroup>
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="Sake"
Properties="SakeTargets=$(_SakeTargets);RepositoryRoot=$(RepositoryRoot)" />
</Target>
<Target Name="CIPull">
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="Sake"
Properties="SakeTargets=ci-pull;RepositoryRoot=$(RepositoryRoot)" />
</Target>
<Target Name="UpdateRepos">
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="Sake"
Properties="SakeTargets=update;RepositoryRoot=$(RepositoryRoot)" />
</Target>
<Target Name="CleanAll">
<MSBuild Projects="$(MSBuildProjectFullPath)"
Targets="Sake"
Properties="SakeTargets=git-clean;RepositoryRoot=$(RepositoryRoot)" />
</Target>
</Project>

View File

@ -1,7 +1,6 @@
var VERSION='0.2.1' var VERSION='0.2.1'
use-ci-loggers
use-release-management use-release-management
use namespace='System' use namespace='System'
use namespace='System.IO' use namespace='System.IO'
@ -12,7 +11,6 @@ use namespace='System.Linq'
use namespace='System.Text' use namespace='System.Text'
use namespace='System.Text.RegularExpressions' use namespace='System.Text.RegularExpressions'
use namespace='System.Threading.Tasks' use namespace='System.Threading.Tasks'
use import="BuildEnv"
use import="EnvironmentParameters" use import="EnvironmentParameters"
use import="Files" use import="Files"
use import="Json" use import="Json"
@ -32,7 +30,6 @@ functions
static string buildBranch = GetEnvironmentParameter("BUILD_BRANCH") ?? DefaultBuildBranch; static string buildBranch = GetEnvironmentParameter("BUILD_BRANCH") ?? DefaultBuildBranch;
static string coherencePath = GetEnvironmentParameter("COHERENCE_PATH"); static string coherencePath = GetEnvironmentParameter("COHERENCE_PATH");
static string dropsShare = GetEnvironmentParameter("ASPNETCI_DROPS_SHARE", DefaultDropsShare); static string dropsShare = GetEnvironmentParameter("ASPNETCI_DROPS_SHARE", DefaultDropsShare);
static string kBuildVersion = GetEnvironmentParameter("DNX_BUILD_VERSION");
static string ciVolatileShare = GetEnvironmentParameter("CI_VOLATILE_SHARE"); static string ciVolatileShare = GetEnvironmentParameter("CI_VOLATILE_SHARE");
static string koreBuildTargets = GetEnvironmentParameter("KOREBUILD_BUILD_TARGETS"); static string koreBuildTargets = GetEnvironmentParameter("KOREBUILD_BUILD_TARGETS");
static string nugetVersion = GetEnvironmentParameter("NUGET_VERSION"); static string nugetVersion = GetEnvironmentParameter("NUGET_VERSION");
@ -52,18 +49,8 @@ functions
static string gitHubUriPrefix = useHttps ? "https://github.com/aspnet/" : "git@github.com:aspnet/"; static string gitHubUriPrefix = useHttps ? "https://github.com/aspnet/" : "git@github.com:aspnet/";
} }
var buildTarget = "compile" var buildTarget = "/t:Compile"
var buildProperties = "/p:Configuration=Debug"
@{
if (!string.IsNullOrEmpty(kBuildVersion))
{
VERSION += "-" + kBuildVersion;
}
else
{
VERSION += "-" + BuildNumber;
}
}
#default .compile #default .compile
@ -72,6 +59,11 @@ var buildTarget = "compile"
Quiet = true; Quiet = true;
} }
#--config-release
@{
buildProperties = "/p:Configuration=Release";
}
#pull #pull
#compile .pull #compile .pull
#install .pull #install .pull
@ -145,12 +137,6 @@ var buildTarget = "compile"
@{ @{
var threads = int.Parse(Environment.GetEnvironmentVariable("UNIVERSE_THREADS") ?? "4"); var threads = int.Parse(Environment.GetEnvironmentVariable("UNIVERSE_THREADS") ?? "4");
var blockLogger = Log as IBlockLogger;
if (blockLogger != null)
{
blockLogger.StartBlock("Cloning repos");
}
Parallel.ForEach(repositories, new ParallelOptions { MaxDegreeOfParallelism = threads }, repo => Parallel.ForEach(repositories, new ParallelOptions { MaxDegreeOfParallelism = threads }, repo =>
{ {
var useBuildBranch = true; var useBuildBranch = true;
@ -182,11 +168,6 @@ var buildTarget = "compile"
GitCommand("", string.Format("clone --quiet --depth 1 --branch {0} git@github.com:aspnet/{1}.git", buildBranch, repo)); GitCommand("", string.Format("clone --quiet --depth 1 --branch {0} git@github.com:aspnet/{1}.git", buildBranch, repo));
} }
}); });
if (blockLogger != null)
{
blockLogger.EndBlock("Cloning repos");
}
} }
#show-build-graph #show-build-graph
@ -219,10 +200,10 @@ var buildTarget = "compile"
CopyFolder(".build", Path.Combine(universeArtifacts, ".build"), true); CopyFolder(".build", Path.Combine(universeArtifacts, ".build"), true);
} }
var blockLogger = Log as IBlockLogger;
var commits = new ConcurrentDictionary<string, string>(); var commits = new ConcurrentDictionary<string, string>();
var threads = int.Parse(Environment.GetEnvironmentVariable("UNIVERSE_THREADS") ?? "4"); var threads = int.Parse(Environment.GetEnvironmentVariable("UNIVERSE_THREADS") ?? "4");
buildTarget = koreBuildTargets ?? "--quiet compile nuget-verify nuget-install"; buildTarget = koreBuildTargets ?? "/t:Package /t:VerifyPackages /t:NuGetInstall";
buildTarget += " " + buildProperties;
var batchedRepos = GetBuildGraph(); var batchedRepos = GetBuildGraph();
Log.Info("Building repositories in batches: "); Log.Info("Building repositories in batches: ");
@ -260,11 +241,6 @@ var buildTarget = "compile"
{ {
var blockName = string.Format("Building {0}", repo); var blockName = string.Format("Building {0}", repo);
if (blockLogger != null)
{
blockLogger.StartBlock(blockName);
}
if (!IsLinux) if (!IsLinux)
{ {
Exec("cmd", "/C xcopy /S/Q/I/Y .build " + Path.Combine(repo, ".build"), ""); Exec("cmd", "/C xcopy /S/Q/I/Y .build " + Path.Combine(repo, ".build"), "");
@ -309,13 +285,6 @@ var buildTarget = "compile"
Log.Error("Building '" + repo + "' failed: " + ex); Log.Error("Building '" + repo + "' failed: " + ex);
throw; throw;
} }
finally
{
if (blockLogger != null)
{
blockLogger.EndBlock(blockName);
}
}
}); });
} }
@ -370,10 +339,10 @@ var buildTarget = "compile"
} }
#change-default-build-target-to-verify #change-default-build-target-to-verify
- buildTarget = "verify"; - buildTarget = "/t:Verify";
#change-default-build-target-for-coherence-build #change-default-build-target-for-coherence-build
- buildTarget = koreBuildTargets ?? "compile nuget-install"; - buildTarget = koreBuildTargets ?? "/t:Compile /t:NuGetInstall";
#init #init
@{ @{
@ -428,10 +397,6 @@ var buildTarget = "compile"
foreach(var repo in repositories) foreach(var repo in repositories)
{ {
var blockName = string.Format("Building {0}", repo); var blockName = string.Format("Building {0}", repo);
if (IsTeamCity)
{
Log.Info(string.Format("##teamcity[blockOpened name='{0}']", FormatForTeamCity(blockName)));
}
try try
{ {
Log.Info(blockName); Log.Info(blockName);
@ -485,13 +450,6 @@ var buildTarget = "compile"
Log.Warn(string.Format("Build {0} failed: {1}", repo, ex.Message)); Log.Warn(string.Format("Build {0} failed: {1}", repo, ex.Message));
failed[repo] = ex; failed[repo] = ex;
} }
finally
{
if (IsTeamCity)
{
Log.Info(string.Format("##teamcity[blockClosed name='{0}']", FormatForTeamCity(blockName)));
}
}
} }
foreach(var repo in repositories) foreach(var repo in repositories)
@ -500,13 +458,6 @@ var buildTarget = "compile"
if (failed.TryGetValue(repo, out ex)) if (failed.TryGetValue(repo, out ex))
{ {
Log.Warn(string.Format("Build {0} failed: {1}", repo, ex.Message)); Log.Warn(string.Format("Build {0} failed: {1}", repo, ex.Message));
if (IsTeamCity)
{
Log.Warn(string.Format("##teamcity[message text='{0}' errorDetails='{1}' status='ERROR']",
FormatForTeamCity(ex.Message),
FormatForTeamCity(ex.StackTrace)));
}
} }
else if (skipped.Contains(repo)) else if (skipped.Contains(repo))
{ {
@ -549,13 +500,6 @@ var buildTarget = "compile"
#git-clean description='REMOVE ALL CHANGES to the working directory' #git-clean description='REMOVE ALL CHANGES to the working directory'
@{ @{
// Console.WriteLine("This runs `git clean -xfd` in all non-Universe repos.");
// Console.WriteLine("This should REMOVE ALL CHANGES to the working directory.");
// Console.Write("***** Are you sure? ***** (Y or anything else)? ");
// if (Console.ReadLine() != "Y")
// {
// throw new Exception("git-clean cancelled");
// }
foreach(var repo in repositories) foreach(var repo in repositories)
{ {
GitClean(repo); GitClean(repo);