diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 17ef7451..17dc5e42 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -30,7 +30,7 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Setup .NET Core SDK + - name: Setup .NET SDK uses: actions/setup-dotnet@v3 - name: Install StatsD diff --git a/Directory.Build.targets b/Directory.Build.targets index 8c119d54..0bdc5742 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,2 +1,14 @@ + + true + HTML + $(ReportGeneratorReportTypes);MarkdownSummaryGitHub + $([System.IO.Path]::Combine($(OutputPath), 'coverage')) + <_MarkdownSummaryPrefix><details><summary>:chart_with_upwards_trend: <b>$(AssemblyName) Code Coverage report</b></summary> + <_MarkdownSummarySuffix></details> + + + + + diff --git a/build.ps1 b/build.ps1 index 665b833f..f37bfcee 100755 --- a/build.ps1 +++ b/build.ps1 @@ -31,7 +31,7 @@ if ($OutputPath -eq "") { $installDotNetSdk = $false; if (($null -eq (Get-Command "dotnet" -ErrorAction SilentlyContinue)) -and ($null -eq (Get-Command "dotnet.exe" -ErrorAction SilentlyContinue))) { - Write-Host "The .NET Core SDK is not installed." + Write-Host "The .NET SDK is not installed." $installDotNetSdk = $true } else { @@ -43,7 +43,7 @@ else { } if ($installedDotNetVersion -ne $dotnetVersion) { - Write-Host "The required version of the .NET Core SDK is not installed. Expected $dotnetVersion." + Write-Host "The required version of the .NET SDK is not installed. Expected $dotnetVersion." $installDotNetSdk = $true } } @@ -85,12 +85,21 @@ if ($installDotNetSdk -eq $true) { function DotNetPack { param([string]$Project) + $additionalArgs = @() + if ($VersionSuffix) { - & $dotnet pack $Project --output (Join-Path $OutputPath "packages") --configuration $Configuration --version-suffix "$VersionSuffix" --include-symbols --include-source - } - else { - & $dotnet pack $Project --output (Join-Path $OutputPath "packages") --configuration $Configuration --include-symbols --include-source + $additionalArgs += "--version-suffix" + $additionalArgs += $VersionSuffix } + + & $dotnet ` + pack $Project ` + --output (Join-Path $OutputPath "packages") ` + --configuration $Configuration ` + --include-symbols ` + --include-source ` + $additionalArgs + if ($LASTEXITCODE -ne 0) { throw "dotnet pack failed with exit code $LASTEXITCODE" } @@ -99,14 +108,6 @@ function DotNetPack { function DotNetTest { param([string]$Project) - $nugetPath = Join-Path ($env:USERPROFILE ?? "~") ".nuget\packages" - $propsFile = Join-Path $solutionPath "Directory.Packages.props" - $reportGeneratorVersion = (Select-Xml -Path $propsFile -XPath "//PackageVersion[@Include='ReportGenerator']/@Version").Node.'#text' - $reportGeneratorPath = Join-Path $nugetPath "reportgenerator\$reportGeneratorVersion\tools\net6.0\ReportGenerator.dll" - - $coverageOutput = Join-Path $OutputPath "coverage.*.cobertura.xml" - $reportOutput = Join-Path $OutputPath "coverage" - $additionalArgs = @() if (![string]::IsNullOrEmpty($env:GITHUB_SHA)) { @@ -116,19 +117,8 @@ function DotNetTest { & $dotnet test $Project --output $OutputPath --configuration $Configuration $additionalArgs - $dotNetTestExitCode = $LASTEXITCODE - - if (Test-Path $coverageOutput) { - & $dotnet ` - $reportGeneratorPath ` - `"-reports:$coverageOutput`" ` - `"-targetdir:$reportOutput`" ` - -reporttypes:HTML ` - -verbosity:Warning - } - - if ($dotNetTestExitCode -ne 0) { - throw "dotnet test failed with exit code $dotNetTestExitCode" + if ($LASTEXITCODE -ne 0) { + throw "dotnet test failed with exit code $LASTEXITCODE" } }