From d9fefd1b231989242d7b823ea965538bb7adfbb2 Mon Sep 17 00:00:00 2001 From: Weihan Li Date: Thu, 4 Jan 2024 22:58:38 +0800 Subject: [PATCH] build: PublishCodeCoverageResults --- azure-pipelines.yml | 14 ++++++++------ build/build.cs | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index df687450..c1559368 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -32,13 +32,15 @@ steps: - script: dotnet --info displayName: 'dotnet info' -- task: DotNetCoreCLI@2 - displayName: 'Run Unit Tests' - inputs: - command: 'test' - arguments: '--no-build -c Release --collect "XPlat Code Coverage"' - - powershell: ./build.ps1 displayName: 'Powershell Script' env: Nuget__ApiKey: $(nugetApiKey) + +# Publish code coverage results v2 +# Publish any of the code coverage results from a build. +- task: PublishCodeCoverageResults@2 + inputs: + summaryFileLocation: "**/coverage.*.xml" # string. Required. Path to summary files. + #pathToSources: # string. Path to Source files. + #failIfCoverageEmpty: false # boolean. Fail if code coverage results are missing. Default: false. \ No newline at end of file diff --git a/build/build.cs b/build/build.cs index 87122eb9..8732e446 100644 --- a/build/build.cs +++ b/build/build.cs @@ -51,7 +51,7 @@ await BuildProcess.CreateBuilder() { foreach (var project in testProjects) { - await ExecuteCommandAsync($"dotnet test {project}"); + await ExecuteCommandAsync($"dotnet test {project} --collect 'XPlat Code Coverage;ExcludeByAttribute=ExcludeFromCodeCoverage,Obsolete,GeneratedCode,CompilerGeneratedAttribute'"); } }) ;