From 7f2aa8a4f1df92a7cd9c585e0dbcc8a3c6ba79eb Mon Sep 17 00:00:00 2001 From: Geert van Horrik Date: Wed, 12 Jul 2023 04:44:52 +0200 Subject: [PATCH] GitHubSync update --- .config/dotnet-tools.json | 2 +- deployment/cake/generic-variables.cake | 11 ++ deployment/cake/lib-msbuild.cake | 145 ++++++++++++---------- deployment/cake/sourcecontrol-github.cake | 2 +- tools/packages.config | 4 - 5 files changed, 95 insertions(+), 69 deletions(-) delete mode 100644 tools/packages.config diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 831d039..8f3a438 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "3.0.0", + "version": "3.1.0", "commands": [ "dotnet-cake" ] diff --git a/deployment/cake/generic-variables.cake b/deployment/cake/generic-variables.cake index cb915fa..167fa65 100644 --- a/deployment/cake/generic-variables.cake +++ b/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) { diff --git a/deployment/cake/lib-msbuild.cake b/deployment/cake/lib-msbuild.cake index 35be5f3..682c488 100644 --- a/deployment/cake/lib-msbuild.cake +++ b/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(); + buildContext.CakeContext.Information(string.Empty); - foreach (var issue in issues) - { - var priority = issue.Priority ?? 0; + var loggedIssues = new HashSet(); - 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) { diff --git a/deployment/cake/sourcecontrol-github.cake b/deployment/cake/sourcecontrol-github.cake index d941c12..648a821 100644 --- a/deployment/cake/sourcecontrol-github.cake +++ b/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" //------------------------------------------------------------- diff --git a/tools/packages.config b/tools/packages.config deleted file mode 100644 index 29e63e0..0000000 --- a/tools/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - -