问题
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