pubxml web publish tool Event Lifecycle

孤街醉人 提交于 2019-12-05 10:35:26

As far as I can tell GatherAllFilesToPublish is the last event available. However, depending on your requirements you may still be able to use this event.

Instead of performing operations on files in the final publish location, you can target the intermediate files written to the location below (where ProjectDir is the folder of your project obviously)

/ProjectDir/obj/Release/Package/PackageTmp/

It seems that Visual Studio does a straight copy of all files in this directory. So, when hooking into GatherAllFilesToPublish you should be able to make any changes to the files in this directory and they will be reflected in the final publish location.


Related Information

If you'd like to verify that GatherAllFilesToPublish is truly the last event you can do this yourself by enabling Diagnostic build output.

Tools -> Options -> Projects and Solutions -> Build and Run -> MSBuild project build output verbosity -> Diagnostic

Build the project and search for Done building target "GatherAllFilesToPublish", for me this was the last trigger before it started copying the files to the publish location.

I had the same problem. Your solution

Coping first to the temp directory and let web publish picking up the coping for publishing

was helpful.

I just want to share for other people how it can be done:

<Target Name="CopyConfigForPublish" AfterTargets="CopyAllFilesToSingleFolderForPackage" Condition="exists('$(SolutionDir)Web.Common\bin\$(Configuration)\Log.config')">
    <Copy SourceFiles="$(SolutionDir)Web.Common\bin\$(Configuration)\Log.config" DestinationFolder="$(WPPAllFilesInSingleFolder)" />
</Target>
Gabriel Marques

I had a similar issue.

As far as i could check, "GatherAllFilesToPublish" is the last target you can deal with. You can use it doing an AfterTargets.

And use this >

$(MSBuildProjectDirectory)\obj\Release\Package\PackageTmp

To manipulate anything there.

What I did was creating an .bat file to do the dirty work.

You can find out which one is the variable that stores the relative part of the path (\obj\Release\Package\PackageTmp) and use it on more refined way.

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