Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifiers "include" is not working as expected in dotnet 8 #8003

Open
y-karnitskaya opened this issue May 20, 2024 · 0 comments
Open

Modifiers "include" is not working as expected in dotnet 8 #8003

y-karnitskaya opened this issue May 20, 2024 · 0 comments

Comments

@y-karnitskaya
Copy link

Product

dotnet CLI (dotnet new)

Describe The Bug

Given the template sources configuration for a custom template below:

....
"sources": [
    {
      "include": [],
      "modifiers": [
        {
          "condition": "(!someBoolParam)",
          "include": [
            "**/*"
          ],
          "exclude": [
            ".fake/**",
            ".paket/**",
            "paket-files/**",
            "..."
          ]
        },
        {
          "condition": "(someBoolParam)",
          "include": [
            "src/Folder/SubFolder/**/*"
          ],
          "exclude": ["Dockerfile"]
        }
      ]
    }
  ]
....

And Given the fact that the directory was already initiated from the template (someBoolParam == false)
When the dotnet new is executed in the existing directory where someBoolParam == true,
Then the "include" condition (i.e. "src/Folder/SubFolder/**/*") is ignored and all files in the directory are getting updated except for the excluded file (i.e. "Dockerfile"). Note: "exclude" was added to the example below just to show that "exclude" is working, but "include" is not. If "exclude" is removed, the "include" still does not work.

An example of the warning message displayed in the console:

Creating this template will make changes to existing files:
  Overwrite   ./.dockerignore
  Overwrite   ./.editorconfig
  Overwrite   ./.gitattributes
  Overwrite   ./.gitignore
  .............................................
  To create the template anyway, run the command with '--force' option:
  ............................................

Such template config worked as expected when using .NET 6 SDK, but after the update to .NET 8, the issue described above is started to appear.

To Reproduce

Steps:

  1. Configure the template using sources from the description
  2. Install template
  3. Create a service from a template with someBoolParam set to false
  4. Create a service from the template again with someBoolParam set to true

dotnet Info

output .NET SDK: Version: 8.0.204 Commit: c338c7548c Workload version: 8.0.200-manifests.7d36c14f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.204\

.NET workloads installed:
There are no installed workloads to display.

Host:
Version: 8.0.4
Architecture: x64
Commit: 2d7eea2529

.NET SDKs installed:
6.0.422 [C:\Program Files\dotnet\sdk]
8.0.204 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.4 [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:
C:\Users**\global.json

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Visual Studio Version

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant