title: Automatically nest files in .csproj class libary (DependentUpon)
body: <p>I have a number of C# files I am generating. I would like them to automatically be nested under the matching C# file inside the Visual Studio solution explorer. For example, Foo.Generated.cs and Bar.Generated.cs would be nested under Foo.cs and Bar.cs, respectively.</p>
  
  <p>If possible I'd like to be able to manage this in my Directory.Build.props file, so all the class libraries in my solution will have the same behavior.</p>
  
  <p><strong>Versions</strong></p>
  
  <ul>
  <li>.NET Core 3.1</li>
  <li>Visual Studio 2019 (16.5.3)</li>
  </ul>
  
  <p><strong>Failed Attempt A:</strong></p>
  
  <pre><code>&lt;Compile Update="**\*Generated.cs"&gt;
    &lt;DependentUpon&gt;$([System.String]::Copy(%(Filename)).Replace('.Generated', '.cs'))&lt;/DependentUpon&gt;
  &lt;/Compile&gt;
  </code></pre>
  
  <p><strong>Failed Attempt B:</strong></p>
  
  <pre><code>&lt;Compile Update="**\*Generated.cs"&gt;
    &lt;DependentUpon&gt;%(Filename)&lt;/DependentUpon&gt;
  &lt;/Compile&gt;
  </code></pre>
  
  <p><strong>Failed Attempt C:</strong></p>
  
  <pre><code>&lt;Compile Update="**\*Generated.cs"&gt;
    &lt;DependentUpon&gt;%(Filename).cs&lt;/DependentUpon&gt;
  &lt;/Compile&gt;
  </code></pre>
  
  <p>The above approaches have also been tried with:</p>
  
  <pre><code>&lt;ItemGroup&gt;
    &lt;ProjectCapability Include="DynamicDependentFile" /&gt;
    &lt;ProjectCapability Include="DynamicFileNesting" /&gt;
  &lt;/ItemGroup&gt;
  </code></pre>