diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index d00168de..2cd10ee3 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -26,11 +26,11 @@ jobs: name: ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: 'Cache: .nuke/temp, ~/.nuget/packages' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | .nuke/temp @@ -41,7 +41,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 'Publish: coverage_report' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage_report path: .tests/coverage_report diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ff8b879c..53e9d08e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,11 +26,11 @@ jobs: name: ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: 'Cache: .nuke/temp, ~/.nuget/packages' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | .nuke/temp @@ -41,7 +41,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 'Publish: coverage_report' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage_report path: .tests/coverage_report diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 1dcbc962..1cd85396 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -26,11 +26,11 @@ jobs: name: ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: 'Cache: .nuke/temp, ~/.nuget/packages' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | .nuke/temp @@ -41,7 +41,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 'Publish: coverage_report' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 + if: runner.os == 'Linux' with: name: coverage_report path: .tests/coverage_report @@ -49,11 +50,11 @@ jobs: name: windows-latest runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: 'Cache: .nuke/temp, ~/.nuget/packages' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | .nuke/temp @@ -64,7 +65,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 'Publish: coverage_report' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 + if: runner.os == 'Linux' with: name: coverage_report path: .tests/coverage_report diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dba79f2a..e420f1a9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -26,11 +26,11 @@ jobs: name: ubuntu-latest runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: 'Cache: .nuke/temp, ~/.nuget/packages' - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | .nuke/temp @@ -42,7 +42,7 @@ jobs: NUGET_ORG_TOKEN: ${{ secrets.NUGET_ORG_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 'Publish: coverage_report' - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: coverage_report path: .tests/coverage_report diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index c390ca16..be4fe84f 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -1,58 +1,68 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "$ref": "#/definitions/build", - "title": "Build Schema", "definitions": { - "build": { - "type": "object", + "Host": { + "type": "string", + "enum": [ + "AppVeyor", + "AzurePipelines", + "Bamboo", + "Bitbucket", + "Bitrise", + "GitHubActions", + "GitLab", + "Jenkins", + "Rider", + "SpaceAutomation", + "TeamCity", + "Terminal", + "TravisCI", + "VisualStudio", + "VSCode" + ] + }, + "ExecutableTarget": { + "type": "string", + "enum": [ + "Build", + "Clean", + "CodeCoverage", + "DeployNuGet", + "Pack", + "PushNuGet", + "Rebuild", + "Restore", + "Test" + ] + }, + "Verbosity": { + "type": "string", + "description": "", + "enum": [ + "Verbose", + "Normal", + "Minimal", + "Quiet" + ] + }, + "NukeBuild": { "properties": { - "Configuration": { - "type": "string", - "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", - "enum": [ - "Debug", - "Release" - ] - }, "Continue": { "type": "boolean", "description": "Indicates to continue a previously failed build attempt" }, - "GITHUB_TOKEN": { - "type": "string" - }, "Help": { "type": "boolean", "description": "Shows the help text for this build assembly" }, "Host": { - "type": "string", "description": "Host for execution. Default is 'automatic'", - "enum": [ - "AppVeyor", - "AzurePipelines", - "Bamboo", - "Bitbucket", - "Bitrise", - "GitHubActions", - "GitLab", - "Jenkins", - "Rider", - "SpaceAutomation", - "TeamCity", - "Terminal", - "TravisCI", - "VisualStudio", - "VSCode" - ] + "$ref": "#/definitions/Host" }, "NoLogo": { "type": "boolean", "description": "Disables displaying the NUKE logo" }, - "NUGET_ORG_TOKEN": { - "type": "string" - }, "Partition": { "type": "string", "description": "Partition to use on CI" @@ -76,53 +86,48 @@ "type": "array", "description": "List of targets to be skipped. Empty list skips all dependencies", "items": { - "type": "string", - "enum": [ - "Build", - "Clean", - "CodeCoverage", - "DeployNuGet", - "Pack", - "PushNuGet", - "Rebuild", - "Restore", - "Test" - ] + "$ref": "#/definitions/ExecutableTarget" } }, - "Solution": { - "type": "string", - "description": "Path to a solution file that is automatically loaded" - }, "Target": { "type": "array", "description": "List of targets to be invoked. Default is '{default_target}'", "items": { - "type": "string", - "enum": [ - "Build", - "Clean", - "CodeCoverage", - "DeployNuGet", - "Pack", - "PushNuGet", - "Rebuild", - "Restore", - "Test" - ] + "$ref": "#/definitions/ExecutableTarget" } }, "Verbosity": { - "type": "string", "description": "Logging verbosity during build execution. Default is 'Normal'", + "$ref": "#/definitions/Verbosity" + } + } + } + }, + "allOf": [ + { + "properties": { + "Configuration": { + "type": "string", + "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", "enum": [ - "Minimal", - "Normal", - "Quiet", - "Verbose" + "Debug", + "Release" ] + }, + "GITHUB_TOKEN": { + "type": "string" + }, + "NUGET_ORG_TOKEN": { + "type": "string" + }, + "Solution": { + "type": "string", + "description": "Path to a solution file that is automatically loaded" } } + }, + { + "$ref": "#/definitions/NukeBuild" } - } + ] } diff --git a/build/Build.cs b/build/Build.cs index 2c39158b..2f18b39c 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -30,6 +30,7 @@ InvokedTargets = [NukeTargets.Rebuild, NukeTargets.CodeCoverage, NukeTargets.Pack], EnableGitHubToken = true, PublishArtifacts = true, + PublishCondition = "runner.os == 'Linux'", FetchDepth = 0 )] [GitHubActions("main", GitHubActionsImage.UbuntuLatest, diff --git a/build/_build.csproj b/build/_build.csproj index d89342d8..74330ba7 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -12,10 +12,8 @@ - - - - + + diff --git a/samples/BlazorWebAssemblySampleApp/BlazorWebAssemblySampleApp.csproj b/samples/BlazorWebAssemblySampleApp/BlazorWebAssemblySampleApp.csproj index 8d92bcb7..64082e34 100644 --- a/samples/BlazorWebAssemblySampleApp/BlazorWebAssemblySampleApp.csproj +++ b/samples/BlazorWebAssemblySampleApp/BlazorWebAssemblySampleApp.csproj @@ -5,12 +5,9 @@ - - - - - - + + + diff --git a/samples/BlazorWebAssemblySampleApp/Pages/Counter.razor b/samples/BlazorWebAssemblySampleApp/Pages/Counter.razor index accec907..1a1d5afc 100644 --- a/samples/BlazorWebAssemblySampleApp/Pages/Counter.razor +++ b/samples/BlazorWebAssemblySampleApp/Pages/Counter.razor @@ -9,7 +9,7 @@ - + @* *@ @**@ diff --git a/samples/NetSampleApp/NetSampleApp.csproj b/samples/NetSampleApp/NetSampleApp.csproj index c8e11a70..17071043 100644 --- a/samples/NetSampleApp/NetSampleApp.csproj +++ b/samples/NetSampleApp/NetSampleApp.csproj @@ -7,7 +7,6 @@ - diff --git a/samples/WebApiSampleApp/WebApiSampleApp.csproj b/samples/WebApiSampleApp/WebApiSampleApp.csproj index 24dd7393..53c98021 100644 --- a/samples/WebApiSampleApp/WebApiSampleApp.csproj +++ b/samples/WebApiSampleApp/WebApiSampleApp.csproj @@ -7,8 +7,7 @@ - - + diff --git a/source/AspNetCore/CreativeCoders.AspNetCore.Blazor/CreativeCoders.AspNetCore.Blazor.csproj b/source/AspNetCore/CreativeCoders.AspNetCore.Blazor/CreativeCoders.AspNetCore.Blazor.csproj index 33c7afa3..27660138 100644 --- a/source/AspNetCore/CreativeCoders.AspNetCore.Blazor/CreativeCoders.AspNetCore.Blazor.csproj +++ b/source/AspNetCore/CreativeCoders.AspNetCore.Blazor/CreativeCoders.AspNetCore.Blazor.csproj @@ -7,9 +7,9 @@ - - - + + + diff --git a/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/CreativeCoders.AspNetCore.TokenAuth.Jwt.csproj b/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/CreativeCoders.AspNetCore.TokenAuth.Jwt.csproj index b8334057..4c00542d 100644 --- a/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/CreativeCoders.AspNetCore.TokenAuth.Jwt.csproj +++ b/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/CreativeCoders.AspNetCore.TokenAuth.Jwt.csproj @@ -7,7 +7,7 @@ - + diff --git a/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/JwtBearerOptionsConfiguration.cs b/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/JwtBearerOptionsConfiguration.cs index 52982070..50b062c5 100644 --- a/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/JwtBearerOptionsConfiguration.cs +++ b/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/JwtBearerOptionsConfiguration.cs @@ -38,7 +38,7 @@ public void Configure(JwtBearerOptions options) options.Events = CreateJwtBearerEvents(); } - public void Configure(string name, JwtBearerOptions options) + public void Configure(string? name, JwtBearerOptions options) { Configure(options); } diff --git a/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/JwtHttpRequestExtensions.cs b/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/JwtHttpRequestExtensions.cs index 8ea38dfe..7595cc04 100644 --- a/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/JwtHttpRequestExtensions.cs +++ b/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuth.Jwt/JwtHttpRequestExtensions.cs @@ -8,7 +8,7 @@ public static string GetJwtToken(this HttpRequest request, string authTokenName) { var token = request.Headers.Authorization.FirstOrDefault(x => - x.StartsWith("Bearer ", StringComparison.Ordinal)); + x?.StartsWith("Bearer ", StringComparison.Ordinal) == true); if (!string.IsNullOrEmpty(token) && token.StartsWith("Bearer ", StringComparison.Ordinal)) { diff --git a/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuthApi.Jwt/CreativeCoders.AspNetCore.TokenAuthApi.Jwt.csproj b/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuthApi.Jwt/CreativeCoders.AspNetCore.TokenAuthApi.Jwt.csproj index e32e7881..b01b5757 100644 --- a/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuthApi.Jwt/CreativeCoders.AspNetCore.TokenAuthApi.Jwt.csproj +++ b/source/AspNetCore/CreativeCoders.AspNetCore.TokenAuthApi.Jwt/CreativeCoders.AspNetCore.TokenAuthApi.Jwt.csproj @@ -8,7 +8,7 @@ - + diff --git a/source/CodeCompilation/CreativeCoders.CodeCompilation.Roslyn/CreativeCoders.CodeCompilation.Roslyn.csproj b/source/CodeCompilation/CreativeCoders.CodeCompilation.Roslyn/CreativeCoders.CodeCompilation.Roslyn.csproj index 0afe9ee4..b71ab195 100644 --- a/source/CodeCompilation/CreativeCoders.CodeCompilation.Roslyn/CreativeCoders.CodeCompilation.Roslyn.csproj +++ b/source/CodeCompilation/CreativeCoders.CodeCompilation.Roslyn/CreativeCoders.CodeCompilation.Roslyn.csproj @@ -6,7 +6,7 @@ - + diff --git a/source/Core/CreativeCoders.Core/CreativeCoders.Core.csproj b/source/Core/CreativeCoders.Core/CreativeCoders.Core.csproj index 3157c2b3..1feb7b25 100644 --- a/source/Core/CreativeCoders.Core/CreativeCoders.Core.csproj +++ b/source/Core/CreativeCoders.Core/CreativeCoders.Core.csproj @@ -8,7 +8,7 @@ - + diff --git a/source/Data/CreativeCoders.Data.EfCore.SqlServer/CreativeCoders.Data.EfCore.SqlServer.csproj b/source/Data/CreativeCoders.Data.EfCore.SqlServer/CreativeCoders.Data.EfCore.SqlServer.csproj index d4123dd1..4a99463e 100644 --- a/source/Data/CreativeCoders.Data.EfCore.SqlServer/CreativeCoders.Data.EfCore.SqlServer.csproj +++ b/source/Data/CreativeCoders.Data.EfCore.SqlServer/CreativeCoders.Data.EfCore.SqlServer.csproj @@ -6,7 +6,7 @@ - + diff --git a/source/Data/CreativeCoders.Data.EfCore/CreativeCoders.Data.EfCore.csproj b/source/Data/CreativeCoders.Data.EfCore/CreativeCoders.Data.EfCore.csproj index d0a17c64..cc02d114 100644 --- a/source/Data/CreativeCoders.Data.EfCore/CreativeCoders.Data.EfCore.csproj +++ b/source/Data/CreativeCoders.Data.EfCore/CreativeCoders.Data.EfCore.csproj @@ -6,7 +6,7 @@ - + diff --git a/source/DynamicCode/CreativeCoders.DynamicCode.Proxying/CreativeCoders.DynamicCode.Proxying.csproj b/source/DynamicCode/CreativeCoders.DynamicCode.Proxying/CreativeCoders.DynamicCode.Proxying.csproj index 52644d46..5c0816b0 100644 --- a/source/DynamicCode/CreativeCoders.DynamicCode.Proxying/CreativeCoders.DynamicCode.Proxying.csproj +++ b/source/DynamicCode/CreativeCoders.DynamicCode.Proxying/CreativeCoders.DynamicCode.Proxying.csproj @@ -7,7 +7,7 @@ - + diff --git a/source/IO/CreativeCoders.IO/CreativeCoders.IO.csproj b/source/IO/CreativeCoders.IO/CreativeCoders.IO.csproj index e8c16f64..b1ce3f53 100644 --- a/source/IO/CreativeCoders.IO/CreativeCoders.IO.csproj +++ b/source/IO/CreativeCoders.IO/CreativeCoders.IO.csproj @@ -7,7 +7,7 @@ - + diff --git a/source/Net/CreativeCoders.Net.WebApi/CreativeCoders.Net.WebApi.csproj b/source/Net/CreativeCoders.Net.WebApi/CreativeCoders.Net.WebApi.csproj index 87093677..f38996dc 100644 --- a/source/Net/CreativeCoders.Net.WebApi/CreativeCoders.Net.WebApi.csproj +++ b/source/Net/CreativeCoders.Net.WebApi/CreativeCoders.Net.WebApi.csproj @@ -6,7 +6,7 @@ - + diff --git a/source/Net/CreativeCoders.Net/CreativeCoders.Net.csproj b/source/Net/CreativeCoders.Net/CreativeCoders.Net.csproj index f5526cee..25679f3e 100644 --- a/source/Net/CreativeCoders.Net/CreativeCoders.Net.csproj +++ b/source/Net/CreativeCoders.Net/CreativeCoders.Net.csproj @@ -8,7 +8,7 @@ - + diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/CreativeCoders.NukeBuild.Components.csproj b/source/NukeBuild/CreativeCoders.NukeBuild.Components/CreativeCoders.NukeBuild.Components.csproj index 985d8bdc..ab039504 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/CreativeCoders.NukeBuild.Components.csproj +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/CreativeCoders.NukeBuild.Components.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IBuildTarget.cs b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IBuildTarget.cs index 0eab9997..ef3a7b89 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IBuildTarget.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IBuildTarget.cs @@ -22,8 +22,10 @@ DotNetBuildSettings ConfigureCompileSettings(DotNetBuildSettings buildSettings) sealed DotNetBuildSettings ConfigureDefaultCompileSettings(DotNetBuildSettings buildSettings) { + var solutionParameter = this.As(); + return buildSettings - .When(this.TryAs(out var solutionParameter), x => x + .When(_ => solutionParameter != null, x => x // ReSharper disable once NullableWarningSuppressionIsUsed .SetProjectFile(solutionParameter!.Solution)) .WhenNotNull(this as IConfigurationParameter, (x, configuration) => x diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ICleanTarget.cs b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ICleanTarget.cs index fd695e39..82fb183c 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ICleanTarget.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ICleanTarget.cs @@ -28,8 +28,10 @@ DotNetCleanSettings ConfigureCleanSettings(DotNetCleanSettings cleanSettings) [SuppressMessage("ReSharper", "NullableWarningSuppressionIsUsed")] sealed DotNetCleanSettings ConfigureDefaultCleanSettings(DotNetCleanSettings cleanSettings) { + var solutionParameter = this.As(); + return cleanSettings - .When(this.TryAs(out var solutionParameter), + .When(_ => solutionParameter != null, x => x.SetProject(solutionParameter!.Solution)); } } diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ICodeCoverageTarget.cs b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ICodeCoverageTarget.cs index bd2eacd1..a635ffca 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ICodeCoverageTarget.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ICodeCoverageTarget.cs @@ -2,6 +2,7 @@ using CreativeCoders.NukeBuild.Components.Targets.Settings; using JetBrains.Annotations; using Nuke.Common; +using Nuke.Common.Tooling; using Nuke.Common.Tools.ReportGenerator; namespace CreativeCoders.NukeBuild.Components.Targets; diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPackTarget.cs b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPackTarget.cs index 3b604f45..db855967 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPackTarget.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPackTarget.cs @@ -33,18 +33,18 @@ DotNetPackSettings ConfigureDefaultPackSettings(DotNetPackSettings packSettings) .WhenNotNull(this as IConfigurationParameter, (x, configurationParameter) => x .SetConfiguration(configurationParameter.Configuration)) .EnableIncludeSymbols() - .When(!string.IsNullOrWhiteSpace(OutputDirectory), x => x + .When(_ => !string.IsNullOrWhiteSpace(OutputDirectory), x => x .SetOutputDirectory(OutputDirectory)) .WhenNotNull(this as IGitVersionParameter, (x, gitVersionParameter) => x .SetVersion(gitVersionParameter.GitVersion?.NuGetVersionV2)) .SetNoBuild(SucceededTargets.Contains(this.As()?.Build)) - .When(!string.IsNullOrWhiteSpace(Copyright), x => x + .When(_ => !string.IsNullOrWhiteSpace(Copyright), x => x .SetCopyright(Copyright)) - .When(!string.IsNullOrWhiteSpace(PackageProjectUrl), x => x + .When(_ => !string.IsNullOrWhiteSpace(PackageProjectUrl), x => x .SetPackageProjectUrl(PackageProjectUrl)) - .When(!string.IsNullOrWhiteSpace(PackageLicenseUrl), x => x + .When(_ => !string.IsNullOrWhiteSpace(PackageLicenseUrl), x => x .SetPackageLicenseUrl(PackageLicenseUrl)) - .When(!string.IsNullOrWhiteSpace(PackageLicenseExpression), x => x + .When(_ => !string.IsNullOrWhiteSpace(PackageLicenseExpression), x => x .SetProperty("PackageLicenseExpression", PackageLicenseExpression)); } } diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPublishTarget.cs b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPublishTarget.cs index d28d3d44..86b8b529 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPublishTarget.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPublishTarget.cs @@ -68,7 +68,7 @@ static DotNetPublishSettings ConfigureDefaultPublishItemSettings(DotNetPublishSe .SetProject(publishingItem.ProjectPath) .SetOutput(publishingItem.OutputPath) .SetSelfContained(publishingItem.SelfContained) - .When(!string.IsNullOrWhiteSpace(publishingItem.Runtime), x => x + .When(_ => !string.IsNullOrWhiteSpace(publishingItem.Runtime), x => x .SetRuntime(publishingItem.Runtime)); } } diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPushNuGetTarget.cs b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPushNuGetTarget.cs index 6971a20f..62d7bc78 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPushNuGetTarget.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IPushNuGetTarget.cs @@ -34,9 +34,9 @@ sealed DotNetNuGetPushSettings ConfigureDefaultNuGetPushSettings( { return nuGetPushSettings .SetTargetPath(packagePath) - .When(!string.IsNullOrWhiteSpace(NuGetFeedUrl), x => x + .When(_ => !string.IsNullOrWhiteSpace(NuGetFeedUrl), x => x .SetSource(NuGetFeedUrl)) - .When(!string.IsNullOrWhiteSpace(NuGetApiKey), x => x + .When(_ => !string.IsNullOrWhiteSpace(NuGetApiKey), x => x .SetApiKey(NuGetApiKey)); } } diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IRestoreTarget.cs b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IRestoreTarget.cs index 0dbad633..2af438df 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IRestoreTarget.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/IRestoreTarget.cs @@ -23,8 +23,10 @@ DotNetRestoreSettings ConfigureRestoreSettings(DotNetRestoreSettings buildSettin sealed DotNetRestoreSettings ConfigureDefaultRestoreSettings(DotNetRestoreSettings buildSettings) { + var solutionParameter = this.As(); + return buildSettings - .When(this.TryAs(out var solutionParameter), x => x + .When(_ => solutionParameter != null, x => x // ReSharper disable once NullableWarningSuppressionIsUsed .SetProjectFile(solutionParameter!.Solution)); } diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ITestTarget.cs b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ITestTarget.cs index 5a49a768..6dfb6858 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ITestTarget.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/ITestTarget.cs @@ -42,7 +42,7 @@ sealed DotNetTestSettings ConfigureDefaultTestSettings(DotNetTestSettings testSe .SetNoBuild(SucceededTargets.Contains(this.As()?.Build)) .WhenNotNull(this as IConfigurationParameter, (x, configurationParameter) => x .SetConfiguration(configurationParameter.Configuration)) - .When(GenerateCodeCoverage, x => x + .When(_ => GenerateCodeCoverage, x => x .SetDataCollector("XPlat Code Coverage") .SetResultsDirectory(CoverageDirectory)); } diff --git a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/Settings/ICodeCoverageSettings.cs b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/Settings/ICodeCoverageSettings.cs index 935d17ee..0dfdcd07 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/Settings/ICodeCoverageSettings.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild.Components/Targets/Settings/ICodeCoverageSettings.cs @@ -1,6 +1,7 @@ using CreativeCoders.Core; using CreativeCoders.Core.IO; using CreativeCoders.Core.SysEnvironment; +using Nuke.Common.CI.GitHubActions; using Nuke.Common.IO; namespace CreativeCoders.NukeBuild.Components.Targets.Settings; @@ -16,5 +17,5 @@ public interface ICodeCoverageSettings : ITestSettings string Framework => $"net{Env.Version.Major}.0"; - IEnumerable Reports => new string[] { TestBaseDirectory / "coverage" / "**" / "*.xml" }; + IEnumerable Reports => [TestBaseDirectory / "coverage" / "**" / "*.xml"]; } diff --git a/source/NukeBuild/CreativeCoders.NukeBuild/BuildActions/CopyToArtifactsBuildAction.cs b/source/NukeBuild/CreativeCoders.NukeBuild/BuildActions/CopyToArtifactsBuildAction.cs index 1c1c7851..22bc8ea7 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild/BuildActions/CopyToArtifactsBuildAction.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild/BuildActions/CopyToArtifactsBuildAction.cs @@ -33,7 +33,7 @@ private void CopyFileToArtifacts(AbsolutePath fullFileName) } var targetFile = Path.Combine(BuildInfo.ArtifactsDirectory, fileName); - FileSystemTasks.CopyFile(fullFileName, targetFile, FileExistsPolicy.Overwrite); + fullFileName.Copy(targetFile, ExistsPolicy.FileOverwrite); } public void SetFileMask(string fileMask) diff --git a/source/NukeBuild/CreativeCoders.NukeBuild/BuildActions/CoverageReportAction.cs b/source/NukeBuild/CreativeCoders.NukeBuild/BuildActions/CoverageReportAction.cs index 3e23b117..3eba2518 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild/BuildActions/CoverageReportAction.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild/BuildActions/CoverageReportAction.cs @@ -1,6 +1,7 @@ using System.Diagnostics.CodeAnalysis; using CreativeCoders.Core.SysEnvironment; using JetBrains.Annotations; +using Nuke.Common.Tooling; using Nuke.Common.Tools.ReportGenerator; namespace CreativeCoders.NukeBuild.BuildActions; diff --git a/source/NukeBuild/CreativeCoders.NukeBuild/CreativeCoders.NukeBuild.csproj b/source/NukeBuild/CreativeCoders.NukeBuild/CreativeCoders.NukeBuild.csproj index 77dd006c..88dacedf 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild/CreativeCoders.NukeBuild.csproj +++ b/source/NukeBuild/CreativeCoders.NukeBuild/CreativeCoders.NukeBuild.csproj @@ -6,7 +6,7 @@ - + diff --git a/source/NukeBuild/CreativeCoders.NukeBuild/GitVersionWrapper.cs b/source/NukeBuild/CreativeCoders.NukeBuild/GitVersionWrapper.cs index 7d38ea32..9c223b8f 100644 --- a/source/NukeBuild/CreativeCoders.NukeBuild/GitVersionWrapper.cs +++ b/source/NukeBuild/CreativeCoders.NukeBuild/GitVersionWrapper.cs @@ -5,21 +5,9 @@ namespace CreativeCoders.NukeBuild; -public class GitVersionWrapper : IVersionInfo +public class GitVersionWrapper(GitVersion? gitVersion, string defaultVersion, int defaultBuildRevision) + : IVersionInfo { - private readonly GitVersion? _gitVersion; - - private readonly string _defaultVersion; - - private readonly int _defaultBuildRevision; - - public GitVersionWrapper(GitVersion? gitVersion, string defaultVersion, int defaultBuildRevision) - { - _gitVersion = gitVersion; - _defaultVersion = defaultVersion; - _defaultBuildRevision = defaultBuildRevision; - } - private static string SafeCallGitVersion(Func callGitVersion, string defaultGitVersion) { try @@ -34,21 +22,21 @@ private static string SafeCallGitVersion(Func callGitVersion, string de public string GetAssemblySemVer() => SafeCallGitVersion( - () => _gitVersion?.AssemblySemVer, - $"{_defaultVersion}.{_defaultBuildRevision}"); + () => gitVersion?.AssemblySemVer, + $"{defaultVersion}.{defaultBuildRevision}"); public string GetAssemblySemFileVer() => SafeCallGitVersion( - () => _gitVersion?.AssemblySemFileVer, - $"{_defaultVersion}.{_defaultBuildRevision}"); + () => gitVersion?.AssemblySemFileVer, + $"{defaultVersion}.{defaultBuildRevision}"); public string InformationalVersion => SafeCallGitVersion( - () => _gitVersion?.InformationalVersion, - $"{_defaultVersion}.{_defaultBuildRevision}-unknown"); + () => gitVersion?.InformationalVersion, + $"{defaultVersion}.{defaultBuildRevision}-unknown"); public string NuGetVersionV2 => SafeCallGitVersion( - () => _gitVersion?.NuGetVersionV2, - $"{_defaultVersion}-unknown"); + () => gitVersion?.NuGetVersionV2, + $"{defaultVersion}-unknown"); } diff --git a/source/Options/CreativeCoders.Options.Serializers/CreativeCoders.Options.Serializers.csproj b/source/Options/CreativeCoders.Options.Serializers/CreativeCoders.Options.Serializers.csproj index 2a38f318..0b5d848c 100644 --- a/source/Options/CreativeCoders.Options.Serializers/CreativeCoders.Options.Serializers.csproj +++ b/source/Options/CreativeCoders.Options.Serializers/CreativeCoders.Options.Serializers.csproj @@ -11,7 +11,7 @@ - + diff --git a/source/SysConsole/CreativeCoders.SysConsole.Core/CreativeCoders.SysConsole.Core.csproj b/source/SysConsole/CreativeCoders.SysConsole.Core/CreativeCoders.SysConsole.Core.csproj index 5cebceeb..4ad25c09 100644 --- a/source/SysConsole/CreativeCoders.SysConsole.Core/CreativeCoders.SysConsole.Core.csproj +++ b/source/SysConsole/CreativeCoders.SysConsole.Core/CreativeCoders.SysConsole.Core.csproj @@ -8,7 +8,7 @@ - + diff --git a/source/UnitTests/CreativeCoders.UnitTests/CreativeCoders.UnitTests.csproj b/source/UnitTests/CreativeCoders.UnitTests/CreativeCoders.UnitTests.csproj index b015f7e1..cdf3c27a 100644 --- a/source/UnitTests/CreativeCoders.UnitTests/CreativeCoders.UnitTests.csproj +++ b/source/UnitTests/CreativeCoders.UnitTests/CreativeCoders.UnitTests.csproj @@ -6,9 +6,9 @@ - + - + diff --git a/tests/CreativeCoders.AspNetCore.Blazor.UnitTests/CreativeCoders.AspNetCore.Blazor.UnitTests.csproj b/tests/CreativeCoders.AspNetCore.Blazor.UnitTests/CreativeCoders.AspNetCore.Blazor.UnitTests.csproj index 8231aaa1..8fd0de88 100644 --- a/tests/CreativeCoders.AspNetCore.Blazor.UnitTests/CreativeCoders.AspNetCore.Blazor.UnitTests.csproj +++ b/tests/CreativeCoders.AspNetCore.Blazor.UnitTests/CreativeCoders.AspNetCore.Blazor.UnitTests.csproj @@ -7,13 +7,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.AspNetCore.Tests/CreativeCoders.AspNetCore.Tests.csproj b/tests/CreativeCoders.AspNetCore.Tests/CreativeCoders.AspNetCore.Tests.csproj index 63e410e3..afced56b 100644 --- a/tests/CreativeCoders.AspNetCore.Tests/CreativeCoders.AspNetCore.Tests.csproj +++ b/tests/CreativeCoders.AspNetCore.Tests/CreativeCoders.AspNetCore.Tests.csproj @@ -8,18 +8,18 @@ - + - - - - - - + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.CodeCompilation.UnitTests/CreativeCoders.CodeCompilation.UnitTests.csproj b/tests/CreativeCoders.CodeCompilation.UnitTests/CreativeCoders.CodeCompilation.UnitTests.csproj index 715331dd..b2a56697 100644 --- a/tests/CreativeCoders.CodeCompilation.UnitTests/CreativeCoders.CodeCompilation.UnitTests.csproj +++ b/tests/CreativeCoders.CodeCompilation.UnitTests/CreativeCoders.CodeCompilation.UnitTests.csproj @@ -5,13 +5,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.CodeCompilation.UnitTests/RoslynCompilation/RoslynCompilerTests.cs b/tests/CreativeCoders.CodeCompilation.UnitTests/RoslynCompilation/RoslynCompilerTests.cs index ec5cbefb..31946383 100644 --- a/tests/CreativeCoders.CodeCompilation.UnitTests/RoslynCompilation/RoslynCompilerTests.cs +++ b/tests/CreativeCoders.CodeCompilation.UnitTests/RoslynCompilation/RoslynCompilerTests.cs @@ -26,7 +26,7 @@ public void Compile_SimpleTestScript_AddMethodReturnsCorrectValue() var compilerResult = compiler.Compile(compilationPackage, compilationOutput); - Assert.Empty(compilerResult.Messages.Where(x => x.MessageType == CompilationMessageType.Error)); + Assert.DoesNotContain(compilerResult.Messages, x => x.MessageType == CompilationMessageType.Error); var assembly = Assembly.Load(outputStream.ToArray()); diff --git a/tests/CreativeCoders.Core.UnitTests/CreativeCoders.Core.UnitTests.csproj b/tests/CreativeCoders.Core.UnitTests/CreativeCoders.Core.UnitTests.csproj index 692e7640..6d6b3cb3 100644 --- a/tests/CreativeCoders.Core.UnitTests/CreativeCoders.Core.UnitTests.csproj +++ b/tests/CreativeCoders.Core.UnitTests/CreativeCoders.Core.UnitTests.csproj @@ -6,17 +6,17 @@ - + - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.Core.UnitTests/IO/FileCleanUpTests.cs b/tests/CreativeCoders.Core.UnitTests/IO/FileCleanUpTests.cs index 46a26b42..16766afa 100644 --- a/tests/CreativeCoders.Core.UnitTests/IO/FileCleanUpTests.cs +++ b/tests/CreativeCoders.Core.UnitTests/IO/FileCleanUpTests.cs @@ -14,6 +14,7 @@ namespace CreativeCoders.Core.UnitTests.IO; public class FileCleanUpTests { [Fact] + [Obsolete("Obsolete cause underlying method from System.IO.Abstractions is marked as obsolete")] public void Dispose_FileNotExistsNoThrow_NotThrowsException() { var mockFileSystem = new MockFileSystemEx( diff --git a/tests/CreativeCoders.Core.UnitTests/Threading/SynchronizedValueTests.cs b/tests/CreativeCoders.Core.UnitTests/Threading/SynchronizedValueTests.cs index 35f9d14f..4d4dcf74 100644 --- a/tests/CreativeCoders.Core.UnitTests/Threading/SynchronizedValueTests.cs +++ b/tests/CreativeCoders.Core.UnitTests/Threading/SynchronizedValueTests.cs @@ -96,7 +96,7 @@ public void SetValue_ParallelReadValue_ValueAfterSetIsReturned() long readTimeMs = 0; // Act - var setTask = new Thread(async () => + var setTask = new Thread(() => { synchronizedValue.SetValue(_ => { diff --git a/tests/CreativeCoders.Data.NoSql.LiteDb.Tests/CreativeCoders.Data.NoSql.LiteDb.Tests.csproj b/tests/CreativeCoders.Data.NoSql.LiteDb.Tests/CreativeCoders.Data.NoSql.LiteDb.Tests.csproj index 2f4907bf..2b978745 100644 --- a/tests/CreativeCoders.Data.NoSql.LiteDb.Tests/CreativeCoders.Data.NoSql.LiteDb.Tests.csproj +++ b/tests/CreativeCoders.Data.NoSql.LiteDb.Tests/CreativeCoders.Data.NoSql.LiteDb.Tests.csproj @@ -8,18 +8,18 @@ - + - - - - - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.DependencyInjection.UnitTests/CreativeCoders.DependencyInjection.UnitTests.csproj b/tests/CreativeCoders.DependencyInjection.UnitTests/CreativeCoders.DependencyInjection.UnitTests.csproj index 789fba76..063d1547 100644 --- a/tests/CreativeCoders.DependencyInjection.UnitTests/CreativeCoders.DependencyInjection.UnitTests.csproj +++ b/tests/CreativeCoders.DependencyInjection.UnitTests/CreativeCoders.DependencyInjection.UnitTests.csproj @@ -8,15 +8,15 @@ - + - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.IO.UnitTests/CreativeCoders.IO.UnitTests.csproj b/tests/CreativeCoders.IO.UnitTests/CreativeCoders.IO.UnitTests.csproj index 2c43080f..b85f73ba 100644 --- a/tests/CreativeCoders.IO.UnitTests/CreativeCoders.IO.UnitTests.csproj +++ b/tests/CreativeCoders.IO.UnitTests/CreativeCoders.IO.UnitTests.csproj @@ -7,16 +7,16 @@ - + - + - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.Localization.UnitTests/CreativeCoders.Localization.UnitTests.csproj b/tests/CreativeCoders.Localization.UnitTests/CreativeCoders.Localization.UnitTests.csproj index cf863f09..b5421675 100644 --- a/tests/CreativeCoders.Localization.UnitTests/CreativeCoders.Localization.UnitTests.csproj +++ b/tests/CreativeCoders.Localization.UnitTests/CreativeCoders.Localization.UnitTests.csproj @@ -6,16 +6,16 @@ - + - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.Messaging.UnitTests/CreativeCoders.Messaging.UnitTests.csproj b/tests/CreativeCoders.Messaging.UnitTests/CreativeCoders.Messaging.UnitTests.csproj index 0827c898..8352ff1c 100644 --- a/tests/CreativeCoders.Messaging.UnitTests/CreativeCoders.Messaging.UnitTests.csproj +++ b/tests/CreativeCoders.Messaging.UnitTests/CreativeCoders.Messaging.UnitTests.csproj @@ -6,13 +6,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.MiscTest.UnitTests/CreativeCoders.MiscTest.UnitTests.csproj b/tests/CreativeCoders.MiscTest.UnitTests/CreativeCoders.MiscTest.UnitTests.csproj index 284ce151..d6420397 100644 --- a/tests/CreativeCoders.MiscTest.UnitTests/CreativeCoders.MiscTest.UnitTests.csproj +++ b/tests/CreativeCoders.MiscTest.UnitTests/CreativeCoders.MiscTest.UnitTests.csproj @@ -8,17 +8,17 @@ - - - - - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.MiscTest.UnitTests/NukeBuild/GitVersionWrapperTests.cs b/tests/CreativeCoders.MiscTest.UnitTests/NukeBuild/GitVersionWrapperTests.cs index 09648a8c..996adb6b 100644 --- a/tests/CreativeCoders.MiscTest.UnitTests/NukeBuild/GitVersionWrapperTests.cs +++ b/tests/CreativeCoders.MiscTest.UnitTests/NukeBuild/GitVersionWrapperTests.cs @@ -9,17 +9,14 @@ namespace CreativeCoders.MiscTest.UnitTests.NukeBuild; public class GitVersionWrapperTests { [Theory] - [InlineData("1", 1, "1.1")] - [InlineData("1.0", 1, "1.0.1")] - [InlineData("1.0.1", 1, "1.0.1.1")] + [InlineData("1", 1, 1, 1, 0, "")] + [InlineData("1.0", 1, 1, 0, 1, "")] + [InlineData("1.0.1", 1, 1, 1, 1, "1")] public void GetAssemblySemVer_GitVersionThrowsException_ReturnsDefaultVersion( - string defaultVersion, int defaultBuildRevision, string expectedVersion) + string defaultVersion, int defaultBuildRevision, int expectedMajor, + int expectedMinor, int expectedPatch, string expectedBuildMetaData) { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.AssemblySemVer) - .Throws(); + var gitVersion = CreateGitVersion(expectedMajor, expectedMinor, expectedPatch, expectedBuildMetaData); var versionWrapper = new GitVersionWrapper(gitVersion, defaultVersion, defaultBuildRevision); @@ -29,21 +26,18 @@ public void GetAssemblySemVer_GitVersionThrowsException_ReturnsDefaultVersion( // Assert actualVersion .Should() - .Be(expectedVersion); + .Be($"{expectedMajor}.{expectedMinor}.{expectedPatch}-{expectedBuildMetaData}"); } [Theory] - [InlineData("1", 1, "1.1")] - [InlineData("1.0", 1, "1.0.1")] - [InlineData("1.0.1", 1, "1.0.1.1")] + [InlineData("1", 1, 1, 1, 0, "")] + [InlineData("1.0", 1, 1, 0, 1, "")] + [InlineData("1.0.1", 1, 1, 1, 1, "1")] public void GetAssemblySemVer_GitVersionReturnsNull_ReturnsDefaultVersion( - string defaultVersion, int defaultBuildRevision, string expectedVersion) + string defaultVersion, int defaultBuildRevision, int expectedMajor, + int expectedMinor, int expectedPatch, string expectedBuildMetaData) { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.AssemblySemVer)! - .Returns(null); + var gitVersion = CreateGitVersion(expectedMajor, expectedMinor, expectedPatch, expectedBuildMetaData); var versionWrapper = new GitVersionWrapper(gitVersion, defaultVersion, defaultBuildRevision); @@ -53,19 +47,17 @@ public void GetAssemblySemVer_GitVersionReturnsNull_ReturnsDefaultVersion( // Assert actualVersion .Should() - .Be(expectedVersion); + .Be($"{expectedMajor}.{expectedMinor}.{expectedPatch}-{expectedBuildMetaData}"); } [Theory] - [InlineData("1.0")] - [InlineData("1.0.1")] - public void GetAssemblySemVer_GitVersionReturnsVersion_ReturnsVersion(string expectedVersion) + [InlineData(1, 1, 0, "")] + [InlineData(1, 0, 1, "")] + [InlineData(1, 1, 1, "1")] + public void GetAssemblySemVer_GitVersionReturnsVersion_ReturnsVersion(int expectedMajor, + int expectedMinor, int expectedPatch, string expectedBuildMetaData) { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.AssemblySemVer) - .Returns(expectedVersion); + var gitVersion = CreateGitVersion(expectedMajor, expectedMinor, expectedPatch, expectedBuildMetaData); var versionWrapper = new GitVersionWrapper(gitVersion, "2.0", 2); @@ -75,45 +67,17 @@ public void GetAssemblySemVer_GitVersionReturnsVersion_ReturnsVersion(string exp // Assert actualVersion .Should() - .Be(expectedVersion); - } - - [Theory] - [InlineData("1", 1, "1.1")] - [InlineData("1.0", 1, "1.0.1")] - [InlineData("1.0.1", 1, "1.0.1.1")] - public void GetAssemblySemFileVer_GitVersionThrowsException_ReturnsDefaultVersion( - string defaultVersion, int defaultBuildRevision, string expectedVersion) - { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.AssemblySemFileVer) - .Throws(); - - var versionWrapper = new GitVersionWrapper(gitVersion, defaultVersion, defaultBuildRevision); - - // Act - var actualVersion = versionWrapper.GetAssemblySemFileVer(); - - // Assert - actualVersion - .Should() - .Be(expectedVersion); + .Be($"{expectedMajor}.{expectedMinor}.{expectedPatch}-{expectedBuildMetaData}"); } [Theory] - [InlineData("1", 1, "1.1")] - [InlineData("1.0", 1, "1.0.1")] - [InlineData("1.0.1", 1, "1.0.1.1")] + [InlineData("1", 1)] + [InlineData("1.0", 1)] + [InlineData("1.0.1", 1)] public void GetAssemblySemFileVer_GitVersionReturnsNull_ReturnsDefaultVersion( - string defaultVersion, int defaultBuildRevision, string expectedVersion) + string defaultVersion, int defaultBuildRevision) { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.AssemblySemFileVer)! - .Returns(null); + var gitVersion = CreateGitVersionWithEmptyProps(); var versionWrapper = new GitVersionWrapper(gitVersion, defaultVersion, defaultBuildRevision); @@ -123,19 +87,16 @@ public void GetAssemblySemFileVer_GitVersionReturnsNull_ReturnsDefaultVersion( // Assert actualVersion .Should() - .Be(expectedVersion); + .Be(defaultVersion + $".{defaultBuildRevision}"); } [Theory] - [InlineData("1.0")] - [InlineData("1.0.1")] - public void GetAssemblySemFileVer_GitVersionReturnsVersion_ReturnsVersion(string expectedVersion) + [InlineData(1, 0, 0, "")] + [InlineData(1, 2, 3, "b12")] + public void GetAssemblySemFileVer_GitVersionReturnsVersion_ReturnsVersion(int expectedMajor, + int expectedMinor, int expectedPatch, string expectedBuildMetaData) { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.AssemblySemFileVer) - .Returns(expectedVersion); + var gitVersion = CreateGitVersion(expectedMajor, expectedMinor, expectedPatch, expectedBuildMetaData); var versionWrapper = new GitVersionWrapper(gitVersion, "2.0", 2); @@ -145,31 +106,7 @@ public void GetAssemblySemFileVer_GitVersionReturnsVersion_ReturnsVersion(string // Assert actualVersion .Should() - .Be(expectedVersion); - } - - [Theory] - [InlineData("1", 1, "1.1-unknown")] - [InlineData("1.0", 1, "1.0.1-unknown")] - [InlineData("1.0.1", 1, "1.0.1.1-unknown")] - public void InformationalVersion_GitVersionThrowsException_ReturnsDefaultVersion( - string defaultVersion, int defaultBuildRevision, string expectedVersion) - { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.InformationalVersion) - .Throws(); - - var versionWrapper = new GitVersionWrapper(gitVersion, defaultVersion, defaultBuildRevision); - - // Act - var actualVersion = versionWrapper.InformationalVersion; - - // Assert - actualVersion - .Should() - .Be(expectedVersion); + .Be($"{expectedMajor}.{expectedMinor}.{expectedPatch}-{expectedBuildMetaData}"); } [Theory] @@ -179,11 +116,7 @@ public void InformationalVersion_GitVersionThrowsException_ReturnsDefaultVersion public void InformationalVersion_GitVersionReturnsNull_ReturnsDefaultVersion( string defaultVersion, int defaultBuildRevision, string expectedVersion) { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.InformationalVersion)! - .Returns(null); + var gitVersion = CreateGitVersionWithEmptyProps(); var versionWrapper = new GitVersionWrapper(gitVersion, defaultVersion, defaultBuildRevision); @@ -197,15 +130,12 @@ public void InformationalVersion_GitVersionReturnsNull_ReturnsDefaultVersion( } [Theory] - [InlineData("1.0")] - [InlineData("1.0.1")] - public void InformationalVersion_GitVersionReturnsVersion_ReturnsVersion(string expectedVersion) + [InlineData(1, 0, 0, "")] + [InlineData(1, 2, 3, "b12")] + public void InformationalVersion_GitVersionReturnsVersion_ReturnsVersion(int expectedMajor, + int expectedMinor, int expectedPatch, string expectedBuildMetaData) { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.InformationalVersion) - .Returns(expectedVersion); + var gitVersion = CreateGitVersion(expectedMajor, expectedMinor, expectedPatch, expectedBuildMetaData); var versionWrapper = new GitVersionWrapper(gitVersion, "2.0", 2); @@ -215,21 +145,17 @@ public void InformationalVersion_GitVersionReturnsVersion_ReturnsVersion(string // Assert actualVersion .Should() - .Be(expectedVersion); + .Be($"{expectedMajor}.{expectedMinor}.{expectedPatch}-{expectedBuildMetaData}"); } [Theory] [InlineData("1", 1, "1-unknown")] [InlineData("1.0", 1, "1.0-unknown")] [InlineData("1.0.1", 1, "1.0.1-unknown")] - public void NuGetVersionV2_GitVersionThrowsException_ReturnsDefaultVersion( + public void NuGetVersionV2_GitVersionReturnsNull_ReturnsDefaultVersion( string defaultVersion, int defaultBuildRevision, string expectedVersion) { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.NuGetVersionV2) - .Throws(); + var gitVersion = CreateGitVersionWithEmptyProps(); var versionWrapper = new GitVersionWrapper(gitVersion, defaultVersion, defaultBuildRevision); @@ -243,19 +169,14 @@ public void NuGetVersionV2_GitVersionThrowsException_ReturnsDefaultVersion( } [Theory] - [InlineData("1", 1, "1-unknown")] - [InlineData("1.0", 1, "1.0-unknown")] - [InlineData("1.0.1", 1, "1.0.1-unknown")] - public void NuGetVersionV2_GitVersionReturnsNull_ReturnsDefaultVersion( - string defaultVersion, int defaultBuildRevision, string expectedVersion) + [InlineData(1, 0, 0, "")] + [InlineData(1, 2, 3, "b12")] + public void NuGetVersionV2_GitVersionReturnsVersion_ReturnsVersion(int expectedMajor, + int expectedMinor, int expectedPatch, string expectedBuildMetaData) { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.NuGetVersionV2)! - .Returns(null); + var gitVersion = CreateGitVersion(expectedMajor, expectedMinor, expectedPatch, expectedBuildMetaData); - var versionWrapper = new GitVersionWrapper(gitVersion, defaultVersion, defaultBuildRevision); + var versionWrapper = new GitVersionWrapper(gitVersion, "2.0", 2); // Act var actualVersion = versionWrapper.NuGetVersionV2; @@ -263,28 +184,87 @@ public void NuGetVersionV2_GitVersionReturnsNull_ReturnsDefaultVersion( // Assert actualVersion .Should() - .Be(expectedVersion); + .Be($"{expectedMajor}.{expectedMinor}.{expectedPatch}"); } - [Theory] - [InlineData("1.0")] - [InlineData("1.0.1")] - public void NuGetVersionV2_GitVersionReturnsVersion_ReturnsVersion(string expectedVersion) + private GitVersion CreateGitVersionWithEmptyProps() { - var gitVersion = A.Fake(); - - A - .CallTo(() => gitVersion.NuGetVersionV2) - .Returns(expectedVersion); - - var versionWrapper = new GitVersionWrapper(gitVersion, "2.0", 2); - - // Act - var actualVersion = versionWrapper.NuGetVersionV2; + return new GitVersion( + BranchName: "main", + Sha: "dummySha", + ShortSha: "dummy", + Major: 0, + Minor: 0, + Patch: 0, + PreReleaseTag: string.Empty, + PreReleaseTagWithDash: string.Empty, + PreReleaseLabel: string.Empty, + PreReleaseLabelWithDash: string.Empty, + PreReleaseNumber: null, + WeightedPreReleaseNumber: null, + BuildMetaData: null, + BuildMetaDataPadded: string.Empty, + FullBuildMetaData: string.Empty, + MajorMinorPatch: null, + SemVer: null, + LegacySemVer: null, + LegacySemVerPadded: null, + AssemblySemVer: null, + AssemblySemFileVer: null, + FullSemVer: null, + InformationalVersion: null, + EscapedBranchName: "main", + CommitDate: DateTimeOffset.Now.ToString(), + CommitsSinceVersionSource: "0", + CommitsSinceVersionSourcePadded: "0000", + UncommittedChanges: 0, + VersionSourceSha: "dummySourceSha", + NuGetVersionV2: null, + NuGetVersion: null, + NuGetPreReleaseTagV2: string.Empty, + NuGetPreReleaseTag: string.Empty + ); + } - // Assert - actualVersion - .Should() - .Be(expectedVersion); + private GitVersion CreateGitVersion(int major, int minor, int patch, string buildMetaData) + { + var shortVersion = $"{major}.{minor}.{patch}"; + var fullVersion = $"{major}.{minor}.{patch}-{buildMetaData}"; + + return new GitVersion( + BranchName: "main", + Sha: "dummySha", + ShortSha: "dummy", + Major: major, + Minor: minor, + Patch: patch, + PreReleaseTag: string.Empty, + PreReleaseTagWithDash: string.Empty, + PreReleaseLabel: string.Empty, + PreReleaseLabelWithDash: string.Empty, + PreReleaseNumber: null, + WeightedPreReleaseNumber: null, + BuildMetaData: buildMetaData, + BuildMetaDataPadded: string.Empty, + FullBuildMetaData: string.Empty, + MajorMinorPatch: shortVersion, + SemVer: shortVersion, + LegacySemVer: shortVersion, + LegacySemVerPadded: shortVersion, + AssemblySemVer: fullVersion, + AssemblySemFileVer: fullVersion, + FullSemVer: shortVersion, + InformationalVersion: fullVersion, + EscapedBranchName: "main", + CommitDate: DateTimeOffset.Now.ToString(), + CommitsSinceVersionSource: "0", + CommitsSinceVersionSourcePadded: "0000", + UncommittedChanges: 0, + VersionSourceSha: "dummySourceSha", + NuGetVersionV2: shortVersion, + NuGetVersion: shortVersion, + NuGetPreReleaseTagV2: string.Empty, + NuGetPreReleaseTag: string.Empty + ); } } diff --git a/tests/CreativeCoders.Net.UnitTests/CreativeCoders.Net.UnitTests.csproj b/tests/CreativeCoders.Net.UnitTests/CreativeCoders.Net.UnitTests.csproj index d5920f36..7d2af811 100644 --- a/tests/CreativeCoders.Net.UnitTests/CreativeCoders.Net.UnitTests.csproj +++ b/tests/CreativeCoders.Net.UnitTests/CreativeCoders.Net.UnitTests.csproj @@ -6,14 +6,14 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.NukeBuild.Tests/CreativeCoders.NukeBuild.Tests.csproj b/tests/CreativeCoders.NukeBuild.Tests/CreativeCoders.NukeBuild.Tests.csproj index 1886246f..65c417e4 100644 --- a/tests/CreativeCoders.NukeBuild.Tests/CreativeCoders.NukeBuild.Tests.csproj +++ b/tests/CreativeCoders.NukeBuild.Tests/CreativeCoders.NukeBuild.Tests.csproj @@ -10,19 +10,19 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/CreativeCoders.NukeBuild.Tests/NukeBuildExtensionsTests.cs b/tests/CreativeCoders.NukeBuild.Tests/NukeBuildExtensionsTests.cs index 4bf0f16e..f11f0653 100644 --- a/tests/CreativeCoders.NukeBuild.Tests/NukeBuildExtensionsTests.cs +++ b/tests/CreativeCoders.NukeBuild.Tests/NukeBuildExtensionsTests.cs @@ -14,7 +14,41 @@ public class NukeBuildExtensionsTests public void GetGitVersion_Always_ReturnsVersionFromGitVersionParameter() { // Arrange - var expectedGitVersion = new GitVersion(); + var expectedGitVersion = new GitVersion( + BranchName: "main", + Sha: "dummySha", + ShortSha: "dummy", + Major: 1, + Minor: 0, + Patch: 0, + PreReleaseTag: string.Empty, + PreReleaseTagWithDash: string.Empty, + PreReleaseLabel: string.Empty, + PreReleaseLabelWithDash: string.Empty, + PreReleaseNumber: null, + WeightedPreReleaseNumber: null, + BuildMetaData: string.Empty, + BuildMetaDataPadded: string.Empty, + FullBuildMetaData: string.Empty, + MajorMinorPatch: "1.0.0", + SemVer: "1.0.0", + LegacySemVer: "1.0.0", + LegacySemVerPadded: "1.0.0", + AssemblySemVer: "1.0.0.0", + AssemblySemFileVer: "1.0.0.0", + FullSemVer: "1.0.0", + InformationalVersion: "1.0.0+dummySha", + EscapedBranchName: "main", + CommitDate: DateTimeOffset.Now.ToString(), + CommitsSinceVersionSource: "0", + CommitsSinceVersionSourcePadded: "0000", + UncommittedChanges: 0, + VersionSourceSha: "dummySourceSha", + NuGetVersionV2: "1.0.0", + NuGetVersion: "1.0.0", + NuGetPreReleaseTagV2: string.Empty, + NuGetPreReleaseTag: string.Empty + ); var fakeBuild = new MockBuildWithGitVersionParameter(expectedGitVersion); // Act diff --git a/tests/CreativeCoders.Reactive.UnitTests/CreativeCoders.Reactive.UnitTests.csproj b/tests/CreativeCoders.Reactive.UnitTests/CreativeCoders.Reactive.UnitTests.csproj index 41a9cdf9..e1846b81 100644 --- a/tests/CreativeCoders.Reactive.UnitTests/CreativeCoders.Reactive.UnitTests.csproj +++ b/tests/CreativeCoders.Reactive.UnitTests/CreativeCoders.Reactive.UnitTests.csproj @@ -6,13 +6,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.Scripting.UnitTests/CreativeCoders.Scripting.UnitTests.csproj b/tests/CreativeCoders.Scripting.UnitTests/CreativeCoders.Scripting.UnitTests.csproj index c50c8e2b..ba2dd50f 100644 --- a/tests/CreativeCoders.Scripting.UnitTests/CreativeCoders.Scripting.UnitTests.csproj +++ b/tests/CreativeCoders.Scripting.UnitTests/CreativeCoders.Scripting.UnitTests.csproj @@ -6,13 +6,13 @@ - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.SysConsole.App.UnitTests/CreativeCoders.SysConsole.App.UnitTests.csproj b/tests/CreativeCoders.SysConsole.App.UnitTests/CreativeCoders.SysConsole.App.UnitTests.csproj index 59232f1e..f9606bc5 100644 --- a/tests/CreativeCoders.SysConsole.App.UnitTests/CreativeCoders.SysConsole.App.UnitTests.csproj +++ b/tests/CreativeCoders.SysConsole.App.UnitTests/CreativeCoders.SysConsole.App.UnitTests.csproj @@ -7,14 +7,14 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.SysConsole.Cli.Actions.UnitTests/CreativeCoders.SysConsole.Cli.Actions.UnitTests.csproj b/tests/CreativeCoders.SysConsole.Cli.Actions.UnitTests/CreativeCoders.SysConsole.Cli.Actions.UnitTests.csproj index 354c02d7..f0fcd6a7 100644 --- a/tests/CreativeCoders.SysConsole.Cli.Actions.UnitTests/CreativeCoders.SysConsole.Cli.Actions.UnitTests.csproj +++ b/tests/CreativeCoders.SysConsole.Cli.Actions.UnitTests/CreativeCoders.SysConsole.Cli.Actions.UnitTests.csproj @@ -11,17 +11,17 @@ - - - - - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests.csproj b/tests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests.csproj index b97c7994..52f2afc0 100644 --- a/tests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests.csproj +++ b/tests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests/CreativeCoders.SysConsole.Cli.Parsing.UnitTests.csproj @@ -7,15 +7,15 @@ - + - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.SysConsole.CliArguments.UnitTests/CreativeCoders.SysConsole.CliArguments.UnitTests.csproj b/tests/CreativeCoders.SysConsole.CliArguments.UnitTests/CreativeCoders.SysConsole.CliArguments.UnitTests.csproj index 9f87fb6f..b1531dce 100644 --- a/tests/CreativeCoders.SysConsole.CliArguments.UnitTests/CreativeCoders.SysConsole.CliArguments.UnitTests.csproj +++ b/tests/CreativeCoders.SysConsole.CliArguments.UnitTests/CreativeCoders.SysConsole.CliArguments.UnitTests.csproj @@ -7,15 +7,15 @@ - + - - - + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/tests/CreativeCoders.SysConsole.UnitTests/CreativeCoders.SysConsole.UnitTests.csproj b/tests/CreativeCoders.SysConsole.UnitTests/CreativeCoders.SysConsole.UnitTests.csproj index 4576955f..75072694 100644 --- a/tests/CreativeCoders.SysConsole.UnitTests/CreativeCoders.SysConsole.UnitTests.csproj +++ b/tests/CreativeCoders.SysConsole.UnitTests/CreativeCoders.SysConsole.UnitTests.csproj @@ -8,14 +8,14 @@ - - - - + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all