MSBuild将文件添加到主要输出 [英] MSBuild add file to primary output
问题描述
如何将MSBuild创建的一些自定义文件添加到项目输出中? 即,我有空白的.csproj,我向目标添加了Exec任务,该任务生成了一些file.txt,现在我想将此文件包含到主要输出"或内容文件"中.
How can i add some custom file created by MSBuild to project output? i.e. I have blank .csproj, I add Exec task to Target that generates some file.txt and now i want to include this file into "primary output" or "content files".
谢谢, 马雷克
推荐答案
通常,您只需要包含您拥有的输出文件,然后将它们复制到输出目录即可.
Generally, you just need to include the output files you have and then copy them to the output directory.
<CreateItem Include="$(SourcePath)\file.txt">
<Output ItemName="FilesToCopy" TaskParameter="Include" />
</CreateItem>
<Copy SourceFiles="@(FilesToCopy)" DestinationFolder="$(OutDir)" />
对于直接项目,还有一个变量$(OutputDirectory).您可能还会发现其他许多有用的属性:
There's also a variable $(OutputDirectory) for the immediate project. There are many other properties you may find useful also:
https://msdn.microsoft.com/en-us/library/ms164309.aspx https://msdn.microsoft.com/en-us/library/ms164313.aspx
这篇关于MSBuild将文件添加到主要输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!