From 6c957b86e9bb604656f111edc357ebd5700f929f Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Sun, 9 Jul 2023 11:14:46 +0200 Subject: [PATCH 1/3] feat: Add target sdk for template --- CHANGELOG.md | 6 ++++- .../.template.config/dotnetcli.host.json | 10 +++++--- .../template/.template.config/template.json | 25 +++++++++++++++++++ .../template/Company.BlazorTests1.csproj | 18 ++++++------- 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d2abb6f60..4f5bc6e27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,11 @@ All notable changes to **bUnit** will be documented in this file. The project ad ## [Unreleased] -## Changed +### Added + +- Update bunit templates to support the target framework version of the project. By [@linkdotnet](https://github.com/linkdotnet). + +### Changed - Change all bUnit services registration from singleton to scoped. By [@egil](https://github.com/egil). Closes https://github.com/bUnit-dev/bUnit/issues/1138. diff --git a/src/bunit.template/template/.template.config/dotnetcli.host.json b/src/bunit.template/template/.template.config/dotnetcli.host.json index d78ed2e98..d66f5d4ef 100644 --- a/src/bunit.template/template/.template.config/dotnetcli.host.json +++ b/src/bunit.template/template/.template.config/dotnetcli.host.json @@ -7,11 +7,15 @@ "UnitTestFramework": { "longName": "framework", "shortName": "" + }, + "TargetSdk": { + "longName": "sdk", + "shortName": "" } }, "usageExamples": [ - "--framework xunit", - "--framework nunit", - "--framework mstest" + "--framework xunit --sdk net6.0", + "--framework nunit --sdk net6.0", + "--framework mstest --sdk net6.0" ] } diff --git a/src/bunit.template/template/.template.config/template.json b/src/bunit.template/template/.template.config/template.json index 47766b885..ad70fbf48 100644 --- a/src/bunit.template/template/.template.config/template.json +++ b/src/bunit.template/template/.template.config/template.json @@ -76,6 +76,31 @@ "testFramework_mstest": { "type": "computed", "value": "UnitTestFramework == \"mstest\"" + }, + "targetSdk": { + "type": "parameter", + "description": "The target framework sdk for the project.", + "displayName": "Target framework sdk", + "datatype": "choice", + "defaultValue": "net6.0", + "replaces": "targetSdk", + "choices": [ + { + "choice": "net6.0", + "description": ".net 6.0", + "displayName": ".net 6.0" + }, + { + "choice": "net7.0", + "description": ".net 7.0", + "displayName": ".net 7.0" + }, + { + "choice": "net8.0", + "description": ".net 8.0", + "displayName": ".net 8.0" + } + ] } }, "primaryOutputs": [ diff --git a/src/bunit.template/template/Company.BlazorTests1.csproj b/src/bunit.template/template/Company.BlazorTests1.csproj index 2fb52dda9..143b9c82e 100644 --- a/src/bunit.template/template/Company.BlazorTests1.csproj +++ b/src/bunit.template/template/Company.BlazorTests1.csproj @@ -1,7 +1,7 @@ - net6.0 + targetSdk enable false @@ -17,29 +17,29 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all - - + + - - + + From 604dd811c23c2f0bfd98e1d6b6a9993d470ae101 Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Sun, 9 Jul 2023 16:26:26 +0200 Subject: [PATCH 2/3] made net7.0 current default --- src/bunit.template/template/.template.config/template.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bunit.template/template/.template.config/template.json b/src/bunit.template/template/.template.config/template.json index ad70fbf48..f926c5c55 100644 --- a/src/bunit.template/template/.template.config/template.json +++ b/src/bunit.template/template/.template.config/template.json @@ -82,7 +82,7 @@ "description": "The target framework sdk for the project.", "displayName": "Target framework sdk", "datatype": "choice", - "defaultValue": "net6.0", + "defaultValue": "net7.0", "replaces": "targetSdk", "choices": [ { From 2fe2782e8f7e829824cf30fd9844b5c06a197442 Mon Sep 17 00:00:00 2001 From: Steven Giesel Date: Sun, 9 Jul 2023 16:28:40 +0200 Subject: [PATCH 3/3] Update examples as well --- .../template/.template.config/dotnetcli.host.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/bunit.template/template/.template.config/dotnetcli.host.json b/src/bunit.template/template/.template.config/dotnetcli.host.json index d66f5d4ef..25f3a28b9 100644 --- a/src/bunit.template/template/.template.config/dotnetcli.host.json +++ b/src/bunit.template/template/.template.config/dotnetcli.host.json @@ -14,8 +14,8 @@ } }, "usageExamples": [ - "--framework xunit --sdk net6.0", - "--framework nunit --sdk net6.0", - "--framework mstest --sdk net6.0" + "--framework xunit --sdk net7.0", + "--framework nunit --sdk net7.0", + "--framework mstest --sdk net7.0" ] }