.net核心项目在构建时如何知道要包含哪些文件

Nas*_*sim 7 csproj .net-core

我观察到.csproj.Net标准和.Net Core 中的文件存在差异。
在.Net项目.cs,.js etc.csproj,每个项目的所有文件都包含在文件中。例如:

<Compile Include="ViewModel\LiveViewViewModel.cs" />
<Compile Include="ViewModel\RegistrationViewModel.cs" />
<Compile Include="Views\LiveView.xaml.cs">
  <DependentUpon>LiveView.xaml</DependentUpon>
</Compile>
Run Code Online (Sandbox Code Playgroud)

但是,如果我看到新的.Net Core .csproj文件,则没有.cs/.js任何文件提及。
我很想知道.net核心项目在编译时如何包含文件。

Mar*_*ich 6

它们现在来自通过Microsoft.NET.SdkMSBuild sdk 导入的msbuild定义文件,并使用通配符根据项目文件的位置指定搜索模式。

(简化)等价于如果您写

<Compile Include="**\*.cs" />
Run Code Online (Sandbox Code Playgroud)

到项目文件中,该文件已受msbulid长期支持,但不能与Visual Studio工具一起很好地工作。新的项目系统可以更好地处理通配符,然后在属性窗口中排除某些文件或更改元数据时添加适当的名称<Compile Remove".."/>Update=".."定义。

默认项目的源代码被发现在这里,以及由Web-SDK用于ASP.NET核心项目带来了一些额外的定义在这里