Skip to content

new File gets removed from custom ItemGroup #4483

Open
@SabotageAndi

Description

@SabotageAndi

I have following csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <CustomFileTypeItemGroup Include="**\*.customFileType"></CustomFileTypeItemGroup>
  </ItemGroup>
</Project>

If I add via the Add new File dialog a new File from Text File template with the name TextFile1.customFileType, Visual Studio changes the csproj to following:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <CustomFileTypeItemGroup Include="**\*.customFileType"></CustomFileTypeItemGroup>
  </ItemGroup>

  <ItemGroup>
    <CustomFileTypeItemGroup Remove="TextFile1.customFileType" />
  </ItemGroup>
roject>

It is removing the new file from the custom ItemGroup.

Is there any workaround to stop this? This behavior makes us problems in SpecFlow, as VS is removing items from our ItemGroups (they are defined in a props file in the NuGet package), which we need in a MSBuild Task.

This happens in Visual Studio 2017 15.9.5 and Visual Studio 2017 16.0.0 Preview 1.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Discussion/QuestionA discussion or question about the project that will not be treated as a bug or feature request.Triage-ApprovedReviewed and prioritized

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions