文件可以嵌套在 VS2017 解决方案资源管理器中用于 .NET Core(非 ASP.NET Core)项目吗?

编程入门 行业动态 更新时间:2024-10-27 20:27:19
本文介绍了文件可以嵌套在 VS2017 解决方案资源管理器中用于 .NET Core(非 ASP.NET Core)项目吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

在老派"MSBuild 项目中——例如,VS2017 中的 Windows 窗体仍在使用——文件可以通过 csproj 文件中的 DependentUpon 项嵌套".

In "old school" MSBuild projects - as still used by Windows Forms in VS2017 for example - files could be "nested" via a DependentUpon item in the csproj file.

我用它在 Noda Time 中将单元测试组合在一起,例如

I used this to group unit tests together in Noda Time, e.g.

<Compile Include="LocalDateTest.PeriodArithmetic.cs">
  <DependentUpon>LocalDateTest.cs</DependentUpon>
</Compile>

这导致了易于导航的测试:

That led to easily-navigable tests:

在将 .NET Core 移至 project.json 时,我故意丢失"了此功能,但希望在转换为 MSBuild 时它会恢复.但是,看起来基于 .NET Core SDK 的 MSBuild 项目(根元素 <Project Sdk="Microsoft.NET.Sdk">)在 Visual Studio 2017 中没有得到相同的处理,即使 ItemGroup 是手动添加的,其元素与老派"项目相同.

I knowingly "lost" this feature when moving to project.json for .NET Core, but had hoped it would return when converting to MSBuild. However, it looks like MSBuild projects based on the .NET Core SDK (root element <Project Sdk="Microsoft.NET.Sdk">) don't get the same treatment in Visual Studio 2017, even if an ItemGroup is added manually with the same elements as the "old school" project.

ASP.NET Core 项目会收到用于缩小 CSS 和 Javascript 的自动嵌套,但尚不清楚如何将其应用于 .NET Core 库项目中的 C#.

ASP.NET Core projects receive automatic nesting for minified CSS and Javascript, but it's not clear how to apply that to C# in .NET Core library projects.

推荐答案

我让它在我的一个 Microsoft.NET.Sdk 风格的项目中工作,使用类似于以下内容:

I have it working in one of my Microsoft.NET.Sdk-style projects using something similar to the following:

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

这里的技巧是使用 Update 而不是 Include.这是因为隐式项目来自在主项目之前导入的道具文件.额外的 Include 不会影响已经包含的文件,但可以使用 Update 修改它们.

The trick here is to use Update instead of Include. This is because the implicit items are coming from a props file that is imported before the main project. An additional Include won't affect files that are already included, but they can be modified using Update.

这篇关于文件可以嵌套在 VS2017 解决方案资源管理器中用于 .NET Core(非 ASP.NET Core)项目吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-14 15:57:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/845343.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌套   资源管理   器中   解决方案   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!