-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
dotnet sln add
should allow non-project files to be added to the solution
#9611
Comments
dotnet sln add
should allow non-project files to be added to the solution
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? |
is this issue been considered at all? |
Can this be considered for an upcoming release? The ability to script adding non-project solution files to the solution would be ideal. |
Just throwing my hat in the ring as 😱 that this is still not possible in 2022 |
and 5 years later, still is not implemented 👎 |
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:
|
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.
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. |
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? |
I hope slnx (#40913) will have this up front |
@baronfel I'm considering this issue as my potential first contribution to this repository, but I want to align on the design first. There are a few options here:
Given the cons listed, I'm actually leaning towards options 3 or 4 (to be consistent with rest of the CLI), as opposed to the proposed option 1.
|
Having thought more about this, I've concluded that option 4 doesn't work because it cannot distinguish between a solution item, a solution folder, and a project with the same name. Will go with option 3. Would appreciate it if I could be assigned to the ticket. |
My quick thoughts are that I disagree with some of the cons you have listed for option 1, and it remains my preference. There is no technical or grammatical difference between a single subcommand and N subcommands - they are all just Commands and all that matters is the chain you use to get to them. Right now aside from nuget, we also have prior art for this in the Of the remaining, option 3 is my most favored, but I still disagree with that approach. Establishing a top-level command for |
Thanks for the input @baronfel! I agree that option 1 is the most intuitive and straightforward from the user's perspective, but as a first-time contributor, I wasn't sure how to go about it.
Are you referring to something like this? https://github.com/dotnet/sdk/blob/main/src/Cli/dotnet/commands/dotnet-workload/WorkloadCommandParser.cs#L146-L156 |
Yeah, that's a good example. In System.CommandLine, you can add a SubCommand (which is really just another Here's a quick example of what the simplest kind of nested-subcommand registration for this might look like: private static CliCommand ConstructCommand()
{
CliCommand command = new("add", LocalizableStrings.AddAppFullName);
command.Arguments.Add(ProjectPathArgument);
command.Options.Add(InRootOption);
command.Options.Add(SolutionFolderOption);
+ command.Subcommands.Add(new CliCommand("file"));
command.SetAction((parseResult) => new AddProjectToSolutionCommand(parseResult).Execute());
return command;
} It's just that for anything 'real' we want to make a standalone class for the Command, so that's what the additional bit of ceremony is about. |
Thanks @baronfel! A few more immediate questions:
This looks confusing to me, because |
This work is complicated by #45072 (comment) the slnx functionality, it should still be done but there might be a pause first. Thank you for your engagement here. I will also mark this so we can hopefully get some clarity on your questions above in a bit. |
Update: FYI, the PR for the new |
Hi @nagilson / @edvilme - would you be able to answer my questions in #9611 (comment)? I think the most blocking one is number 3 (pasted below), since everything else can be discussed during a code review:
|
Hii, just following up on some of the questions @Bartleby2718
No, this means that if the argument
Kind of related to question 1, but I believe this is a more design-oriented question and would like to know @baronfel 's opinion. However, IMO, as a user I would expect it to create solution folder
Build times can definitely be a bottleneck. That approach would probably work but I would recommend still doing the full build to be able to catch additional failing tests, as I believe there are some that call |
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.
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) anddotnet sln <SLN_FILE> add --directory=MyFolderName file [file1 [file2 [...]]]
for adding items to a custom named folderThe text was updated successfully, but these errors were encountered: