I want to use the SquishIt nuget package inside and MVC3 application that is running on Windows Azure. I'm using SquishIt for CSS and JS combination and minification.

In my Views/Shares/_Layout.cshtml I have the following lines:

@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"))

This results in an

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

I found something here http://www.bondigeek.com/blog/2011/03/22/all-is-quiet-not-on-the-azure-front/ but this is actually not what I want. In general it should be possible for SquishIt to write on the disk of the Azure VM, but probably the directory is wrong or the security rights are insufficient. Any idea?

有帮助吗?

解决方案

In Azure VM, you cannot write to file system directly. You have to configure SquishIt to keep bundles in memory.

See this page for more details: Using SquishIt programmatically without the file system

其他提示

You can use It on azure but you need to add a Start-up Script in the web role that will set proper Permission on the Directory that you write to:

Those are the Steps:

  1. Add a new folder to the web project , I prefer to call it App_Startup
  2. Add new Bat File called enableWritePermissions.cmd
  3. Add the Permission Command: icacls %~dp0..\scripts /grant "NETWORK SERVICE":(OI)(CI)RX
  4. Add a start-up Script to the web role by adding the ServiceDefinition.csdef of the Azure Project in the Sites Tag <Startup> <Task commandLine="App_Startup\enableWritePermissions.cmd" executionContext="elevated" taskType="background" /> </Startup>

That's all , you have a Write permission in the \scripts directory and you can use the Minimization freely.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top