diff --git a/docs/docs/documentation/issue-providers/msbuild/examples.md b/docs/docs/documentation/issue-providers/msbuild/examples.md index d93b7184e..a8ce629bd 100644 --- a/docs/docs/documentation/issue-providers/msbuild/examples.md +++ b/docs/docs/documentation/issue-providers/msbuild/examples.md @@ -13,15 +13,6 @@ To read issues from MsBuild log files you need to import the core addin and the #addin nuget:?package=Cake.Issues.MsBuild&version={{ cake_issues_version }} ``` -In this example the log file is written by the `XmlFileLogger` class from [MSBuild Extension Pack]. -In order to use the above logger, the following line will download and install the tool from NuGet.org: - -```csharp -#tool "nuget:?package=MSBuild.Extension.Pack" // (1)! -``` - ---8<-- "snippets/pinning.md" - We need some global variables: ```csharp @@ -29,27 +20,32 @@ var logPath = @"c:\build\msbuild.log"; var repoRootPath = @"c:\repo"; ``` -The following task will build the solution and write a log file: +The following task will build the solution and write a binary log file: ```csharp Task("Build-Solution").Does(() => { - // Build solution. - var settings = - new MSBuildSettings() - .WithLogger( - Context.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath, - "XmlFileLogger", - $"logfile=\"{logPath}\";verbosity=Detailed;encoding=UTF-8" - ); - - MSBuild(repoRootPath.CombineWithFilePath("MySolution.sln"), settings); + var msBuildSettings = + new MSBuildSettings().WithLogger( + "BinaryLogger," + Context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll"), + "", + logPath) + DotNetBuild( + repoRootPath.CombineWithFilePath("MySolution.sln"), + new DotNetBuildSettings{MSBuildSettings = msBuildSettings}); }); ``` +!!! Tip + When using `MSBuildSettings.BinaryLogger` property to write a binary log, the version of the binary log format written + depends on the version of the .NET SDK. + + To avoid the risk of breaking builds when the .NET SDK is updated and introduces a new binary log format, which is not supported + in the used version of Cake.Issues.MsBuild, the binary logger instance shipped as part of Cake.Issues.MsBuild is + used in the above example. + Finally you can define a task where you call the core addin with the desired issue provider. -The following example reads issues reported as MsBuild warnings by the `XmlFileLogger` -class from [MSBuild Extension Pack]: +The following example reads warnings and errors reported as MsBuild in a binary log: ```csharp Task("Read-Issues") @@ -61,11 +57,9 @@ Task("Read-Issues") ReadIssues( MsBuildIssuesFromFilePath( logPath, - MsBuildXmlFileLoggerFormat), + MsBuildBinaryLogFileFormat), repoRootFolder); Information("{0} issues are found.", issues.Count()); }); ``` - -[MSBuild Extension Pack]: https://github.com/mikefourie-zz/MSBuildExtensionPack diff --git a/docs/docs/documentation/pull-request-systems/azure-devops/examples/azure-pipelines.md b/docs/docs/documentation/pull-request-systems/azure-devops/examples/azure-pipelines.md index c8c2bbf20..6de2a0f69 100644 --- a/docs/docs/documentation/pull-request-systems/azure-devops/examples/azure-pipelines.md +++ b/docs/docs/documentation/pull-request-systems/azure-devops/examples/azure-pipelines.md @@ -19,10 +19,19 @@ in this example for JetBrains InspectCode: --8<-- "snippets/pinning.md" -In the following task we'll first determine if the build is running on Azure DevOps and for a pull request, -then read the remote repository URL and pull request id from environment variables set by the Azure Pipelines build -and finally call the [AzureDevOpsPullRequests](https://cakebuild.net/api/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases/){target="_blank"} -alias using the OAuth token provided by the Azure Pipeline build. +The following task will call the [AzureDevOpsPullRequests](https://cakebuild.net/api/Cake.Issues.PullRequests.AzureDevOps/AzureDevOpsPullRequestSystemAliases/){target="_blank"} +alias to connect to the pull request using the environment variables provided by Azure Pipelines. + +```csharp +Task("ReportIssuesToPullRequest").Does(() => +{ + ReportIssuesToPullRequest( + InspectCodeIssuesFromFilePath( + @"C:\build\inspectcode.log"), + AzureDevOpsPullRequests(), + repoRootFolder); +}); +``` !!! info Please note that you'll need to setup your Azure Pipelines build to @@ -31,47 +40,4 @@ alias using the OAuth token provided by the Azure Pipeline build. See [OAuth authentication from Azure Pipelines] for details. -```csharp -Task("ReportIssuesToPullRequest").Does(() => -{ - var isRunningOnAzureDevOps = - !string.IsNullOrWhiteSpace(context.EnvironmentVariable("TF_BUILD")) && - !string.IsNullOrWhiteSpace(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")) && - ( - new Uri(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")).Host == "dev.azure.com" || - new Uri(context.EnvironmentVariable("SYSTEM_COLLECTIONURI")).Host.EndsWith("visualstudio.com") - ); - - var isPullRequestBuild = - !string.IsNullOrWhiteSpace(context.EnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID")); - - if (isRunningOnAzureDevOps) - { - var repositoryUrl = new Uri(context.EnvironmentVariable("BUILD_REPOSITORY_URI")); - - if (isPullRequestBuild) - { - var pullRequestIdVariable = context.EnvironmentVariable("SYSTEM_PULLREQUEST_PULLREQUESTID"); - if (!Int32.TryParse(pullRequestIdVariable, out var pullRequestId)) - { - throw new Exception($"Invalid pull request ID: {pullRequestIdVariable}"); - } - else - { - var repoRootFolder = MakeAbsolute(Directory("./")); - - ReportIssuesToPullRequest( - InspectCodeIssuesFromFilePath( - @"C:\build\inspectcode.log"), - AzureDevOpsPullRequests( - repositoryUrl, - pullRequestId, - AzureDevOpsAuthenticationOAuth(EnvironmentVariable("SYSTEM_ACCESSTOKEN"))), - repoRootFolder); - } - } - } -}); -``` - [OAuth authentication from Azure Pipelines]: ../setup.md#oauth-authentication-from-azure-pipelines diff --git a/docs/docs/documentation/report-formats/console/examples.md b/docs/docs/documentation/report-formats/console/examples.md index a2db77409..d61d188c7 100644 --- a/docs/docs/documentation/report-formats/console/examples.md +++ b/docs/docs/documentation/report-formats/console/examples.md @@ -7,7 +7,6 @@ icon: material/test-tube The following example will print issues logged as warnings by MsBuild to the console. ```csharp -#tool "nuget:?package=MSBuild.Extension.Pack" // (1)! #addin nuget:?package=Cake.Issues&version={{ cake_issues_version }} #addin nuget:?package=Cake.Issues.MsBuild&version={{ cake_issues_version }} #addin nuget:?package=Cake.Issues.Reporting&version={{ cake_issues_version }} @@ -17,18 +16,16 @@ Task("Create-IssueReport").Does(() => { var repoRootFolder = new DirectoryPath(@"c:\repo"); - // Build MySolution.sln solution in the repository root folder and log issues - // using XmlFileLogger from MSBuild Extension Pack. + // Build MySolution.sln solution in the repository root folder and write a binary log. FilePath msBuildLogFile = @"c:\build\msbuild.log"; - var settings = new MsBuildSettings() - .WithLogger( - Context.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath, - "XmlFileLogger", - string.Format( - "logfile=\"{0}\";verbosity=Detailed;encoding=UTF-8", - msBuildLogFile) - ); - MSBuild(repoRootFolder.CombineWithFilePath("MySolution.sln"), settings); + var msBuildSettings = + new MSBuildSettings().WithLogger( + "BinaryLogger," + Context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll"), + "", + msBuildLogFile) + DotNetBuild( + repoRootPath.CombineWithFilePath("MySolution.sln"), + new DotNetBuildSettings{MSBuildSettings = msBuildSettings}); // Write issues to console. CreateIssueReport( @@ -36,7 +33,7 @@ Task("Create-IssueReport").Does(() => { MsBuildIssuesFromFilePath( msBuildLogFile, - MsBuildXmlFileLoggerFormat) + MsBuildBinaryLogFileFormat) }, ConsoleIssueReportFormat( new ConsoleIssueReportFormatSettings @@ -49,5 +46,3 @@ Task("Create-IssueReport").Does(() => string.Empty); }); ``` - ---8<-- "snippets/pinning.md" diff --git a/docs/docs/documentation/report-formats/generic/examples/custom-template.md b/docs/docs/documentation/report-formats/generic/examples/custom-template.md index b157293f9..56f148e98 100644 --- a/docs/docs/documentation/report-formats/generic/examples/custom-template.md +++ b/docs/docs/documentation/report-formats/generic/examples/custom-template.md @@ -10,7 +10,6 @@ description: Example how to create a report using a custom template The following example will create a HTML report for issues logged as warnings by MsBuild using a custom template. ```csharp -#tool "nuget:?package=MSBuild.Extension.Pack" // (1)! #addin nuget:?package=Cake.Issues&version={{ cake_issues_version }} #addin nuget:?package=Cake.Issues.MsBuild&version={{ cake_issues_version }} #addin nuget:?package=Cake.Issues.Reporting&version={{ cake_issues_version }} @@ -20,18 +19,16 @@ Task("Create-IssueReport").Does(() => { var repoRootFolder = new DirectoryPath(@"c:\repo"); - // Build MySolution.sln solution in the repository root folder and log issues - // using XmlFileLogger from MSBuild Extension Pack. + // Build MySolution.sln solution in the repository root folder and write a binary log. FilePath msBuildLogFile = @"c:\build\msbuild.log"; - var settings = new MsBuildSettings() - .WithLogger( - Context.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath, - "XmlFileLogger", - string.Format( - "logfile=\"{0}\";verbosity=Detailed;encoding=UTF-8", - msBuildLogFile) - ); - MSBuild(repoRootFolder.CombineWithFilePath("MySolution.sln"), settings); + var msBuildSettings = + new MSBuildSettings().WithLogger( + "BinaryLogger," + Context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll"), + "", + msBuildLogFile) + DotNetBuild( + repoRootPath.CombineWithFilePath("MySolution.sln"), + new DotNetBuildSettings{MSBuildSettings = msBuildSettings}); // Create HTML report using Diagnostic template. CreateIssueReport( @@ -39,7 +36,7 @@ Task("Create-IssueReport").Does(() => { MsBuildIssuesFromFilePath( msBuildLogFile, - MsBuildXmlFileLoggerFormat) + MsBuildBinaryLogFileFormat) }, GenericIssueReportFormatFromFilePath(@"c:\ReportTemplate.cshtml"), repoRootFolder, @@ -47,8 +44,6 @@ Task("Create-IssueReport").Does(() => }); ``` ---8<-- "snippets/pinning.md" - `ReportTemplate` looks like this: ```csharp diff --git a/docs/docs/documentation/report-formats/generic/examples/default-template.md b/docs/docs/documentation/report-formats/generic/examples/default-template.md index ef15ca77f..6eaa50694 100644 --- a/docs/docs/documentation/report-formats/generic/examples/default-template.md +++ b/docs/docs/documentation/report-formats/generic/examples/default-template.md @@ -6,7 +6,6 @@ description: Example how to create a report using an embedded default template. The following example will create a HTML report for issues logged as warnings by MsBuild. ```csharp -#tool "nuget:?package=MSBuild.Extension.Pack" // (1)! #addin nuget:?package=Cake.Issues&version={{ cake_issues_version }} #addin nuget:?package=Cake.Issues.MsBuild&version={{ cake_issues_version }} #addin nuget:?package=Cake.Issues.Reporting&version={{ cake_issues_version }} @@ -16,18 +15,16 @@ Task("Create-IssueReport").Does(() => { var repoRootFolder = new DirectoryPath(@"c:\repo"); - // Build MySolution.sln solution in the repository root folder and log issues - // using XmlFileLogger from MSBuild Extension Pack. + // Build MySolution.sln solution in the repository root folder and write a binary log. FilePath msBuildLogFile = @"c:\build\msbuild.log"; - var settings = new MsBuildSettings() - .WithLogger( - Context.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath, - "XmlFileLogger", - string.Format( - "logfile=\"{0}\";verbosity=Detailed;encoding=UTF-8", - msBuildLogFile) - ); - MSBuild(repoRootFolder.CombineWithFilePath("MySolution.sln"), settings); + var msBuildSettings = + new MSBuildSettings().WithLogger( + "BinaryLogger," + Context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll"), + "", + msBuildLogFile) + DotNetBuild( + repoRootPath.CombineWithFilePath("MySolution.sln"), + new DotNetBuildSettings{MSBuildSettings = msBuildSettings}); // Create HTML report using Diagnostic template. CreateIssueReport( @@ -35,12 +32,10 @@ Task("Create-IssueReport").Does(() => { MsBuildIssuesFromFilePath( msBuildLogFile, - MsBuildXmlFileLoggerFormat) + MsBuildBinaryLogFileFormat) }, GenericIssueReportFormatFromEmbeddedTemplate(GenericIssueReportTemplate.HtmlDiagnostic), repoRootFolder, @"c:\report.html"); }); ``` - ---8<-- "snippets/pinning.md" diff --git a/docs/docs/documentation/report-formats/sarif/examples.md b/docs/docs/documentation/report-formats/sarif/examples.md index 5d62375ff..5b7adffb8 100644 --- a/docs/docs/documentation/report-formats/sarif/examples.md +++ b/docs/docs/documentation/report-formats/sarif/examples.md @@ -7,7 +7,6 @@ icon: material/test-tube The following example will create a SARIF report for issues logged as warnings by MsBuild. ```csharp -#tool "nuget:?package=MSBuild.Extension.Pack" // (1)! #addin nuget:?package=Cake.Issues&version={{ cake_issues_version }} #addin nuget:?package=Cake.Issues.MsBuild&version={{ cake_issues_version }} #addin nuget:?package=Cake.Issues.Reporting&version={{ cake_issues_version }} @@ -17,18 +16,16 @@ Task("Create-IssueReport").Does(() => { var repoRootFolder = new DirectoryPath(@"c:\repo"); - // Build MySolution.sln solution in the repository root folder and log issues - // using XmlFileLogger from MSBuild Extension Pack. + // Build MySolution.sln solution in the repository root folder and write a binary log. FilePath msBuildLogFile = @"c:\build\msbuild.log"; - var settings = new MsBuildSettings() - .WithLogger( - Context.Tools.Resolve("MSBuild.ExtensionPack.Loggers.dll").FullPath, - "XmlFileLogger", - string.Format( - "logfile=\"{0}\";verbosity=Detailed;encoding=UTF-8", - msBuildLogFile) - ); - MSBuild(repoRootFolder.CombineWithFilePath("MySolution.sln"), settings); + var msBuildSettings = + new MSBuildSettings().WithLogger( + "BinaryLogger," + Context.Tools.Resolve("Cake.Issues.MsBuild*/**/StructuredLogger.dll"), + "", + msBuildLogFile) + DotNetBuild( + repoRootPath.CombineWithFilePath("MySolution.sln"), + new DotNetBuildSettings{MSBuildSettings = msBuildSettings}); // Create SARIF report. CreateIssueReport( @@ -36,12 +33,10 @@ Task("Create-IssueReport").Does(() => { MsBuildIssuesFromFilePath( msBuildLogFile, - MsBuildXmlFileLoggerFormat) + MsBuildBinaryLogFileFormat) }, SarifIssueReportFormat(), repoRootFolder, @"c:\report.sarif"); }); ``` - ---8<-- "snippets/pinning.md" diff --git a/docs/docs/documentation/usage/creating-reports/creating-reports.md b/docs/docs/documentation/usage/creating-reports/creating-reports.md index 826879a0c..21213d4b2 100644 --- a/docs/docs/documentation/usage/creating-reports/creating-reports.md +++ b/docs/docs/documentation/usage/creating-reports/creating-reports.md @@ -28,7 +28,7 @@ Task("Create-Report").Does(() => CreateIssueReport( MsBuildIssuesFromFilePath( @"C:\build\msbuild.log", - MsBuildXmlFileLoggerFormat), + MsBuildBinaryLogFileFormat), GenericIssueReportFormatFromEmbeddedTemplate(GenericIssueReportTemplate.HtmlDiagnostic), repoRootFolder, @"c:\report.html"); diff --git a/docs/docs/documentation/usage/reading-issues/file-linking.md b/docs/docs/documentation/usage/reading-issues/file-linking.md index 1798021e0..7a1609086 100644 --- a/docs/docs/documentation/usage/reading-issues/file-linking.md +++ b/docs/docs/documentation/usage/reading-issues/file-linking.md @@ -12,7 +12,7 @@ var settings = { FileLinkSettings = IssueFileLinkSettingsForGitHubCommit( - "https://github.com/cake-contrib/Cake.Issues.Reporting.Generic", + "https://github.com/cake-contrib/Cake.Issues", "76a7cacef7ad4295a6766646d45c9b56") }; diff --git a/docs/docs/documentation/usage/reading-issues/reading-issues.md b/docs/docs/documentation/usage/reading-issues/reading-issues.md index d222c64cc..9b76a9c6d 100644 --- a/docs/docs/documentation/usage/reading-issues/reading-issues.md +++ b/docs/docs/documentation/usage/reading-issues/reading-issues.md @@ -22,8 +22,8 @@ and from JetBrains InspectCode are imported: ``` Finally you can define a task where you call the core addin with the desired issue providers. -The following example reads issues reported as MsBuild warnings by the `XmlFileLogger` -class from [MSBuild Extension Pack](http://www.msbuildextensionpack.com/){target="_blank"} and issues reported by JetBrains InspectCode: +The following example reads warnings and errors reported by MsBuild from a binary log +and issues reported by JetBrains InspectCode: ```csharp Task("Read-Issues").Does(() => @@ -34,7 +34,7 @@ Task("Read-Issues").Does(() => { MsBuildIssuesFromFilePath( @"C:\build\msbuild.log", - MsBuildXmlFileLoggerFormat), + MsBuildBinaryLogFileFormat), InspectCodeIssuesFromFilePath( @"C:\build\inspectcode.log") }, diff --git a/docs/docs/documentation/usage/reading-issues/run-information.md b/docs/docs/documentation/usage/reading-issues/run-information.md index 7535768f4..193118e47 100644 --- a/docs/docs/documentation/usage/reading-issues/run-information.md +++ b/docs/docs/documentation/usage/reading-issues/run-information.md @@ -19,7 +19,7 @@ issues.AddRange( ReadIssues( MsBuildIssuesFromFilePath( @"C:\build\solution1-msbuild.log", - MsBuildXmlFileLoggerFormat), + MsBuildBinaryLogFileFormat), new ReadIssuesSettings(@"c:\repo") { Run = "Solution 1" @@ -32,7 +32,7 @@ issues.AddRange( ReadIssues( MsBuildIssuesFromFilePath( @"C:\build\solution2-msbuild.log", - MsBuildXmlFileLoggerFormat), + MsBuildBinaryLogFileFormat), new ReadIssuesSettings(@"c:\repo") { Run = "Solution 2" diff --git a/docs/docs/documentation/usage/recipe/using-cake-issues-recipe.md b/docs/docs/documentation/usage/recipe/using-cake-issues-recipe.md index 2754a42df..31db2db1c 100644 --- a/docs/docs/documentation/usage/recipe/using-cake-issues-recipe.md +++ b/docs/docs/documentation/usage/recipe/using-cake-issues-recipe.md @@ -27,7 +27,7 @@ Task("Configure-CakeIssuesRecipe") .IsDependentOn("Run-InspectCode") .Does(() => { - IssuesParameters.InputFiles.AddMsBuildXmlFileLoggerLogFilePath(msBuildLogFilePath); + IssuesParameters.InputFiles.AddMsBuildBinaryLogFilePath(msBuildLogFilePath); IssuesParameters.InputFiles.AddInspectCodeLogFilePath(inspectCodeLogFilePath); } ``` diff --git a/docs/docs/documentation/usage/reporting-issues-to-pull-requests/custom-issue-filter.md b/docs/docs/documentation/usage/reporting-issues-to-pull-requests/custom-issue-filter.md index 03391129c..030ba80e4 100644 --- a/docs/docs/documentation/usage/reporting-issues-to-pull-requests/custom-issue-filter.md +++ b/docs/docs/documentation/usage/reporting-issues-to-pull-requests/custom-issue-filter.md @@ -34,12 +34,9 @@ Task("ReportIssuesToPullRequest").Does(() => { MsBuildIssuesFromFilePath( @"C:\build\msbuild.log", - MsBuildXmlFileLoggerFormat) + MsBuildBinaryLogFileFormat) }, - AzureDevOpsPullRequests( - new Uri("http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository"), - "refs/heads/feature/myfeature", - AzureDevOpsAuthenticationNtlm()), + AzureDevOpsPullRequests(), settings)); }); ``` diff --git a/docs/docs/documentation/usage/reporting-issues-to-pull-requests/report-issues-to-pull-requests.md b/docs/docs/documentation/usage/reporting-issues-to-pull-requests/report-issues-to-pull-requests.md index 2a8fd59d8..99ecf218d 100644 --- a/docs/docs/documentation/usage/reporting-issues-to-pull-requests/report-issues-to-pull-requests.md +++ b/docs/docs/documentation/usage/reporting-issues-to-pull-requests/report-issues-to-pull-requests.md @@ -28,11 +28,8 @@ Task("ReportIssuesToPullRequest").Does(() => ReportIssuesToPullRequest( MsBuildIssuesFromFilePath( @"C:\build\msbuild.log", - MsBuildXmlFileLoggerFormat), - AzureDevOpsPullRequests( - new Uri("http://myserver:8080/tfs/defaultcollection/myproject/_git/myrepository"), - "refs/heads/feature/myfeature", - AzureDevOpsAuthenticationNtlm()), + MsBuildBinaryLogFileFormat), + AzureDevOpsPullRequests(), repoRootFolder); }); ```