Using System.web.optimization; Visual Studio For Mac

Active1 year, 7 months ago
  1. X Code
  2. Visual Studio For Mac
  3. Visual Studio For Mac Tutorial
  4. Visual Studio For Mac Download
  5. Visual Studio
  6. Visual Studio For Mac Os
  7. Using System Web Optimization Visual Studio For Mac
  8. Microsoft Visual Studio For Mac
X code

X Code

Aug 31, 2015  This video shows how you can run Microsoft Visual Studio and Microsoft SQL Server on a Mac OSX machine using Virtualization Technology such as Parallels for Desktop. May 10, 2017  It can also be published using Visual Studio for Mac’s Archive feature, or using Apple’s Application Loader app (that is installed with Xcode). This is one of the benefits of sharing the same solution and project structure on Mac and Windows.

I'm trying to use the new bundling feature in a project I recently converted from MVC 3 to MVC 4 beta. It requires a line of code in global.asax, BundleTable.Bundles.RegisterTemplateBundles();, which requires using System.Web.Optimization; at the top.

When I do this, I get the red squiggly lines that say, 'Are you missing an assembly reference?' When I try and add reference, and click on the .NET tab in the dialog, sort from A-Z, I do not see System.Web.Optimization.

How do I add this ref to my project? Thanks.

Hao Kung
26.2k6 gold badges78 silver badges91 bronze badges
Ian DavisIan Davis
8,22523 gold badges73 silver badges121 bronze badges

7 Answers

The Microsoft.Web.Optimization package is now obsolete. With ASP.NET (MVC) 4 and higher you should install the Microsoft ASP.NET Web Optimization Framework:

  • Install the package from nuget:

  • Create and configure bundle(s) in App_StartBundleConfig.cs:

  • Call the RegisterBundles() function from Application_Start() in your global.asax.cs:

  • In your view.cshtml include the Optimization namespace and render the bundle(s):

See http://www.asp.net/mvc/overview/performance/bundling-and-minification for more information

Update
Version 1.1.x is available, read the release notes: https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization

mhumhuVisual
16k8 gold badges50 silver badges77 bronze badges

With the final released version of ASP.Net MVC 4 the approach is as follows:

  • Install Microsoft.AspNet.Web.Optimization via nuget (as it is not installed by the framework)

  • Create the bundle in Global.asax Application_Start:

  • Add the 'System.Web.Optimization' namespace to the 'Views' web.config:

  • In your view.cshtml add an include to the bundle created in the last step:

In debug mode, all script files in your directory will render individually; in release mode they will be bundled and minified.

Liam
17.3k16 gold badges80 silver badges133 bronze badges
Noel AbrahamsNoel Abrahams
6,3243 gold badges27 silver badges31 bronze badges

Update (reinstall) the package from nuget, you can use the command:

update-Package Microsoft.AspNet.Web.Optimization -reinstall

Mike Elofson
1,8771 gold badge6 silver badges16 bronze badges
M. SalahM. Salah

In my case it was a tfs issue, since tfs exclude binaries, so the Nugget PM find the nugget installed and don't update the library If you have similar issue :

  • Go to source control
  • Navigate to the ..packagesMicrosoft.Web.Optimization
  • Add lib folder (uncheck the exclude binary extensions)
  • Update your solution and add the dll reference from the path

NB : the package folder is in the same level of yousolution.sln file

Visual Studio For Mac

amineamine

Using nuget to uninstall System.Web.Optimization in the package manager console like this:

Uninstall-Package Microsoft.AspNet.Web.Optimization

Then reinstalling using:

Install-Package Microsoft.AspNet.Web.Optimization

May solve this problem for you.

Visual Studio For Mac Tutorial

MyziferMyzifer
8131 gold badge18 silver badges52 bronze badges

Visual Studio For Mac Download

Install it from NUGet through Visual Studio Open Visual Studio 2010 , select Tools-> Library Package Manager-> Package Manager Console

This will open the conslve, paste

Visual Studio

and enter. and you are done

Visual Studio For Mac Os

MianMian

set in Global.asax application_start (in RELEASE mode etc.) :

Using System Web Optimization Visual Studio For Mac

to enable minification and change to false in DEBUG mode to render all script and style files individually.

zenichizenichi

Microsoft Visual Studio For Mac

Not the answer you're looking for? Browse other questions tagged asp.net-mvc-4asp.net-optimization or ask your own question.