c# - 发布网站并没有更新我的 CSS 包

标签 c# css .net visual-studio-2013 publishing

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

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

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

我的包配置:

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 检查捆绑的 CSS

所以我对 application.css 进行了更改,如果我在 visual studio 中点击播放(在 Release模式下),这很好,但是当我发布到我的本地 IIS 时,我的更改不再存在。

最佳答案

如果您在与未缩小文件相同的目录中有缩小版本的 css 文件,就会发生这种情况。

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


    ~/Content/bootstrap.css
    ~/Content/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 设置:


    BundleTable.EnableOptimizations = false;

这将进入您的 BundleConfig.cs 文件。

关于c# - 发布网站并没有更新我的 CSS 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28470331/

相关文章:

c# - 关于处理 DataContext 和 DataBind()

c# - 大型集合的 LINQ 性能

c# - 'System.String'类型参数转换为 'System.Web.Mvc.SelectListItem'类型参数失败

C# lambda 和数组中的升序值

css - Woff 开放式字体在本地不起作用?

jquery - 用半透明 PNG 覆盖 <A>

javascript - 如何为所有实例设置相同的子组件动态宽度?网络组件

c# - 代码 : TokenNotFound Message: User not found in token cache. 可能服务器已重新启动

c# - 如何在 visual studio (C#) 中使用 webView 功能

c# - 我应该使用 AutoMapper 从 ViewModel 到 Model 对象吗