Is there a DependentUpon option in a .net core app?
Asked Answered
A

2

5

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?

Azikiwe answered 21/6, 2018 at 14:26 Comment(0)
E
7

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>
Encumbrancer answered 21/6, 2018 at 14:29 Comment(0)
N
0

One thing to note is the folder structure as stated here. If the files are located in a folder, then you reference the parent without the folder, like so:

<ItemGroup>
  <Compile Update="Models\Person.*.cs">
    <DependentUpon>Person.cs</DependentUpon>
  </Compile>
</ItemGroup>

Naca answered 12/10, 2023 at 20:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.