gpt4 book ai didi

CSS 文件未从 MVC 站点中的 bundle 中部署

转载 作者:行者123 更新时间:2023-11-28 04:34:03 24 4
gpt4 key购买 nike

Bundle 对我来说是新的,但在我的 _layout.cshtml 文件中我有以下内容:

@Styles.Render("~/Content/css")

在 App_Start\BundleConfig.cs 文件中我有以下内容:

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css",
"~/Content/Portal.css"));

当我通过从 Visual Studio 启动它来查看本地主机上的站点时,所有样式都被插入,如下所示:

<link href="/Content/bootstrap.css" rel="stylesheet"/>
<link href="/Content/site.css" rel="stylesheet"/>
<link href="/Content/Portal.css" rel="stylesheet"/>

但是,当我部署到测试服务器时,标记中没有包含 portal6.css 文件,实际上甚至没有复制到我的发布目录中。我手动将该 CSS 文件复制到 Content 文件夹,但似乎包中没有引用它。

有人知道问题出在哪里吗?

最佳答案

...in fact was not even copied into my Publish directory. I manually copied that CSS file to the Content folder...

听起来这只是在元素文件属性中将元素文件的 Build Action 标记为 Content 的情况 - 否则,它不会像您一样“发布”已经注意到/声明。

查看 portal.css 属性:

  • 选择文件
  • 然后 F4 ALT + ENTER
  • 在 Properties 选项卡/窗口中检查 Build Action 是否设置为 Content(很可能它已设置为 None “手动复制”)

    sample properties of font-awesome.css
    一些需要“发布”的 css 文件 (font-awesome.css) 的示例 View

注意:假设文件“包含在元素中”(而不仅仅是在文件系统中)- 因此它应该在 VS 的元素 View 中可见(没有启用“查看所有文件”切换)。

嗯...

关于CSS 文件未从 MVC 站点中的 bundle 中部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41580975/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com