Skip to content

Commit

Permalink
.NET 8 preparation
Browse files Browse the repository at this point in the history
Cherry-pick various changes from #412.
  • Loading branch information
martincostello committed May 18, 2023
1 parent 5084257 commit b06632c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
name: Upload coverage to Codecov
with:
file: ./artifacts/coverage.net7.0.cobertura.xml
file: ./artifacts/coverage/coverage.net7.0.cobertura.xml
flags: ${{ matrix.os_name }}

- name: Publish artifacts
Expand All @@ -64,6 +64,7 @@ jobs:
with:
name: packages-${{ matrix.os_name }}
path: ./artifacts/packages
if-no-files-found: error

validate-packages:
needs: build
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.artifacts/
.DS_Store
.dotnetcli
.idea
Expand Down
1 change: 0 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
</ItemGroup>
<PropertyGroup Condition=" '$(BuildingInsideVisualStudio)' != 'true' ">
<CollectCoverage>true</CollectCoverage>
<CoverletOutput Condition=" '$(OutputPath)' != '' ">$(OutputPath)/</CoverletOutput>
<CoverletOutputFormat>cobertura,json</CoverletOutputFormat>
<Exclude>[SampleApp]*,[xunit.*]*</Exclude>
<ExcludeByAttribute>System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute</ExcludeByAttribute>
Expand Down
3 changes: 2 additions & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@
</ItemGroup>
</Target>
<PropertyGroup Condition=" '$(CollectCoverage)' == 'true' ">
<CoverletOutput>$([System.IO.Path]::Combine($(OutputPath), 'coverage', 'coverage'))</CoverletOutput>
<ReportGeneratorOutputMarkdown Condition=" '$(ReportGeneratorOutputMarkdown)' == '' AND '$(GITHUB_SHA)' != '' ">true</ReportGeneratorOutputMarkdown>
<ReportGeneratorReportTypes>HTML</ReportGeneratorReportTypes>
<ReportGeneratorReportTypes Condition=" '$(ReportGeneratorOutputMarkdown)' == 'true' ">$(ReportGeneratorReportTypes);MarkdownSummaryGitHub</ReportGeneratorReportTypes>
<ReportGeneratorTargetDirectory>$([System.IO.Path]::Combine($(OutputPath), 'coverage-reports'))</ReportGeneratorTargetDirectory>
<ReportGeneratorTargetDirectory>$([System.IO.Path]::Combine($(OutputPath), 'coverage'))</ReportGeneratorTargetDirectory>
<_MarkdownSummaryPrefix>&lt;details&gt;&lt;summary&gt;:chart_with_upwards_trend: &lt;b&gt;$(AssemblyName) Code Coverage report&lt;/b&gt;&lt;/summary&gt;</_MarkdownSummaryPrefix>
<_MarkdownSummarySuffix>&lt;/details&gt;</_MarkdownSummarySuffix>
</PropertyGroup>
Expand Down
28 changes: 2 additions & 26 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

param(
[Parameter(Mandatory = $false)][string] $Configuration = "Release",
[Parameter(Mandatory = $false)][string] $VersionSuffix = "",
[Parameter(Mandatory = $false)][string] $OutputPath = "",
[Parameter(Mandatory = $false)][switch] $SkipTests
)
Expand All @@ -18,7 +17,6 @@ $ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"

$solutionPath = $PSScriptRoot
$solutionFile = Join-Path $solutionPath "Logging.XUnit.sln"
$sdkFile = Join-Path $solutionPath "global.json"

$libraryProject = Join-Path $solutionPath "src\Logging.XUnit\MartinCostello.Logging.XUnit.csproj"
Expand Down Expand Up @@ -87,31 +85,13 @@ if ($installDotNetSdk -eq $true) {
$env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH"
}

function DotNetBuild {
param([string]$Project)

if ($VersionSuffix) {
& $dotnet build $Project --configuration $Configuration --version-suffix "$VersionSuffix"
}
else {
& $dotnet build $Project --configuration $Configuration
}
if ($LASTEXITCODE -ne 0) {
throw "dotnet build failed with exit code $LASTEXITCODE"
}
}

function DotNetPack {
param([string]$Project)

$PackageOutputPath = (Join-Path $OutputPath "packages")

if ($VersionSuffix) {
& $dotnet pack $Project --output $PackageOutputPath --configuration $Configuration --version-suffix "$VersionSuffix" --include-symbols --include-source
}
else {
& $dotnet pack $Project --output $PackageOutputPath --configuration $Configuration --include-symbols --include-source
}
& $dotnet pack $Project --output $PackageOutputPath --configuration $Configuration --include-symbols --include-source

if ($LASTEXITCODE -ne 0) {
throw "dotnet pack failed with exit code $LASTEXITCODE"
}
Expand All @@ -134,14 +114,10 @@ function DotNetTest {
}
}

Write-Host "Building solution..." -ForegroundColor Green
DotNetBuild $solutionFile

Write-Host "Packaging library..." -ForegroundColor Green
DotNetPack $libraryProject

Write-Host "Running tests..." -ForegroundColor Green
ForEach ($testProject in $testProjects) {
DotNetTest $testProject
}

0 comments on commit b06632c

Please sign in to comment.