5

I have a project.json script for 'prepare' that runs a gulpfile to push my bower stuff into the wwwroot. Works great, except during dev I have to manually run it after I update the bower.json package. Any way to automate this during dev? I'd normally use a post-build script but they are no where to be seen. My project.json scripts are looks like this:

  "scripts": {
    "prepare": [ "gulp bower" ]
  }

What i'd love is:

  "scripts": {
    "post-build": [ "gulp bower" ]
  }

2 Answers 2

6

You can use the Task Runner Explorer to automate this. (Use the Quick Launch in the upper right, Ctrl+Alt+\, or View->Other Windows->Task Runner Explorer.)

Find the task you want to add (bower or prepare, depending on the route you want to go), right click, and use the context menu to add the bindings.

My gruntfile.js, for example, got the following line added to the top:

/// <binding BeforeBuild='beforeBuild' AfterBuild='afterBuildMinimal' ProjectOpened='watch' />

I'm not certain if the gulpfile.js uses the exact same conventions, but the Task Runner Explorer is the way to go, either way!

3
  • bows Glad to be of service, Shawn! Commented May 29, 2015 at 13:00
  • 2
    That's right, @JuanDavid. The Task Runner Explorer is only a Visual Studio IDE thing. Now, you'll want to do something completely different, since the project.json is obsolete; I run commands in csproj like this: <Target Name="PreBuild" BeforeTargets="PreBuildEvent"><Exec Command="cd $(ProjectDir)&#xD;&#xA;gulp bower" /></Target> Commented Jul 2, 2017 at 13:50
  • 1
    I use npx to avoid installing packages globally: <Exec Command="npx gulp js" />
    – Lion
    Commented Oct 2, 2018 at 14:39
1

there's postrestore and postbuild you can use on project.json.

I use it like this :

"postrestore": [ "npm install", "bower install" ]
"postbuild": [ "brunch build" ]

in your example, I think you want

"postbuild": [ "gulp bower" ]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.