1

我想使用里面的 SquishIt nuget 包和在 Windows Azure 上运行的 MVC3 应用程序。我正在使用 SquishIt 进行 CSS 和 JS 的组合和缩小。

在我的 Views/Shares/_Layout.cshtml 我有以下几行:

@MvcHtmlString.Create(
    Bundle
    .Css()
    .Add("~/Content/templates/style.css")
    .Add("~/Content/market.css")
    .Add("~/Content/jquery-ui-theme/jquery-ui-1.8.17.custom.css")
    .ForceRelease()
    .Render("/Cache/combined-css_#.css"))

这导致一个

"System.IO.IOException: Unable to open file"

我在这里找到了一些东西http://www.bondigeek.com/blog/2011/03/22/all-is-quiet-not-on-the-azure-front/但这实际上不是我想要的。一般情况下,SquishIt 应该可以写入 Azure VM 的磁盘,但可能是目录错误或安全权限不足。任何想法?

4

2 回答 2

4

在 Azure VM 中,不能直接写入文件系统。您必须配置 SquishIt 以将包保存在内存中。

有关更多详细信息,请参阅此页面:在没有文件系统的情况下以编程方式使用 SquishIt

于 2012-04-21T18:40:21.387 回答
2

您可以在 azure 上使用它,但您需要在 Web 角色中添加一个启动脚本,该脚本将为您写入的目录设置适当的权限:

这些是步骤:

  1. 为 web 项目添加一个新文件夹,我更喜欢将其命名为 App_Startup
  2. 添加名为 enableWritePermissions.cmd 的新 Bat 文件
  3. 添加权限命令:icacls %~dp0..\scripts /grant "NETWORK SERVICE":(OI)(CI)RX
  4. 通过在 Sites Tag 中添加 Azure 项目的 ServiceDefinition.csdef,将启动脚本添加到 Web 角色 <Startup> <Task commandLine="App_Startup\enableWritePermissions.cmd" executionContext="elevated" taskType="background" /> </Startup>

就是这样,您在 \scripts 目录中具有写入权限,您可以自由使用最小化。

于 2012-11-17T16:54:30.300 回答