Search code examples
c#.net-corecsproj

Is there a DependentUpon option in a .net core app?


In my .net core application, I would like to have my partial files put under a given file like it was with a .net framework application using the tag DependentUpon in the csproj.

As shown in a picture, I would like all Program.*.cs files to be under Program.cs.

enter image description here

However, in the .csproj file, I do not see the file listed:

enter image description here

Is there a way to do that in a .net core app?


Solution

  • Yes, you just put an entry in an ItemGroup to update the implicit Compile elements from globbing. I'd personally use a separate ItemGroup element for this, away from your dependencies:

    <ItemGroup>
      <Compile Update="Program.*.cs">
        <DependentUpon>Program.cs</DependentUpon>
      </Compile>
    </ItemGroup>