pubxml web publish tool Event Lifecycle
Asked Answered
R

3

9

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.

Reflation answered 9/2, 2015 at 12:4 Comment(0)
S
9

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.

Suanne answered 17/2, 2015 at 14:33 Comment(2)
Coping first to the temp directory and let web publish picking up the coping for publishing did the trick! ThanksReflation
Publishing with 'Diagnostic' output kept failing for some reason (probably memory issues on my crappy box). I changed it to 'Detailed' and the build worked and I found 'Building target "FileSystemPublish" completely' was the last line with 'target' in my build output. Using "FileSystemPublish" as the target fixed everything for me, THANK YOU!Scott
O
0

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>
Ofori answered 27/9, 2017 at 0:59 Comment(0)
D
0

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.

Decca answered 15/6, 2018 at 23:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.