msbuild include/从子目录复制到根目录 - 可能吗?
我可以包含子目录中的文件,但将其放置在 bulid 的根目录中而不是其原始子目录中吗?
示例:我们有多个用于不同发布配置的 robots.txt 文件。这些文件在解决方案中为 \IncludeTest\Development\robots.txt 和 \IncludeTest\Production\robots.txt
我可以使用类似的方法动态地抓取它们:
<ItemGroup Condition=" '$(Configuration)' == 'Development' ">
<Content Include="IncludeTest\Development\robots.txt">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
但是当我这样做时,我会维护 \IncludeTest\Development\ (或\includeTest\Production) 目录。有什么方法可以将其包含在根目录中,即 robots.txt 应该在的位置吗?
Can I include a file from a subdirectory, but have it placed in the root directory of the bulid instead of its original sub directory?
Example: We have multiple robots.txt files for different release configurations. The files are in the solution as \IncludeTest\Development\robots.txt and \IncludeTest\Production\robots.txt
I can dynamically grab them appropriately using something like:
<ItemGroup Condition=" '$(Configuration)' == 'Development' ">
<Content Include="IncludeTest\Development\robots.txt">
<SubType>Designer</SubType>
</Content>
</ItemGroup>
but when I do that, I maintain the \IncludeTest\Development\ (or \IncludeTest\Production) directory. Any way to just include it in the root directory, where robots.txt is supposed to be?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
上述方法仍然不完全适合我,但我能够根据您设置项目组的方式找到解决方法:
将文件作为链接包含在解决方案中,将其放入根目录中。通过您的 $(Configuration) 提示,我能够做到这一点,并且只需将其动态包含为链接,而不是将其复制到根目录。
The above still did not work for me entirely, but I was able to find a work around based on how you set up the itemgroup:
Including the file in the solution as a link puts it in the root directory. And with your $(Configuration) hint, I was able to do this, and just include it dynamically as a link, rather than copy it over to the root.
不确定我的问题是否正确,请让我知道这是否按您的预期工作:
复制到根目录:
编辑:当文件位于嵌套目录中时可能会出现问题,因此请尝试:
Not sure I got your question right, let me know whether this work as you expected:
Copy to root:
EDIT: It could be problem when files are in nested directories, so try out: