9

I have a gulp file that has 2 tasks in it 1. deletes *.html files from a directory 2. copies *.html files to a directory

I have Visual Studio 2017's Task Runner Explorer setup so that:

  • Before build runs task 1
  • After build runs task 2

If I run the tasks from Visual Studio 2017's Task Runner Explorer they work

WhenI do a Visual Studio 2017's Publish, the Task Runner Explorer events are not firing. How can we get them to fire on Publish?

GregJF
  • 456
  • 4
  • 14

1 Answers1

3

Not sure, why it is not working on publish. It's always special.

As an alternative you can exectute gulp explicitly on publishing. For doing this, open your publishing profile (Properties/PublishProfiles/profile.pubxml) and modify it:

<Target Name="BeforeBuild">
   <Exec Command="gulp myTask" WorkingDirectory="$(ProjectDir)" />
</Target>

Also make sure, you have installed gulp-cli via package.json or by running the following command, if not already done:

npm install -g gulp-cli
Christian Gollhardt
  • 16,510
  • 17
  • 74
  • 111
  • I've been attempting a similar solution, but with the additional Target's configured in my .csproj file, attempting to hook into BeforePublish so my webpack bundle will build in prod mode before all publish profiles. Unfortunately, it doesn't seem to be firing during publish. Should my approach also work? – IronSean Mar 29 '18 at 18:14
  • I didn't have luck with that, but did get it working by extending an idea from here (http://www.codecadwallader.com/2015/03/15/integrating-gulp-into-your-tfs-builds-and-web-deploy/) where I added Target's for my Exec actions as dependencies for the CopyAllfilesToSinglefolderForMsDeployDependsOn rule to trigger the build before the file copy: ``` $(CopyAllFilesToSingleFolderForMsdeployDependsOn); NpmInstall; NpmBuild; CollectDistFolder; ``` – IronSean Mar 29 '18 at 19:13