Skip to content

Commit

Permalink
Fix targetFramework selection (Fix #15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Socolin committed Jul 26, 2024
1 parent 319a76f commit 8dd97c5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 134 deletions.
49 changes: 19 additions & 30 deletions projectTemplates/ReqnrollProject/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,38 @@
},
"sourceName": "Template",
"symbols": {
"targetFramework": {
"Framework": {
"type": "parameter",
"description": "Target Framework",
"datatype": "choice",
"defaultValue": "net6.0",
"defaultValue": "net8.0",
"replaces": "$target$",
"allowMultipleValues": false,
"isRequired": true,
"choices": [
{
"choice": "net8.0",
"description": "net8.0"
},
"displayName": "net8.0"
},
{
"choice": "net7.0",
"description": "net7.0"
},
"displayName": "net7.0"
},
{
"choice": "net6.0",
"description": "net6.0"
},
"displayName": "net6.0"
},
{
"choice": "net481",
"description": ".Net Framework v4.8.1"
"displayName": ".Net Framework v4.8.1"
},
{
"choice": "net48",
"description": ".Net Framework v4.8"
"displayName": ".Net Framework v4.8"
},
{
"choice": "net472",
"description": ".Net Framework v4.7.2"
"displayName": ".Net Framework v4.7.2"
},
{
"choice": "net471",
Expand All @@ -61,18 +63,20 @@
"description": "Provider for Unit Tests",
"datatype": "choice",
"defaultValue": "nunit",
"allowMultipleValues": false,
"isRequired": true,
"choices": [
{
"choice": "nunit",
"description": "NUnit"
"displayName": "NUnit"
},
{
"choice": "xunit",
"description": "xUnit"
},
"displayName": "xUnit"
},
{
"choice": "mstest",
"description": "MSTest"
"displayName": "MSTest"
}
]
},
Expand All @@ -82,21 +86,6 @@
"description": "Add FluentAssertions library",
"defaultValue": "true"
},
"LangVersion": {
"type": "generated",
"generator": "switch",
"replaces": "$langVersion$",
"parameters": {
"evaluator": "C++",
"datatype": "string",
"cases": [
{
"condition": "(targetFramework != 'net6.0')",
"value": "\r\n<LangVersion>10</LangVersion>"
}
]
}
},
"ReqnrollNugetPackages": {
"type": "generated",
"generator": "switch",
Expand Down
2 changes: 1 addition & 1 deletion projectTemplates/ReqnrollProject/Template.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>$target$</TargetFramework>$langVersion$
<TargetFramework>$target$</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ public class ReqnrollSettingsProvider
/// <returns>true if it changes the current project config</returns>
public bool TryUpdate(IProject project, ConfigSource source, ReqnrollSettings? settings)
{
var lifetime = project.GetSolution().GetSolutionLifetimes().UntilSolutionCloseLifetime;
var solution = project.GetSolution();
// GetSolution() return null when the project is deleted
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
if (solution is null)
return false;
var lifetime = solution.GetSolutionLifetimes().UntilSolutionCloseLifetime;

RegisterProjectLifetime(project, lifetime);

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 8dd97c5

Please sign in to comment.