pubxml web publish tool Event Lifecycle

白昼怎懂夜的黑 提交于 2019-12-07 05:30:20

问题


I am using the Web publishing tool from Visual Studio 2012 to publish to File System. I learned that I can open my *.pubxml in the Properties folder to do more advanced things.

What I want to do is run a command line application at the end of the publishing task. I would usually do it in a Custom Target and execute it after one of the build in Events like this.

 <Target Name="CustomAfterPublish" AfterTargets="GatherAllFilesToPublish">
 </Target>

The problem is that GatherAllFilesToPublish is way to early because I want to execute it at the very last, after publishing was done. Is there a list or does someone know the build in events and there order in which they are fired? Basically the Event Lifecycle of a FileSystem web publish.

Or how can I fire a Target manually at the very end?

I tried following without success:

<Target Name="Msg" AfterTargets="PipelineDeployPhase;MSDeployPublish;Package">

And also every each of them individually. So what's the very last hook of the publishing lifecycle?

---> Edited I added already tracing. The problem is that the files were copied to a temp path and after that all files are deleted. So copying to the destination will not work after "GatherAllFilesToPublish"See my trace from the command line window here...

1>------ Build started: Project: Dependency of a project: Release Any CPU ------
2>------ Build started: Project: Dependency of another project, Configuration: Release Any CPU ------


3>------ Build started: Project: Web, Configuration: Release Any CPU ------
4>------ Publish started: Project: Web, Configuration: Release Any CPU ------
4>Transformed Web.config using C:\...\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
4>Copying all files to temporary location below for package/publish:
4>obj\Release\Package\PackageTmp.

**<------------- Here is the place where my excutable is called ---------------------------------**


4>Deleting existing files...
4>Publishing folder /...
4>Publishing folder App_Browsers...
4>Publishing folder App_Themes...
4>Publishing folder bin...

4>Site was published successfully file:///C:/Test
4>
========== Build: 3 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

Thanks for any help.


回答1:


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.




回答2:


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>



回答3:


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.



来源:https://stackoverflow.com/questions/28409352/pubxml-web-publish-tool-event-lifecycle

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