【问题标题】:Perform action after Publish in VisualStudio在 Visual Studio 中发布后执行操作
【发布时间】:2016-08-26 12:01:03
【问题描述】:

我想在发布完成后执行脚本。要在 Visual Studio 中开始发布,我右键单击 project -> Publish... 对于发布,我使用 FTP 方法。 我知道我可以在 .xproj 或 .pubxml 文件中设置目标,但我找不到将调用我的目标的实际事件。 我的 .pubxml 文件是这样的:

    <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>

我想调用目标 MyTarget。我到处寻找,但找不到方法。

【问题讨论】:

    标签: visual-studio msbuild publishing


    【解决方案1】:

    基于使用 FTP 方法(VS2015)发布 Web 应用程序的详细日志(诊断),最后一个目标是 GatherAllFilesToPublish,它在将文件发布到 FTP 文件夹之前运行。

    在 GatherAllFilesToPublish 之后尝试在目标中执行其他操作。例如(编辑您的项目文件 XXX.csproj):

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多