New .csproj format - How to specify entire directory as quot;linked filequot; to a subdirectory?(新的.csproj格式 - 如何将整个目录指定为“链接文件.到子目录?)
问题描述
与新 .csproj 格式(以及旧的),可以将文件添加为项目文件夹外面的链接:
With the new .csproj format (as well as the old), it is possible to add files as linked outside of the project folder:
<EmbeddedResource Include="......DemoSample.cs" Link="ResourcesSample.cs" />
也可以使用 glob 模式来包含多个文件:
It is also possible to use a glob pattern to include multiple files:
<EmbeddedResource Include="......Demo*.cs" />
但是如何将两者结合起来呢?
But how do you combine the two?
-
< embeddedResource include =.. .. .. demo *.CS"链接=资源 *.CS"/> -
< embeddedResource include =.. .. .. demo *.CS"link =资源 *"/> -
< embeddedResource include =.. .. .. demo *.cs"link =资源"/>
前两个只创建一个链接文件(究竟是名称 *.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:
<EmbeddedResource Include="......Demo***.cs" LinkBase="Resources" />
注意,除了最近发布的 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).
它被引入这个拉请求这可能是最佳的文档.
It was introduced with this pull request which is probably the best documentation at the moment.
这篇关于新的.csproj格式 - 如何将整个目录指定为“链接文件".到子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:新的.csproj格式 - 如何将整个目录指定为“链接文件".到子目录?
基础教程推荐
- Moq It.Is<>不匹配 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- WPF 模态进度窗口 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
