文件可以嵌套在.NET Core(非ASP.NET Core)项目的VS2017解决方案资源管理器中吗? [英] Can files be nested in VS2017 Solution Explorer for .NET Core (non-ASP.NET Core) projects?

查看:164
本文介绍了文件可以嵌套在.NET Core(非ASP.NET Core)项目的VS2017解决方案资源管理器中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在老派" 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时会返回.但是,即使手动添加了与旧版本相同的元素的ItemGroup,基于.NET Core SDK(根元素<Project Sdk="Microsoft.NET.Sdk">)的MSBuild项目在Visual Studio 2017中似乎也没有得到相同的处理.学校"项目.

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.这是因为隐式项目来自于在主项目之前导入的props文件.附加的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.

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

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