【问题标题】:Cassette bundle not linking every stylesheet in the folder, only 1盒式磁带包没有链接文件夹中的每个样式表,只有 1
【发布时间】:2012-10-24 16:18:38
【问题描述】:

这是我的文件夹在 Visual Studio 2010 中的设置方式:

[solution]/Public
              /assets
                  /stylesheets
                      bootstrap.css
                      forms.less
                      main.less
                      tigo.less

我设置了一些引用,因为我希望 Bootstrap 首先出现,forms 和 tigo 必须出现在 main.less 之后。

当我在本地机器上运行这个应用程序时,这是参考:

<link href="/cassette.axd/asset/Public/assets/stylesheets/bootstrap.css?Fr-zb2zZgNbHEFtP2LHSlWzPcTc=" type="text/css" rel="stylesheet"/>
<link href="/cassette.axd/asset/Public/assets/stylesheets/main.less?3YJKuT131pux5i9cKZkQeAO_qLQ=" type="text/css" rel="stylesheet"/>
<link href="/cassette.axd/asset/Public/assets/stylesheets/forms.less?3j_M5YCMRn_e3APdf8XOLJrN9s0=" type="text/css" rel="stylesheet"/>
<link href="/cassette.axd/asset/Public/assets/stylesheets/tigo.less?L6L9pztQ4BxBKmO_Q3XHBJx9L8Q=" type="text/css" rel="stylesheet"/>

它在我的机器上运行良好。

但是,当发布到 AppHarbor 时,引用(缩小的)CSS 文件仅包含来自 bootstrap.css 的信息

这是我对 Cassette 的配置:

namespace Foo.WebUI
{
    /// <summary>
    /// Configures the Cassette asset bundles for the web application.
    /// </summary>
    public class CassetteBundleConfiguration : IConfiguration<BundleCollection>
    {
        public void Configure(BundleCollection bundles)
        {
            bundles.Add<StylesheetBundle>("Public/assets/stylesheets");
            bundles.Add<ScriptBundle>("Public/assets/javascripts");
        }
    }
}

这是我的 _Layout.cshtml 文件:

@{
    Bundles.Reference("Public/assets/stylesheets");
    Bundles.Reference("Public/assets/javascripts");
}
<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
    <link rel="Stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/blitzer/jquery-ui.css" />

    @Bundles.RenderStylesheets()
</head>

任何想法为什么它不能正常工作?为什么它抓取了 bootstrap.css 而忘记了其他三个文件。

【问题讨论】:

    标签: c# asp.net-mvc-3 appharbor cassette


    【解决方案1】:

    似乎在他们的支持论坛上讨论了类似的问题:

    http://support.appharbor.com/discussions/problems/3876-appharbor-does-not-serve-my-less-files

    总结,less build 文件在项目中没有正确设置,设置每个less文件的属性,将 Build Action 设置为 Content,然后将 Copy To Output DIrectory 值设置为 Copy always。

    【讨论】:

    • 随机,大约一个小时没碰它后,我重新登录,它现在可以工作了。让我们假设这是解决方案,并且必须在 AppHarbors 端清除一些缓存。谢谢!
    • 您好,我只是想澄清一下,AppHarbor 不会缓存超出您的应用程序本身所做的任何内容的内容。如果您的站点被列为已部署,AppHarbor 会为已部署的构建提供内容。
    猜你喜欢
    • 1970-01-01
    • 2020-03-14
    • 2012-03-13
    • 2015-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-09
    相关资源
    最近更新 更多