我可以在 Compile 元素中同时使用通配符和 Link 元素吗?
在 .csrpoj
文件中,如果我有
<Compile Include="c:\path\File1.cs">
<Link>Dir1\File1.cs</Link>
</Compile>
,则 Visual Studio 会将该文件显示为解决方案资源管理器中 Dir1
文件夹下的快捷方式。
如果我有
<Compile Include="c:\path\*.cs"></Compile>
那么所有 .cs
文件在顶层的解决方案资源管理器中显示为快捷方式:
有没有办法将所有文件包含在某个文件夹中,然后显示在子文件夹?在 Link
元素中省略文件名不起作用:
<Compile Include="c:\path\*.cs">
<Link>Dir1\</Link>
</Compile>
文件仍然显示在顶层。
如何将所有文件包含在文件夹中并仍然使用 Link 元素?我需要这个的原因是,我需要包含多个文件夹中的文件,其中一些具有相同的名称。顶层的两个文件不能具有相同的名称。
还有其他方法可以实现这一目标吗?
In the .csrpoj
file, If I have
<Compile Include="c:\path\File1.cs">
<Link>Dir1\File1.cs</Link>
</Compile>
Then Visual Studio shows that file as a shortcut under Dir1
folder in the Solution Explorer.
If I have
<Compile Include="c:\path\*.cs"></Compile>
Then all .cs
files show up as shortcuts in Solution Explorer at top level:
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>
The files still show up at top level.
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
其他人建议使用带有占位符的
Link
属性,这确实有效。但是,Microsoft 实现了一个名为LinkBase
的新属性(该属性不在我的任何代码完成建议中),如下所示。来源:
Others have suggested the using the
Link
attribute with placeholders, which indeed works. However, Microsoft has implemented a new attribute (which isn't in any of my code completion suggestions), namedLinkBase
, shown below.Sources:
为了其他人的利益,这里是答案加上 Dean 和 Miserable Variable 的评论,我发现这很有用:
我有两个项目,我需要在另一个项目中包含 *.xsd,而无需复制文件或不必更新每次将新的 XSD 添加到第一个文件时都会引用 csproj 文件。
解决方案是将以下内容添加到 csproj 文件
注意 xxx.xsd,您必须在
Link
元素中给出一个虚拟文件名。它只是被替换。此外,您还可以包含所有子文件夹:
以及所有类型的文件(对于从第 3 方提取 CSS/JS/Style 文件夹很有用):
For the sake of others, here's the answer plus the comment from Dean and Miserable Variable, which I found useful:
I have two projects, and I need to include *.xsd from one in the other, without copying the files or having to update the referencing csproj file every time a new XSD is added to the first.
The solution was to add the following to the csproj file
Note xxx.xsd, you have to give a dummy filename in the
Link
element. It just gets replaced.Also, you can include all sub folders with:
And files of all type (useful for pulling in CSS/JS/Style folders from 3rd parties) with:
要包含子文件夹:
To include subfolders: