简体   繁体   中英

Perform action after Publish in VisualStudio

I would like to execute script after Publish finishes. To start publish in Visual Studio I right click on project -> Publish... For publishing I use FTP method. I know I can set up Target in .xproj or .pubxml files but I can not find actual event that will call my target. My .pubxml file lok like this:

    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FTP</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish>htttp://example.com</SiteUrlToLaunchAfterPublish>
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <PublishFramework>netcoreapp1.0</PublishFramework>
    <UsePowerShell>False</UsePowerShell>
    <publishUrl>ftp://example</publishUrl>
    <DeleteExistingFiles>False</DeleteExistingFiles>
    <FtpPassiveMode>False</FtpPassiveMode>
    <FtpSitePath>myFolder</FtpSitePath>
    <UserName>john</UserName>
    <_SavePWD>False</_SavePWD>
  </PropertyGroup>
  <Target Name="MyTarget">
    <Message Text="Hello..." />
  </Target>
</Project>

I want to call target MyTarget. I have looked everywhere but I can not find way to do this.

Based on the detail log (Diagnostic) of web app publish with FTP method (VS2015), the last target is GatherAllFilesToPublish, which is running before publish file to the folder of FTP.

Try do to other things in a target after GatherAllFilesToPublish. For example (edit your project file XXX.csproj):

<Target Name="CustomPostPublishActions" AfterTargets="GatherAllFilesToPublish">
<Message Text="This is custom target" Importance="high" />


</Target>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM