Visual Studio Publish的Bower [英] Bower with Visual Studio Publish

查看:72
本文介绍了Visual Studio Publish的Bower的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Visual Studio 2015中开发的MVC 4应用程序中使用Bower。我知道当您拥有带有Visual Studio 2015 Update 1的MVC 5项目时,有一个很好的Bower管理UI,就像nuget一样接口。这部分并不是很关键。

I want to use Bower in an MVC 4 application, developed in Visual Studio 2015. I know when you have a MVC 5 project, with Visual Studio 2015 Update 1, there is a nice UI for Bower management, much like the nuget interface. This part is not really critical.

我当前正在使用bower-我有npm和bower设置,并且解决方案中有package.json和bower.json文件。保存时,Visual Studio自动运行 npm install,而package.json中有一个后安装步骤,可以运行 bower install。

I am using bower currently - I have npm and bower setup, and I have the package.json and bower.json files in the solution. When you save, Visual Studio automatically runs "npm install" and I have a postinstall step in package.json to run "bower install".

我不想放将bower_components放入解决方案(或源代码管理)中。我想要的只是保留json配置文件,保存时将检索所有依赖项。

I do not want to put the bower_components into the solution (or source control). What I want is to just keep the json config files, and when you save, all dependencies are retrieved.

这一切在开发中都很好,但没有用右键单击Web项目,发布。发布不会运行 npm install,并且不包含解决方案中未包含的文件(除非它似乎可以与解决方案中未包含的nuget包一起使用)。 发布Web功能是如何使用IIS部署将我的Web应用程序部署到生产中。

This all works fine in development, but what doesn't work is right clicking the Web Project, Publish. Publish does not run "npm install", and does not include files not included in the solution (except it seems to work with nuget packages not included in the solution somehow). The "Publish Web" functionality is how my web applications are deployed to production using IIS deployment.

如何使Visual Studio Web Publish与Bower一起使用?

How can I make Visual Studio Web Publish work with Bower?

另一种方法-我已经看到了用于运行gulp任务的Team System Build的新钩子,但是我不知道您可以用这种方式直接发布到IIS。 p>

An alternative - I have seen there are new hooks for Team System Builds that will run gulp tasks, but I don't know that you can publish directly to IIS in this manner.

推荐答案

除了引用/部署完整的bower_components文件夹外,您还可以使用gulp或grunt脚本(随意选择)来复制可以将bower_components文件夹中的文件更正为scripts / lib之类的文件。

instead of referencing/deploying the complete bower_components folder, you can use a gulp or grunt script (pick whatever you prefer) to copy the correct files out of the bower_components folder to something like scripts/lib.

然后,您可以将这些文件包含在源代码管理中,然后进行部署。

You can then include these files in source control and subsequently deploy them.

以下是我用来完成此操作的文件:

The following is a grunt file that I use to accomplish this:

module.exports = function (grunt) {
    grunt.initConfig({
        pkg: grunt.file.readJSON("package.json"),
        copy: {
            main: {
                files: [
                  {
                      expand: true,
                      flatten: true,
                      src: [
                          'node_modules/vss-sdk/lib/VSS.SDK.js',
                          'node_modules/moment/moment.js',
                          'node_modules/moment-timezone/moment-timezone.js',
                          'node_modules/jquery/dist/jquery.js',
                          'bower_components/datetimepicker/jquery.datetimepicker.js',
                          'bower_components/datetimepicker/jquery.datetimepicker.css',
                      ],
                      dest: 'scripts/lib',
                      filter: 'isFile'
                  }              
                ]
            }
        }
    });

    grunt.loadNpmTasks("grunt-exec");
    grunt.loadNpmTasks("grunt-contrib-copy");
};

这篇关于Visual Studio Publish的Bower的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆