问题描述
使用新的 .csproj 格式(以及旧格式),可以在项目文件夹之外添加链接的文件:
with the new .csproj format (as well as the old), it is possible to add files as linked outside of the project folder:
也可以使用 glob 模式来包含多个文件:
it is also possible to use a glob pattern to include multiple files:
但是如何将两者结合起来呢?
but how do you combine the two?
前两个仅创建一个链接文件(分别具有确切的名称 *.cs 和 *).第三个只是出错了.
the first two only create a single linked file (with exactly the name *.cs and * respectively). the third simply errors out.
有没有办法将 globbing 与链接文件结合到目标项目中的特定位置?如果没有,如何在不知道有多少或名称的情况下链接目录中的所有文件?
is there a way to combine globbing with linked files to a specific location in the target project? if not, how can i link all the files in a directory without knowing how many or what their names are?
推荐答案
虽然以前可以在使用 glob 扩展时使用 %(recursivedir) 元数据(link="resources\%(recursivedir)%(filename)%(extension)"),2.0.0版本的.net core sdk允许使用新的linkbase元数据:
while this was previously possible using the %(recursivedir) metadata when using glob expansion ( link="resources\%(recursivedir)%(filename)%(extension)"), the 2.0.0 version of the .net core sdk allows the use of a new linkbase metadata:
注意,除了最近发布的 vs 2017 15.3 之外,还需要安装 2.0.0(并确保没有 global.json 选择较低的版本).
note that you need to install the 2.0.0 in addition to the recently released vs 2017 15.3 (and ensure no global.json selects a lower version).
它是通过 this pull request 引入的,这可能是目前最好的文档.
it was introduced with this pull request which is probably the best documentation at the moment.