dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.64k stars 1.05k forks source link

`dotnet sln add` should allow non-project files to be added to the solution #9611

Open TheRSP opened 6 years ago

TheRSP commented 6 years ago

In my company we often have a small number of files at the solution level for each solution. These include, for example:

I can't find anyway to add to these to a solution. The following image shows the result I would like in visual studio. image

I would propose a command format such as dotnet sln <SLN_FILE> add file [file1 [file2 [...]]] for adding items to a 'Solution Items' folder (as above) and dotnet sln <SLN_FILE> add --directory=MyFolderName file [file1 [file2 [...]]] for adding items to a custom named folder

KathleenDollard commented 3 years ago

We had a comment on Twitter on this https://twitter.com/peval27/status/1404920313289269248?s=20

Anyone know why we do not already do this?

peval27 commented 2 years ago

is this issue been considered at all?

@KathleenDollard

jpactor commented 2 years ago

Can this be considered for an upcoming release? The ability to script adding non-project solution files to the solution would be ideal.

forensicmike commented 1 year ago

Just throwing my hat in the ring as 😱 that this is still not possible in 2022

tahq69 commented 1 year ago

and 5 years later, still is not implemented 👎

baronfel commented 1 year ago

Hey folks - this one got lost in the tagging/labeling shuffle. I'd love to see this implemented - I've marked it up for grabs in case anyone has the desire to contribute. The spec that @TheRSP laid out is a good guideline to follow here. Some additional behavior clarifications:

dileep-hegde commented 11 months ago

Edit: I just realized that the issue is only related to the dotnet CLI. and which is still not possible.

In Case, anyone trying to do this in VS Code using the NEW C# Dev Kit Extension.

Here are the Steps to add files at the solution level.

  1. In Solution Explorer, Click on New Solution Folder option on the main Solution.
  2. Create a Solution folder named "Solution Items".
  3. Right-Click on that Solution folder and select Add Existing Files to add the files which are located on the main Solution where sln file exists.

At the moment, we don't have a dedicated Add File option at the Solution Level.

Also, I doubt, whether it is possible without Solution Explorer as Solution Items is a Solution folder and Solution folders are not a physical folder on the disk.

jpactor commented 11 months ago

Users can already add a project directly to a solution folder with the CLI with the "--solution-folder" option, which even creates the intermediary folders if they don't already exist. Is there a particular reason why a project and a single file are completely different?

dominikjeske commented 2 months ago

I hope slnx (https://github.com/dotnet/sdk/issues/40913) will have this up front