Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Web.Optimization and Microsoft.Web.Optimization won't load reference in vs 2012

I'm working on an MVC 4 project started in Visual Studio 2010. Right now I'm working on a machine with Visual Studio 2012 as I don't have access to the machine I was originally working on. I tried all morning to find answers, but they don't seem to help my situation.

I followed How to add reference to System.Web.Optimization for MVC-3-converted-to-4 app and installed from nuget right into my solution. Even though I have all the required reference packages downloaded and installed on my machine, System.Web.Optimization continues to remain missing. Is there anything else I can do?

Edit: When I try to build the project I receive the following errors

  • The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) - BundleConfig.cs
  • The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) - Global.asax.cs
  • The type or namespace 'BundleCollection' could not be found (are you missing a using directive or an assembly reference?) - BundleConfig.cs

My BundleConfig.cs contains

using System.Web; using System.Web.Optimization;  namespace BCCDC_AdminTool {     public class BundleConfig     {      // For more information on Bundling, visit http://go.microsoft.com/fwlink/?    LinkId=254725     public static void RegisterBundles(BundleCollection bundles)     {            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(                     "~/Scripts/jquery-{version}.js"));             bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(                     "~/Scripts/jquery-ui-{version}.js"));              bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(                     "~/Scripts/jquery.unobtrusive*",                     "~/Scripts/jquery.validate*"));          // Use the development version of Modernizr to develop with and learn from. Then, when you're         // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.             bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(                     "~/Scripts/modernizr-*"));              bundles.Add(new StyleBundle("~/Content/css").Include("~/Content/site.css"));              bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(                     "~/Content/themes/base/jquery.ui.core.css",                     "~/Content/themes/base/jquery.ui.resizable.css",                     "~/Content/themes/base/jquery.ui.selectable.css",                     "~/Content/themes/base/jquery.ui.accordion.css",                     "~/Content/themes/base/jquery.ui.autocomplete.css",                     "~/Content/themes/base/jquery.ui.button.css",                     "~/Content/themes/base/jquery.ui.dialog.css",                     "~/Content/themes/base/jquery.ui.slider.css",                     "~/Content/themes/base/jquery.ui.tabs.css",                     "~/Content/themes/base/jquery.ui.datepicker.css",                     "~/Content/themes/base/jquery.ui.progressbar.css",                     "~/Content/themes/base/jquery.ui.theme.css"));         }     } } 
like image 553
MacSalty Avatar asked Apr 23 '13 21:04

MacSalty


People also ask

What is Microsoft Aspnet web optimization?

ASP.NET Optimization introduces a way to bundle and optimize CSS and JavaScript files.

What is Web grease?

WebGrease is a suit of tools that helps is optimizing the static files (like JavaScript, CSS) in a web application. This tool is developed by a performance team in MSN division of Microsoft . Actually It is evolution of the AJAX min library that we are already using.


1 Answers

I had the same problem with a VS2010 project I opened in VS2012. The Microsoft.AspNet.Web.Optimization package was missing so I just needed to download it using Nuget Package Manager.

You can run in the console: Install-Package Microsoft.AspNet.Web.Optimization

like image 50
Jonathan Bick Avatar answered Oct 03 '22 23:10

Jonathan Bick