Domanda

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?

È stato utile?

Soluzione

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

Altri suggerimenti

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top