文件嵌套不适用于类或共享库项目 [英] Filenesting not working for Class or Shared Library Projects

查看:16
本文介绍了文件嵌套不适用于类或共享库项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2019 Web 项目中,解决方案资源管理器中的文件嵌套就像一个魅力.如果您添加一个名为 ClassA.cs 的文件和另一个名为 ClassA.Custom.cs 的文件,它们会按原样嵌套.

In Visual Studio 2019 Web Projects, file nesting in the Solution Explorer works like a charm. If you add a file named ClassA.cs and another file named ClassA.Custom.cs they get nested as it should be.

但是对于类或共享库项目,它根本不起作用.将设置更改为默认"或Web"甚至添加自定义文件嵌套设置都没有关系.

But for Class or Shared Library Projects it doesn't work at all. It doesn't matter if you change the settings to "Default" or "Web" or even add a custom File Nesting Setting.

有没有办法配置 Visual Studio 2019 以便文件嵌套也适用于类库项目等?

Is there a way, to configure Visual Studio 2019 so that file nesting also works in Class Library Projects and alike?

我知道可以手动更改 *.csproj 文件以添加带有 <DependentUpon> 标签的条目,就像在早期的 Visual Studio 版本中一样,但我真的不喜欢为我拥有的所有课程手动更改此设置.

I know one could change the *.csproj files manually to add Entries with the <DependentUpon> Tag like it was in earlier Visual Studio versions, but i really don't like the idea of changing this manually for all the classes i have.

<Compile Update="$(ProjectDir)\Person.*.cs">
  <DependentUpon>$(ProjectDir)\Person.cs</DependentUpon>
</Compile>

推荐答案

Github.com 上有一个关于此主题的问题:问题 5722

There is an issue about this topic active on Github.com: Issue 5722

存在解决此问题的方法 - 至少适用于 .Net Standard 2.0.将以下行添加到您的 *.csproj 文件中:

A workaround for this problem exists - at least working for .Net Standard 2.0. Add the following lines to your *.csproj file:

<代码><项目组><ProjectCapability Include="DynamicDependentFile"/><ProjectCapability Include="DynamicFileNesting"/></ItemGroup>

这篇关于文件嵌套不适用于类或共享库项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆