MSBuild add file to primary output

雨燕双飞 提交于 2020-01-03 18:51:50

问题


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".

Thanks, Marek


回答1:


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)" />

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



来源:https://stackoverflow.com/questions/16087191/msbuild-add-file-to-primary-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!