Skip to content

Placing files at solution level for project template #8873

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

Open
NotNite opened this issue Apr 2, 2025 · 0 comments
Open

Placing files at solution level for project template #8873

NotNite opened this issue Apr 2, 2025 · 0 comments

Comments

@NotNite
Copy link

NotNite commented Apr 2, 2025

Is your feature request related to a problem? Please describe.

Hi! My template is a single C# project, but I also want to create an .editorconfig and LICENSE file for new solutions. I've avoided making my template a solution template because I want users to be able to create a new project in an existing solution, which from my understanding isn't possible with solution templates (correct me if I'm wrong).

Right now, I'm solving this by using .. with rename:

{
  "rename": {
    ".gitignore": "../.gitignore",
    "LICENSE": "../LICENSE"
  }
}

I'm doing this so that my template can be instantly ready to be committed to a Git repository, while also still being available to add to an existing solution. This has a few problems, though:

  • This overwrites existing files when creating a new project in an existing solution (create a solution + project, add a .gitignore, create the template project in that solution).
  • Even if those files don't already exist, it's not a great experience to add a project to an existing solution and have it create solution-wide files. I'd ideally have it only try and copy the files when creating a new solution+project in one go.
  • When the project and solution are both in the same root folder (checking "Place solution and project in the same directory"), the files get created outside of the project folder! This also occurs when using the dotnet CLI.

Right now, I just have a symbol that the user can toggle off when creating a new project, but ideally I'd automatically detect the right conditions to create these files (creating a new solution+project and project is in a subdirectory). So far, I've tried:

  • Using context:createsolutiondirectory and context:isexclusive as seen in the wiki (doesn't work on the dotnet CLI or JetBrains Rider)
  • Setting preferNameDirectory to true (doesn't seem to do anything?)
  • Setting editorTreatAs to solution (also doesn't seem to do anything?)

Describe the solution you'd like.

Either being able to detect when a new solution is being made (or a project is being made without a solution) in a condition, or being able to rename files into a solution directory (if it exists).

Additional context

I've looked and there seems to be a lot of vaguely related issues, but none that specifically meet what I'm trying to do:

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