Sdk: dotnet sln remove flattens the solution items

Created on 17 Feb 2019  路  10Comments  路  Source: dotnet/sdk

Steps to reproduce

  • Set up an sln with nested solution items.
  • Remove a project

Expected behavior

The nested solution items should be preserved.

Actual behavior

The nested solution items get flattened.
For a repro see the following repo: https://github.com/cveld/dotnet-cli-sln-remove-issue

Environment data

dotnet --info output:
.NET Core SDK (reflecting any global.json):
Version: 2.1.503
Commit: 4c506e0f35

Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.503\

Host (useful for support):
Version: 2.1.7
Commit: cca5d72d48

good first issue help wanted

Most helpful comment

Ok i have found the code, and built the code locally as well. Will update once resolved.

All 10 comments

@peterhuene just putting this in your backlog.

Hi @peterhuene,

Can I take this up, first time contributor here, so may need help.

Regards,
Santosh

@santoshyadav198613 we'd be honored. Feel free to mention me if you run into any issues and I'll help you along the best I can. Thanks!

Hi @peterhuene ,

If i understand this issue correctly this is what i have observed:
when we run below command
dotnet sln WebApplication1.sln remove ConsoleApp1ConsoleApp1.csproj

this also removes below section
GlobalSection(NestedProjects) = preSolution
{9188D173-EFB7-4EEA-9846-9F5A79F2CB38} = {02AD42F4-9611-4B66-B9B0-BFE409B7D9D6}
EndGlobalSection
which should not happen , please correct me if i am wrong.

Regards,
Santosh

That is correct. It also seems to remove the solution folder Folder1 for me entirely.

I would expect it to remove only things relating to the project being removed.

Ok i have found the code, and built the code locally as well. Will update once resolved.

@peterhuene @livarcocc I can fix this, however, I find there is a test checking that this particular behavior is exhibited at

https://github.com/dotnet/cli/blob/3e26f2daf398be5aacd6194c1a06690c656d0866/test/dotnet-sln-remove.Tests/GivenDotnetSlnRemove.cs#L666

Makes me wonder if there's a reason for the behavior or I can go ahead to fix

Hi @vnwonah. Thanks for offering to help fix this issue!

I believe the test to be correct for what it tests. The intention is that if you remove a project and the solution folder containing that project is made empty by the removal, the containing solution folder also gets removed. If removing the solution folder causes its parent solution folder to now be empty, it gets removed; this process is repeated until the root is reached.

In this repro case, however, the project being removed isn't in a solution folder. The solution folder hierarchy should remain unchanged after the project is removed.

Ah, I see that now @peterhuene. Thanks for pointing that out. I鈥檒l open a PR when done.

I believe this PR https://github.com/dotnet/cli/pull/12149 also fixes this issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

noelitoa picture noelitoa  路  3Comments

moozzyk picture moozzyk  路  3Comments

krwq picture krwq  路  3Comments

fmorriso picture fmorriso  路  3Comments

aguacongas picture aguacongas  路  3Comments