How to bind a custom event to the grunt task runner in VS 2013

て烟熏妆下的殇ゞ 提交于 2019-12-23 22:54:03

问题


I'm aware of the task runner as a visual studio extension, you can bind a grunt task to a specific visual studio "event" like:

  • before build
  • after build
  • clean
  • open solution

In my case I want to automate the deploy process to run a build task using grunt (clean, minify, concat files, etc.) before creating a deploy package when publishing a website in visual studio.

I also want to do some modifications to the deploy package instead to pickup the whole list of files in the main directory I'd like to select the libraries (DLLs) and the files that are created by the grunt task in the dist folder, for me sounds like a combination of the task runner and the MSBuild.

in other words, these are my questions:

  • how can I trigger a task before publishing a website?
  • how can I choose specific folders, instead of the whole root directory of the application?

any suggestions or guidance will be more than welcome.


回答1:


I can help you with part of your question, as I'm doing something similar when it comes to selecting what to deploy.

You can create a file in your project called projectname.wpp.targets which is an XML file that allows you fine tune MSBuild. More info here about the MSBuild schema here.

I suspect what you're looking for are the ExcludeFromPackageFolders and ExcludeFromPackageFiles, so you only deploy what you want.

Example:

<?xml version="1.0" encoding="utf-8" ?><Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
    <ExcludeFromPackageFolders Include="Application;bower_components;node_modules">
        <FromTarget>PhoneBook.wpp.targets</FromTarget>
    </ExcludeFromPackageFolders>
    <ExcludeFromPackageFiles Include=".bowerrc;bower.json;gulpfile.js;package.json;main.html;PhoneBook.wpp.targets">
        <FromTarget>PhoneBook.wpp.targets</FromTarget>
    </ExcludeFromPackageFiles>
</ItemGroup>

As for triggering a custom event, sorry I can't help there, I'd love to have a post-publish event to hook into as Gulp and MSBuild can sometimes trip up over each other due to the former's asynchronous nature.



来源:https://stackoverflow.com/questions/27233301/how-to-bind-a-custom-event-to-the-grunt-task-runner-in-vs-2013

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!