Description
Product
dotnet CLI (dotnet new)
Describe The Bug
when I use 'isEnabled' in a generated symbol it does not seem to evaluate and always processes.
example:
Foo.cs
public class Foo
{
public readonly int FooId { get; init; }
}
template.json
{
"name": "Tests",
"identity": "Tests",
"shortName": "tests",
"symbols": {
"ChangeFoo": {
"type": "parameter",
"dataType": "bool",
"isRequired": true
},
"IdentifierName": {
"type": "generated",
"generator": "constant",
"parameters": {
"value": "Bar"
},
"isEnabled": "ChangeFoo",
"replaces": "Foo",
"fileRename": "Foo"
}
}
}
When executing dotnet new tests --ChangeFoo false
, I expect it to generate 'Foo.cs' as is.
Instead, it generates 'Bar.cs' with all Foo replaced to 'Bar', which I expect to happen when I execute dotnet new tests --ChangeFoo true
instead.
It seems to correctly evaluate if I change 'IdentifierName' to 'parameter' without changing the 'isEnabled' condition
"IdentifierName": {
"type": "parameter",
"dataType": "string",
"isEnabled": "ChangeFoo",
"replaces": "Foo",
"fileRename": "Foo"
}
Calling `dotnet new tests --ChangeFoo false --IdentifierName Bar' will not replace 'Foo' as expected
To Reproduce
Steps:
-
create (and install) basic template setup with .template.config\template.json and Foo.cs as described
.
├── .template.config
│ └── template.json
└── Foo.cs -
run
dotnet new tests --ChangeFoo false
-
check generated file
dotnet Info
output
.NET SDK: Version: 8.0.401 Commit: 811edcc344 Workload version: 8.0.400-manifests.b6724b7a MSBuild version: 17.11.4+37eb419adRuntime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.401\
.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.
Host:
Version: 8.0.8
Architecture: x64
Commit: 08338fcaa5
.NET SDKs installed:
8.0.304 [C:\Program Files\dotnet\sdk]
8.0.401 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Visual Studio Version
No response
Additional context
No response