1

I have built a template project with a Template.json and this will generate the template fine ( no errors at all )

ive also managed to add some choices to the symbols that will add or hide code snippets as needed

what im now trying to achieve is removing classes and interfaces based on those same choices

I have added a sources block with the exclude and the condition but it appears to be simply ignored when i generate the project.

the files are in the project created in infrastructure/mongo

but i have also tried with the following

**/MongoRepository.cs

ive included the sources block below as it appears to be the issue as far as i can see ( the rest of the file works fine )

    "sources": [
     {
      "modifiers": [
        {
          "condition": "(!Mongo)",
          "exclude": [
            "**/Infrastructure/Mongo/**"
          ]
        }
      ]
    },
    {
      "exclude": [
        ".template.config/**"
      ]
    }
  ]

UPDATE after testing i have found it appears that maybe its the condition here thats causing the issue if i move the files to the exclude below it will work no matter what. but any condition that is placed in that field will not complete (i have set this field to (1==1) with the same failure)

3
  • 1
    Can you please share a full minimal reproducible example (for example @github) for lazy person like me? Commented Nov 21 at 12:11
  • 1
    ill start removing data to get a clean version i can post in the meantime .. its literally any nested files in a a project for example ./infrastructure/mongorepo.cs Commented Nov 21 at 13:20
  • 1
    @GuruStron github.com/Bithellio/Worker.Template this is a stripped down version Commented Nov 21 at 13:35

1 Answer 1

0

Not sure why exactly but seems the problem is that you are using different JSON objects for the sources modification. The following worked for me:

"sources": [
  {
    "exclude": [
      ".template.config/**/*",
      "tmp/**/*" // my temp folder to play with the template
    ],
    "modifiers": [
      {
        "condition": "(!Mongo)",
        "exclude": [
          "**/Infrastructure/Mongo/**"
        ]
      }
    ]
  }  
]

Source template folder:

enter image description here

Command used:

dotnet new DNA-Worker -n TESTSEST --mongoAddition None

Result:

enter image description here

P.S.

I would argue you are a bit overcomplicating your variables - I would use just boolean ones for the xxxAddition:

"mongoAddition": {
  "type": "parameter",
  "datatype": "bool",
  "defaultValue": "true"
},

Also probably I would rename them into includeXXX. But this is a matter of taste.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.