'Visual studio .projitems wildcards

I modified the project file to include all cs files in the directory with a wild card.(see below).

Unfortunately every time I modify the project using visual studio's solution explorer it removes these wildcards and adds to modified files.

I would like to not have to add each file individually. The documentation isn't clear on this. It states that it should be supported. Anyone know how this can be achieved?

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
    <HasSharedItems>true</HasSharedItems>
    <SharedGUID>f4ee43f1-9cbc-42af-85c0-69df3a128976</SharedGUID>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="$(MSBuildThisFileDirectory)**/*.cs" />
  </ItemGroup>
</Project>

After removing 1 file (Note that it now hides a whole bunch of .cs files):


<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
    <HasSharedItems>true</HasSharedItems>
    <SharedGUID>f4ee43f1-9cbc-42af-85c0-69df3a128976</SharedGUID>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="$(MSBuildThisFileDirectory)Test\Class1.cs" />
  </ItemGroup>
  <ItemGroup>
    <Folder Include="$(MSBuildThisFileDirectory)Test\Models\" />
  </ItemGroup>
</Project>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source