Skip to content

Removing all items included by a wildcard doesn't remove the wildcard #2838

@danmoseley

Description

@danmoseley

Starting with this - note my project is not in c:\shared

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="c:\shared\*.cs" />
  </ItemGroup>

</Project>

which in my case gives me foo.cs and bar.cs in the solution explorer, I remove foo.cs and bar.cs from the solution explorer, and it gives me

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="c:\shared\*.cs" />
  </ItemGroup>

  <ItemGroup>
    <Compile Remove="c:\shared\bar.cs" />
    <Compile Remove="c:\shared\foo.cs" />
  </ItemGroup>

</Project>

In my mind, it's more likely that I meant "I don't need the shared files" than I mean "I don't need these specific files but I might add other files to that folder later". In my actual case there were a large number of files pulled in by the wildcard so I ended up with a lot of Remove tags.

I suggest the heuristic be, if a gesture removes the last files originating from a project file wildcard expression outside of the project root, the wildcard expression (and any Remove expressions against it) can be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-External-CPSOwned by CPS and not this repo. Likely be closed in lieu of issue filed against VS platform.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions