发布网站不会更新我的CSS包 [英] Publishing a website is not updating my CSS bundles

查看:112
本文介绍了发布网站不会更新我的CSS包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我以发布模式从Visual Studio中运行代码并查看捆绑的样式表时,可以在捆绑中查看对CSS文件的更新。但是,当我将网站发布到服务器或本地计算机时,样式表中的更改还没有通过。捆绑的样式表仍然是旧样式表。

When I run my code from Visual Studio in release mode, and check the bundled style sheet, I can see my updates to the css files in that bundle. However when I publish the website to the server or my local machine, my changes in the style sheets have not come through. The bundled style sheet is still the old one.

我尝试了IIS重置,干净的构建/重建,从IIS文件夹中删除了所有文件并重新发布。

I have tried an IIS reset, a clean build/rebuild, deleted all files from the IIS folder and re-published.

如果有任何不同,我正在使用LESS。

I am using LESS if that makes any difference.

我的捆绑包配置:

bundles.Add(new StyleBundle("~/bundles/requiredStyles").Include(
    "~/Content/Style/Libs/bootstrap.min.css",
    "~/Content/Style/Libs/font-awesome.min.css",
    "~/Content/Style/Globals/application.css",
    "/Content/Style/Libs/muliDropdown.css",
    "~/Content/Style/Libs/smoothDivScroll.min.css",
    "~/Content/Style/Libs/jasny-bootstrap.min.css"
));

我正在通过访问 http://www.mywebsite.com/bundles/requiredStyles

所以我进行了更改在application.css中,如果我在Visual Studio中(在发布模式下)打游戏就可以了,但是当我发布到本地IIS时,我的更改就不再存在。

So I made a change in application.css which is fine if I hit play in visual studio (in release mode), but when I publish to my local IIS, my change is no longer there.

推荐答案

如果您在未压缩文件所在的目录中拥有css文件的压缩版本,则会发生这种情况。

This can happen if you have a minified version of a css file in the same directory as your unminified file.

例如,如果您有以下文件:

For example, if you have the following files:



    ~/Content/bootstrap.css
    ~/Content/bootstrap.min.css

在您的目录中,然后将 bootstrap.css文件注册到优化程序包中将首先尝试在发布过程中使用 bootstrap.min.css文件。如果仅更新 bootstrap.css文件,而不更新 bootstrap.min.css文件,则将从 bootstrap.min.css获得旧样式。您可以通过删除 bootstrap.min.css文件或更新文件来解决此问题。

in your directory, and you register the "bootstrap.css" file in your bundle, the optimizer will first attempt to use the "bootstrap.min.css" file during publish. If you only updated the "bootstrap.css" file and did not update the "bootstrap.min.css" file, you will get the old styles from "bootstrap.min.css". You can fix this problem by deleting the "bootstrap.min.css" file or by updating it.

在调试版本中不会发生这种情况,因为它不会拉最小化的文件(如果您的编译设置为使用以下调试工具):

This does not happen in a debug build because it does not pull the minified files if your compilation is set for debug using the following:

<system.web>
    <compilation debug="true" />
    <!-- Lines removed for clarity. -->
</system.web>

您也可以通过禁用优化来覆盖web.config设置通过:

You can also overwrite the web.config setting by disabling the optimizations via:



    BundleTable.EnableOptimizations = false;

这将放入BundleConfig.cs文件中。

This would go inside your BundleConfig.cs file.

这篇关于发布网站不会更新我的CSS包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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