Running Target after files are published to FileSystem

空扰寡人 提交于 2019-12-02 05:54:00

I tried to make my CopyToDeployFolders Target to override AfterPublish and tried to use various different AfterTargets, but none of them worked

After test the project file with with msbuild verbosity set to detail. I got the same result as you. Then I found that the custom target CopyToDeployFolders was executed after copy file to obj\Release\Package\PackageTmp but before Publishing folder. Just as the order that you got.

Build
AdditionalResources
CopyToDeployFolders
Publish folder

After further investigation, I found a official response:

"We currently do not support executing custom targets after publish from VS for the file system protocol. If you publish from the command line the target will be executed however."

Besides, just as we saw the log in output window, the custom target CopyToDeployFolders was executed after copy file to obj\Release\Package\PackageTmp. As a workaround, you can copy all the files from the folder "obj\Release\Package\PackageTmp" rather than the publish folder "obj\Package\PackageTemp", then the problem is solved.

So just need to change <PublishedFiles Include="obj\Package\PackageTemp\**\*" /> to:

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