我可以在Compile元素中同时使用通配符和Link元素吗?

我可以在Compile元素中同时使用通配符和Link元素吗?

问题描述:

.csrpoj文件中,如果我有

<Compile Include="c:\path\File1.cs">
  <Link>Dir1\File1.cs</Link>
</Compile>

然后,Visual Studio将该文件显示为解决方案资源管理器中Dir1文件夹下的快捷方式.

Then Visual Studio shows that file as a shortcut under Dir1 folder in the Solution Explorer.

如果我有

<Compile Include="c:\path\*.cs"></Compile>

然后,所有.cs文件都将作为解决方案浏览器中的快捷方式显示在顶层:

Then all .cs files show up as shortcuts in Solution Explorer at top level:

有没有一种方法可以将 all 个文件包含在某个文件夹中,然后使其显示在子文件夹下?忽略Link元素中的文件名不起作用:

Is there a way to include all files in some folder and make then show up under a sub-folder? Omitting the filename in Link element does not work:

<Compile Include="c:\path\*.cs">
  <Link>Dir1\</Link>
</Compile>

文件仍显示在顶层.

如何将所有文件包含在文件夹中,并且仍然使用Link元素?我需要这个的原因是,我需要包含多个文件夹中的文件,其中一些具有相同的名称.顶层的两个文件不能具有相同的名称.

How do I include all files in a folder and still use the Link element? The reason I need this is, I need to include files from multiple folders and some of them have the same name. Two files at top level cannot have the same name.

还有其他方法可以实现这一目标吗?

Any other way to achieve this?

<Content Include="..\..\SomeDirectory\**\*.xml">
  <Link>SomeLinkDirectoryOfYourChoosing\%(Filename)%(Extension)</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>