MsBuild copy file after build

試著忘記壹切 提交于 2019-11-29 01:15:00

Your destination folder is (most likely) wrong. If you specify it with a leading backslash, it is actually just a shortform for <current-drive-letter>\bin\Debug (making it effectively an absolute path, like C:\bin\Debug).

Either use bin\Debug, or better yet use the OutputPath variable, which is set to either bin\Debug or bin\Release depending on your build configuration.

Example:

<Target Name="AfterBuild">
     <Copy SourceFiles="Controllers.xml" DestinationFolder="$(OutputPath)" ContinueOnError="true" />
</Target>

Is the xml file in your project? Then one of its properties is CopyToOutputDirectory. Set it to CopyAlways and when the project builds the file will be copied out to bin\debug.

You have to specify the full path. I suspect the MsBuild copy task is running from the "Default path" of Visual Studio, and the file can not be found. Also, you most likely want the file to end up in the build target directory.

<Target Name="AfterBuild">
    <Copy SourceFiles="$(ProjectDir)Controllers.xml" DestinationFolder="$(TargetDir)" ContinueOnError="true" />
</Target>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!