From 93c23d71b9577a355a4c7f0c8fa8c3ec2c3cfe77 Mon Sep 17 00:00:00 2001 From: Amadeusz Sadowski Date: Thu, 4 Jan 2024 12:18:04 +0100 Subject: [PATCH] refactor: split into common and csharp-specific --- .github/workflows/template.yml | 1 + .gitignore | 1 + Directory.Build.props | 5 +-- README.md | 15 ++++--- global.json | 5 +-- nuget.config | 6 +-- ... Allegro.NET.Sdk.CSharp.Analyzers.targets} | 0 .../Sdk/Allegro.NET.Sdk.CSharp.props | 27 +++++++++++ .../Sdk/Allegro.NET.Sdk.CSharp.targets | 30 +++++++++++++ .../Sdk/Allegro.NET.Sdk.Common.props | 25 +++++++++++ .../Sdk/Allegro.NET.Sdk.Common.targets | 29 ++++++++++++ .../Sdk/Allegro.NET.Sdk.props | 6 +++ .../Sdk/Allegro.NET.Sdk.targets | 6 +++ src/Allegro.DotnetSdk/Sdk/Sdk.props | 4 +- .../Sdk/UseAllegroDotnetSdkDefaults.props | 41 ----------------- .../Sdk/UseAllegroDotnetSdkDefaults.targets | 45 ------------------- 16 files changed, 143 insertions(+), 103 deletions(-) rename src/Allegro.DotnetSdk/Sdk/{UseDefaultAnalyzers.targets => Allegro.NET.Sdk.CSharp.Analyzers.targets} (100%) create mode 100644 src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.props create mode 100644 src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.targets create mode 100644 src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.Common.props create mode 100644 src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.Common.targets create mode 100644 src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.props create mode 100644 src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.targets delete mode 100644 src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.props delete mode 100644 src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.targets diff --git a/.github/workflows/template.yml b/.github/workflows/template.yml index 0fd020a..7ffc8ad 100644 --- a/.github/workflows/template.yml +++ b/.github/workflows/template.yml @@ -33,6 +33,7 @@ jobs: with: dotnet-version: | 6.0.x + 8.0.x - name: Restore dependencies run: dotnet restore - name: Build diff --git a/.gitignore b/.gitignore index 05b81fb..ea39a34 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ .idea/ .ionide/ App_Data/ +artifacts/ packages/ package/ obj/ diff --git a/Directory.Build.props b/Directory.Build.props index f927eb1..5154eb3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -9,6 +9,7 @@ LICENSE README.md true + true @@ -18,8 +19,4 @@ - - - - \ No newline at end of file diff --git a/README.md b/README.md index 059a960..1bb0148 100644 --- a/README.md +++ b/README.md @@ -52,16 +52,21 @@ The `Directory.Build.props` file should be updated in order to actually import t Most properties are only set in the SDK if not configured by the project. -To configure the SDK, the following properties can be added into `Directory.Build.props` or `.csproj` files: +To configure the SDK, the following properties can be added into `Directory.Build.props` or `.*proj` files: - `AllegroDotnetSdkEnableXmlDocAdjustments` (default: true) - enable doc file generation, suppress missing-comments warning (1591) - completely in test projects, as errors otherwise (keep as warning). -- `TreatWarningsAsErrors` (default: true in CI and Rider IDE) -- `UseAllegroDotnetSdkDefaultAnalyzers` (default: true when no CPM) - reference and configure several external analyzers - StyleCop, AsyncFixer, Meziantou. +- `TreatWarningsAsErrors` (default: true in CI and Rider IDE). - `AllegroDotnetSdkEnableGlobalEditorConfig` (default: true) - add `editorconfig.global` analyzer configuration file. -- `AllegroDotnetSdkEnableImplicitUsingsAdjustments` (default: true) - add `System.Collections.Immutable` and remove `Microsoft.Extensions.Logging` and `System.Net.Http` implicit usings. +- `AllegroDotnetSdkEnablePackAdjustments` (default: true) - sets PublishRepositoryUrl and enables `.snupkg` symbols. +- `AllegroDotnetSdkEnableAzureArtifactsAdjustments` (default: false) - disables `.snupkg` and instead embeds PDBs in `.nupkg`. + +For `C#` only: + +- `AllegroDotnetSdkEnableImplicitUsingsAdjustments` (default: true for C#) - add `System.Collections.Immutable` and remove `Microsoft.Extensions.Logging` and `System.Net.Http` implicit usings. +- `UseAllegroDotnetSdkDefaultAnalyzers` (default: true for C# when no CPM) - reference and configure several external analyzers - StyleCop, AsyncFixer, Meziantou. - `AllegroDotnetSdkEnableAsyncFixer` (default: `UseAllegroDotnetSdkDefaultAnalyzers`) - references AsyncFixer package. - `AllegroDotnetSdkEnableMeziantou` (default: `UseAllegroDotnetSdkDefaultAnalyzers`) - references Meziantou.Analyzers package. -- `AllegroDotnetSdkEnableStyleCop` (default: `UseAllegroDotnetSdkDefaultAnalyzers`) - references StyleCop.Analyzers package. +- `AllegroDotnetSdkEnableStyleCop` (default: `UseAllegroDotnetSdkDefaultAnalyzers`) - references StyleCop.Analyzers package and a preset `stylecop.json`. Configure in `Directory.Build.props` - repo wide: diff --git a/global.json b/global.json index f3b3a4e..e589342 100644 --- a/global.json +++ b/global.json @@ -1,10 +1,9 @@ { "sdk": { - "version": "6.0.400", + "version": "8.0.100", "rollForward": "latestFeature" }, "msbuild-sdks": { - "Microsoft.Build.CentralPackageVersions": "2.1.3", - "Microsoft.Build.NoTargets": "3.5.6" + "Microsoft.Build.NoTargets": "3.7.56" } } \ No newline at end of file diff --git a/nuget.config b/nuget.config index 7d7e3a9..2c70539 100644 --- a/nuget.config +++ b/nuget.config @@ -1,6 +1,6 @@ - - - + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/UseDefaultAnalyzers.targets b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.Analyzers.targets similarity index 100% rename from src/Allegro.DotnetSdk/Sdk/UseDefaultAnalyzers.targets rename to src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.Analyzers.targets diff --git a/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.props b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.props new file mode 100644 index 0000000..88a8f4c --- /dev/null +++ b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.props @@ -0,0 +1,27 @@ + + + + + true + enable + enable + latest-Recommended + true + + + + + + + $(WarningsNotAsErrors);CS1591 + + + + + + $(NoWarn);CA1707 + + $(NoWarn);CS1591 + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.targets b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.targets new file mode 100644 index 0000000..532e624 --- /dev/null +++ b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.CSharp.targets @@ -0,0 +1,30 @@ + + + + + + true + + + + true + true + true + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.Common.props b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.Common.props new file mode 100644 index 0000000..02a99a9 --- /dev/null +++ b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.Common.props @@ -0,0 +1,25 @@ + + + + + + true + + + + + + true + + true + + true + + + + + + true + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.Common.targets b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.Common.targets new file mode 100644 index 0000000..8bea166 --- /dev/null +++ b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.Common.targets @@ -0,0 +1,29 @@ + + + + + true + true + false + + + + + true + true + snupkg + + + + + + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + + false + + + + + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.props b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.props new file mode 100644 index 0000000..c33fa26 --- /dev/null +++ b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.props @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.targets b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.targets new file mode 100644 index 0000000..1131e9c --- /dev/null +++ b/src/Allegro.DotnetSdk/Sdk/Allegro.NET.Sdk.targets @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/Sdk.props b/src/Allegro.DotnetSdk/Sdk/Sdk.props index 73d08d2..df26c55 100644 --- a/src/Allegro.DotnetSdk/Sdk/Sdk.props +++ b/src/Allegro.DotnetSdk/Sdk/Sdk.props @@ -9,11 +9,11 @@ - $(CustomAfterDirectoryBuildProps);$(MSBuildThisFileDirectory)UseAllegroDotnetSdkDefaults.props + $(CustomAfterDirectoryBuildProps);$(MSBuildThisFileDirectory)Allegro.NET.Sdk.props - $(CustomBeforeDirectoryBuildTargets);$(MSBuildThisFileDirectory)UseAllegroDotnetSdkDefaults.targets + $(CustomBeforeDirectoryBuildTargets);$(MSBuildThisFileDirectory)Allegro.NET.Sdk.targets - - true - - - - latest - enable - enable - - - - latest-Recommended - true - - true - - true - - true - - - - - true - - - $(WarningsNotAsErrors);CS1591 - - - - - - $(NoWarn);CA1707 - - $(NoWarn);CS1591 - - - \ No newline at end of file diff --git a/src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.targets b/src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.targets deleted file mode 100644 index 9a763f6..0000000 --- a/src/Allegro.DotnetSdk/Sdk/UseAllegroDotnetSdkDefaults.targets +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - true - true - true - - - - true - true - true - - - - true - - true - - - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - true - snupkg - - - - - - - - - - - - - - - - - - - \ No newline at end of file