使用MS捆绑空包 [英] Empty Bundle using MS Bundling

查看:728
本文介绍了使用MS捆绑空包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用asp.net mvc4和内置的捆绑和由MS使用System.Web.Optimization库(1.1.0)用带点定制LessTransform提供缩小。该网站是在IIS 7托管我的问题是间歇包为空,导致网站加载网页上的所有不可思议。

I am using asp.net mvc4 and the built in bundling and minification that is provided by MS using the System.Web.Optimization library (1.1.0) with a custom LessTransform using dotless. The site is hosted in IIS 7. My problem is that intermittently the bundle is empty on the website which causes the website to load all weird.

http://site/Content/surveycss?

这是什么原因?

更新


  1. 我看了,如果少编译器遇到错误时可能会导致一个空包。我测试过少的错误,就是没有。

  1. I read that if the less compiler encounters an error it could result in an empty bundle. I've tested the less for errors and there are none.

我发现有可能与该包被配置为使用内容目录,所以我改变了它从路的一个问题:

I discovered that there maybe an issue with the way that the bundle was configured to use the Content directory, so I changed it from:

    bundles.Add(new StyleBundle("~/Content/bootstrap")
        .Include(...));


        bundles.Add(new StyleBundle("~/cssbundles/bootstrap")
            .Include(...));

重新部署应用程序后,它似乎解决这​​个问题。然而,它的再次发生。安装程序是负载平衡器与2 IIS服务器。今天,我登录到服务器1,并通过IIS浏览该网站,它装载的罚款。

After redeploying the application, it appeared to resolve the issue. However, it's happening again. The setup is a load balancer that with 2 IIS servers. Today, I logged onto server 1 and browsed the site via IIS and it's loading fine.

登录到服务器2和浏览通过IIS网站给人的捆绑问题。

Logging onto server 2 and browsing the site via IIS gives the bundling issue.

更新2

要测试认为资源可能被使用。我试着删除那些是导致这一问题的包的一部分较少的文件。越少的文件已成功删除。一旦恢复.LESS文件,这个问题直接浏览到服务器时,就走开了。

To test the thought that the resource might be in use. I tried deleting the less files that were part of the bundle that caused the issue. The less files were successfully deleted. Upon restoring the .less files, the issue went away when browsing directly to the server.

更新3

这个问题刚刚开始开发服务器上突然出现未负载均衡与不使用带点捆绑

This issue just started cropping up on the dev server which is not load balanced with a bundle that is not using dotless

    bundles.Add(new StyleBundle("~/cssbundles/bootstrap")
        .Include("~/Content/bootstrap/bootstrap.css"));

这是因为的NuGet包升级造成和文件不再有人引用的位置中。我仔细检查了所有其他的捆绑,以确保这些文件仍然存在在那里他们被引用,他们这样做,所以这不是问题。

This was caused because of a nuget package upgrade and a file no longer being in the location it was referenced. I double checked all of the other bundles to make sure the files still existed where they were referenced and they do, so that's not the issue.

更新4

添加记录到带点配置和收到此消息:

Added logging to the dotless configuration and received this message:

06-12-2013 16:08:07.814,10.183.130.143,demo.app.com,/cssbundles/bundlecss?v=WN4weCPcGs3GJ_Hgsm2B7qNotYNgbrMS6xwEt8SWK6M1,user@email.com,"
directive block with unrecognised format on line 1:
   []: /beginning of file
  [1]: @v: WN4weCPcGs3GJ_Hgsm2B7qNotYNgbrMS6xwEt8SWK6M1;
       ^
  [2]: @import ""~/Content/variables.less"";",Error,""

思考?

推荐答案

发生这个确切的情况( V = [无值] ),因为建立在 .LESS 文件操作值被意外设置为。这发生,因为该文件被添加到项目中一个不寻常的方式,然后重命名为 .LESS 。由于VS.NET不知道原来的文件类型,它设置它是属性生成操作

This exact scenario occurred (v=[no value]) because the Build Action value on the .less file was accidentally set to None. This happened because the file was added to the project in an unusual way and then renamed to .less. Since VS.NET didn't know originally the file type it set it's property for Build Action to none.

确保 .LESS 文件都有生成操作配置设置为编译,从而使实际的文件包含在构建中。这也是为什么因为这将是present不会发生局部的问题,但一旦部署它将会丢失。

Make sure the .less file has its Build Action configuration set to Compile, thus allowing the actual file is included in the build. This is also why the problem will not occur locally as it will be present, but once deployed it will be missing.

这篇关于使用MS捆绑空包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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