Skip to content

Commit

Permalink
Merge pull request #613 from WildGums/GitHubSync/20230712-023708
Browse files Browse the repository at this point in the history
GitHubSync update
  • Loading branch information
GeertvanHorrik committed Jul 12, 2023
2 parents 2245ba2 + dc0d02b commit 05562af
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.0.0",
"version": "3.1.0",
"commands": [
"dotnet-cake"
]
Expand Down
11 changes: 11 additions & 0 deletions deployment/cake/generic-variables.cake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class GeneralContext : BuildContextWithItemsBase
: base(parentBuildContext)
{
SkipComponentsThatAreNotDeployable = true;
EnableMsBuildBinaryLog = true;
EnableMsBuildFileLog = true;
EnableMsBuildXmlLog = true;
}

public string Target { get; set; }
Expand All @@ -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; }
Expand Down Expand Up @@ -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)
{
Expand Down
145 changes: 82 additions & 63 deletions deployment/cake/lib-msbuild.cake
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand All @@ -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))
};
}
}

//-------------------------------------------------------------
Expand Down Expand Up @@ -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);
}
}

//-------------------------------------------------------------
Expand All @@ -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;

Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion deployment/cake/sourcecontrol-github.cake
Original file line number Diff line number Diff line change
@@ -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"

//-------------------------------------------------------------

Expand Down
4 changes: 0 additions & 4 deletions tools/packages.config

This file was deleted.

0 comments on commit 05562af

Please sign in to comment.