我可以为MSBuild< Content>指定输出路径吗?标签? [英] Can I specify the output path for the MSBuild <Content> tag?

查看:51
本文介绍了我可以为MSBuild< Content>指定输出路径吗?标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以为以下文件的输出指定其他文件夹?

Is it possible to specify a different folder for the output of the following file?

<Content Include="test.stl">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

推荐答案

可以使用 None / Content上的 Link 元数据来指定其他输出文件夹项:

A different output folder can be specified by using the Link metadata on None/Content items:

<Content Include="test.stl">
  <Link>some\folder\%(Filename)%(Extension)</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

在include语句中使用通配符时,这也是保存目录层次结构的一种方法,即使对于来自项目目录外部的文件也是如此:

When using wildcards in an include statement, this is also the way to preserve the directory hierarchy, even for files coming from outside the project directory:

<Content Include="..\shared\**\*">
  <Link>some\folder\%(RecursiveDir)%(Filename)%(Extension)</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

在使用2.0.0+ SDK的基于SDK的项目(ASP.NET Core/.NET Core/.NET Standard项目的默认设置)中,可以使用 LinkBase 元数据实现相同的目的:

In SDK-based projects (default for ASP.NET Core / .NET Core / .NET Standard projects) using a 2.0.0+ SDK, the same can be achieved using the LinkBase metadata:

<Content Include="..\shared\**\*" LinkBase="some\folder" CopyToOutputDirectory="PreserveNewest" />

这篇关于我可以为MSBuild&lt; Content&gt;指定输出路径吗?标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆