Browse Source

GitHubSync update

pull/897/head
Geert van Horrik 2 years ago
parent
commit
8701335a27
  1. 2
      .config/dotnet-tools.json
  2. 11
      deployment/cake/generic-variables.cake
  3. 145
      deployment/cake/lib-msbuild.cake
  4. 2
      deployment/cake/sourcecontrol-github.cake
  5. 4
      tools/packages.config

2
.config/dotnet-tools.json

@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.0.0",
"version": "3.1.0",
"commands": [
"dotnet-cake"
]

11
deployment/cake/generic-variables.cake

@ -10,6 +10,9 @@ public class GeneralContext : BuildContextWithItemsBase
: base(parentBuildContext)
{
SkipComponentsThatAreNotDeployable = true;
EnableMsBuildBinaryLog = true;
EnableMsBuildFileLog = true;
EnableMsBuildXmlLog = true;
}
public string Target { get; set; }
@ -26,6 +29,10 @@ public class GeneralContext : BuildContextWithItemsBase
public bool VerifyDependencies { get; set; }
public bool SkipComponentsThatAreNotDeployable { get; set; }
public bool EnableMsBuildBinaryLog { get; set; }
public bool EnableMsBuildFileLog { get; set; }
public bool EnableMsBuildXmlLog { get; set; }
public VersionContext Version { get; set; }
public CopyrightContext Copyright { get; set; }
public NuGetContext NuGet { get; set; }
@ -463,6 +470,10 @@ private GeneralContext InitializeGeneralContext(BuildContext buildContext, IBuil
data.VerifyDependencies = !buildContext.BuildServer.GetVariableAsBool("DependencyCheckDisabled", false, showValue: true);
data.SkipComponentsThatAreNotDeployable = buildContext.BuildServer.GetVariableAsBool("SkipComponentsThatAreNotDeployable", true, showValue: true);
data.EnableMsBuildBinaryLog = buildContext.BuildServer.GetVariableAsBool("EnableMsBuildBinaryLog", true, showValue: true);
data.EnableMsBuildFileLog = buildContext.BuildServer.GetVariableAsBool("EnableMsBuildFileLog", true, showValue: true);
data.EnableMsBuildXmlLog = buildContext.BuildServer.GetVariableAsBool("EnableMsBuildXmlLog", true, showValue: true);
// If local, we want full pdb, so do a debug instead
if (data.IsLocalBuild)
{

145
deployment/cake/lib-msbuild.cake

@ -58,7 +58,7 @@ private static void ConfigureMsBuild(BuildContext buildContext, MSBuildSettings
// Only optimize in release mode
if (!buildContext.General.IsLocalBuild)
{
buildContext.CakeContext.Information($"This is NOT a local build, disabling building of project references");
buildContext.CakeContext.Information("This is NOT a local build, disabling building of project references");
// Don't build project references (should already be built)
msBuildSettings.WithProperty("BuildProjectReferences", "false");
@ -67,7 +67,7 @@ private static void ConfigureMsBuild(BuildContext buildContext, MSBuildSettings
}
else
{
buildContext.CakeContext.Information($"This is a local build, disabling building of project references");
buildContext.CakeContext.Information("This is a local build, disabling building of project references");
}
// Continuous integration build
@ -93,20 +93,26 @@ private static void ConfigureMsBuild(BuildContext buildContext, MSBuildSettings
msBuildSettings.MaxCpuCount = 0;
// Enable for file logging
msBuildSettings.AddFileLogger(new MSBuildFileLogger
if (buildContext.General.EnableMsBuildFileLog)
{
Verbosity = msBuildSettings.Verbosity,
//Verbosity = Verbosity.Diagnostic,
LogFile = System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}_log.log", projectName, action))
});
msBuildSettings.AddFileLogger(new MSBuildFileLogger
{
Verbosity = msBuildSettings.Verbosity,
//Verbosity = Verbosity.Diagnostic,
LogFile = System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}_log.log", projectName, action))
});
}
// Enable for bin logging
msBuildSettings.BinaryLogger = new MSBuildBinaryLogSettings
if (buildContext.General.EnableMsBuildBinaryLog)
{
Enabled = true,
Imports = MSBuildBinaryLogImports.Embed,
FileName = System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}_log.binlog", projectName, action))
};
msBuildSettings.BinaryLogger = new MSBuildBinaryLogSettings
{
Enabled = true,
Imports = MSBuildBinaryLogImports.Embed,
FileName = System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}_log.binlog", projectName, action))
};
}
}
//-------------------------------------------------------------
@ -174,27 +180,33 @@ private static void ConfigureMsBuildForDotNet(BuildContext buildContext, DotNetM
msBuildSettings.MaxCpuCount = 0;
// Enable for file logging
msBuildSettings.AddFileLogger(new MSBuildFileLoggerSettings
if (buildContext.General.EnableMsBuildFileLog)
{
Verbosity = msBuildSettings.Verbosity,
//Verbosity = Verbosity.Diagnostic,
LogFile = System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}_log.log", projectName, action))
});
msBuildSettings.AddFileLogger(new MSBuildFileLoggerSettings
{
Verbosity = msBuildSettings.Verbosity,
//Verbosity = Verbosity.Diagnostic,
LogFile = System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}_log.log", projectName, action))
});
}
// Enable for bin logging
msBuildSettings.BinaryLogger = new MSBuildBinaryLoggerSettings
if (buildContext.General.EnableMsBuildBinaryLog)
{
Enabled = true,
Imports = MSBuildBinaryLoggerImports.Embed,
FileName = System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}.binlog", projectName, action))
};
// Note: this only works for direct .net core msbuild usage, not when this is
// being wrapped in a tool (such as 'dotnet pack')
var binLogArgs = string.Format("-bl:\"{0}\";ProjectImports=Embed",
System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}_log.binlog", projectName, action)));
msBuildSettings.ArgumentCustomization = args => args.Append(binLogArgs);
msBuildSettings.BinaryLogger = new MSBuildBinaryLoggerSettings
{
Enabled = true,
Imports = MSBuildBinaryLoggerImports.Embed,
FileName = System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}.binlog", projectName, action))
};
// Note: this only works for direct .net core msbuild usage, not when this is
// being wrapped in a tool (such as 'dotnet pack')
var binLogArgs = string.Format("-bl:\"{0}\";ProjectImports=Embed",
System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}_log.binlog", projectName, action)));
msBuildSettings.ArgumentCustomization = args => args.Append(binLogArgs);
}
}
//-------------------------------------------------------------
@ -218,8 +230,12 @@ private static void RunMsBuild(BuildContext buildContext, string projectName, st
buildContext.CakeContext.CreateDirectory(buildContext.General.OutputRootDirectory);
var logPath = System.IO.Path.Combine(buildContext.General.OutputRootDirectory, string.Format(@"MsBuild_{0}_{1}_log.xml", projectName, action));
msBuildSettings.WithLogger(buildContext.CakeContext.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath,
"XmlFileLogger", $"logfile=\"{logPath}\";verbosity=Detailed;encoding=UTF-8");
if (buildContext.General.EnableMsBuildXmlLog)
{
msBuildSettings.WithLogger(buildContext.CakeContext.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath,
"XmlFileLogger", $"logfile=\"{logPath}\";verbosity=Detailed;encoding=UTF-8");
}
var failBuild = false;
@ -242,53 +258,56 @@ private static void RunMsBuild(BuildContext buildContext, string projectName, st
buildContext.CakeContext.Information($"Investigating potential issues using '{logPath}'");
buildContext.CakeContext.Information(string.Empty);
var investigationStopwatch = Stopwatch.StartNew();
var issuesContext = buildContext.CakeContext.MsBuildIssuesFromFilePath(logPath, buildContext.CakeContext.MsBuildXmlFileLoggerFormat());
//var issuesContext = buildContext.CakeContext.MsBuildIssuesFromFilePath(logPath, buildContext.CakeContext.MsBuildBinaryLogFileFormat());
if (System.IO.File.Exists(logPath))
{
var investigationStopwatch = Stopwatch.StartNew();
buildContext.CakeContext.Debug("Created issue context");
var issuesContext = buildContext.CakeContext.MsBuildIssuesFromFilePath(logPath, buildContext.CakeContext.MsBuildXmlFileLoggerFormat());
//var issuesContext = buildContext.CakeContext.MsBuildIssuesFromFilePath(logPath, buildContext.CakeContext.MsBuildBinaryLogFileFormat());
var issues = buildContext.CakeContext.ReadIssues(issuesContext, buildContext.General.RootDirectory);
buildContext.CakeContext.Debug("Created issue context");
buildContext.CakeContext.Debug($"Found '{issues.Count()}' potential issues");
var issues = buildContext.CakeContext.ReadIssues(issuesContext, buildContext.General.RootDirectory);
buildContext.CakeContext.Information(string.Empty);
buildContext.CakeContext.Debug($"Found '{issues.Count()}' potential issues");
var loggedIssues = new HashSet<string>();
buildContext.CakeContext.Information(string.Empty);
foreach (var issue in issues)
{
var priority = issue.Priority ?? 0;
var loggedIssues = new HashSet<string>();
var message = $"{issue.AffectedFileRelativePath}({issue.Line},{issue.Column}): {issue.Rule}: {issue.MessageText}";
if (loggedIssues.Contains(message))
foreach (var issue in issues)
{
continue;
}
var priority = issue.Priority ?? 0;
//buildContext.CakeContext.Information($"[{issue.Priority}] {message}");
var message = $"{issue.AffectedFileRelativePath}({issue.Line},{issue.Column}): {issue.Rule}: {issue.MessageText}";
if (loggedIssues.Contains(message))
{
continue;
}
if (priority == (int)IssuePriority.Warning)
{
buildContext.CakeContext.Warning($"WARNING: {message}");
//buildContext.CakeContext.Information($"[{issue.Priority}] {message}");
loggedIssues.Add(message);
}
else if (priority == (int)IssuePriority.Error)
{
buildContext.CakeContext.Error($"ERROR: {message}");
if (priority == (int)IssuePriority.Warning)
{
buildContext.CakeContext.Warning($"WARNING: {message}");
loggedIssues.Add(message);
loggedIssues.Add(message);
}
else if (priority == (int)IssuePriority.Error)
{
buildContext.CakeContext.Error($"ERROR: {message}");
loggedIssues.Add(message);
failBuild = true;
failBuild = true;
}
}
}
buildContext.CakeContext.Information(string.Empty);
buildContext.CakeContext.Information($"Done investigating project, took '{investigationStopwatch.Elapsed}'");
buildContext.CakeContext.Information($"Total msbuild ({action} + investigation) took '{totalStopwatch.Elapsed}'");
buildContext.CakeContext.Information(string.Empty);
buildContext.CakeContext.Information(string.Empty);
buildContext.CakeContext.Information($"Done investigating project, took '{investigationStopwatch.Elapsed}'");
buildContext.CakeContext.Information($"Total msbuild ({action} + investigation) took '{totalStopwatch.Elapsed}'");
buildContext.CakeContext.Information(string.Empty);
}
if (failBuild)
{

2
deployment/cake/sourcecontrol-github.cake

@ -1,5 +1,5 @@
#addin "nuget:?package=Cake.GitHub&version=0.1.0"
#addin "nuget:?package=Octokit&version=6.2.1"
#addin "nuget:?package=Octokit&version=7.0.1"
//-------------------------------------------------------------

4
tools/packages.config

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake.CoreCLR" version="2.3.0" />
</packages>
Loading…
Cancel
Save