2

I am trying to use the bundles feature in ASP.NET MVC in my project, everything works great in my local, if I switch the compilation debug property to false I can see that the bundle is being generating with a version (v=XXXXXXX) and my application keeps working.

When I deploy the application to a server and request the page, the bundle is there but the v= value is empty. Is there anything I am missing?

<script src="/bundles/bundlename?v="></script>
axy108
  • 537
  • 2
  • 4
  • 14
  • I had a similar problem a long time ago that I was never able to solve; I ended up switching less parsers. Here is that question: http://stackoverflow.com/questions/20135051/empty-bundle-using-ms-bundling – drneel Jan 12 '16 at 20:21

3 Answers3

2

One of the possible cases you have is with optimization side of bundles. I had the same issue with my scripts and styles when I started to use minified versions. For example, if I specified in bundle configuration with .min.js file then you can fall into problem when optimization framework minifies already minified script(s). And it also occurs only in release mode. I solved it with BundleTable.EnableOptimizations = false; in BundleConfig.cs file after all bundles' configs

Andrew
  • 1,474
  • 4
  • 19
  • 27
  • I am not using min version in the bundle, but I commented the BundleTable.EnableOptimizations = false; line of code, let me try adding it back to see if that helps. – axy108 Jan 12 '16 at 20:57
  • Try multiple combinations and it didn't help... I will keep trying and go back if I get something. – axy108 Jan 12 '16 at 22:51
1

I think you miss specific root path since locally its not the same vs server side. Why don't you use the script helper from the framework:

@Scripts.Render("~/bundles/bundlename")
ataravati
  • 8,891
  • 9
  • 57
  • 89
DarkVision
  • 1,373
  • 3
  • 20
  • 33
  • That is how I'm doing it the tag I put above is the output from the bundle in the server. – axy108 Jan 12 '16 at 20:48
  • what your BundleConfig.cs for bundlename look like ? – DarkVision Jan 12 '16 at 21:03
  • also the post Andrew in his post talk about BundleTable.EnableOptimizations if you use it don't forget set debug to false in web.config could cause a lot of problem – DarkVision Jan 12 '16 at 21:15
  • bundles.Add(new ScriptBundle("~/bundles/veyron").Include( "~/Scripts/script1.js", "~/Scripts/script2.js", "~/Scripts/script3.js", "~/Scripts/script4.js", "~/Scripts/scrip5.js" )); – axy108 Jan 12 '16 at 22:56
  • I have nothing special in the bundle definition – axy108 Jan 12 '16 at 23:00
  • i suggest you try just with one script at a time remove the others and test see if maybe they something wrong with the script js. and add it one by one. if it not still work have you put debug="false" before push the website to the server ?. Also verify (new ScriptBundle("~/bundles/veyron") is not call more than once in your bundle because its represent a unique key for each bundle. – DarkVision Jan 13 '16 at 00:32
0

I found the issue, after trying everything I went back an check the build scripts on the TFS server, we have continuous integration configured, turns out the build server was removing the .js and only letting the .min.js files on the final build. I removed that instruction and it started working.

Basically the .js did not exist on the server so there was nothing to bundle.

Thank you guys for your help!

axy108
  • 537
  • 2
  • 4
  • 14