private BundleMap LoadBundles(Context context, string type, string template)
		{
			var bundleFiles = context.Bundles
				.Where(b => b.EndsWith("." + type + ".bundle", StringComparison.OrdinalIgnoreCase))
				.ToList();

			var map = new BundleMap(bundleFiles.Count);
			foreach (var bundleFile in bundleFiles)
			{
				try
				{
					var bundle = new Bundle(context, bundleFile);
					Log.LogMessage("Bundle: " + bundleFile);
					Log.LogMessage("\tType: " + type);
					Log.LogMessage("\tKey: " + bundle.Key);
					Log.LogMessage("\tMinify: " + bundle.Minify);
					Log.LogMessage("\tOutputDirectory: " + bundle.OutputDirectory);

					if (context.DebugBuild)
					{
						var html = new StringBuilder();
						foreach (var file in bundle.Files)
						{
							html.AppendFormat(template, file.Url);
							Log.LogMessage("\tFile: " + file.Path);
							Log.LogMessage("\t\tUrl: " + file.Url);
						}
						bundle.Html = html.ToString();
					}
					else
					{
						bundle.Html = String.Format(template, bundle.BundleFile.Url);
						Log.LogMessage("\tUrl: " + bundle.BundleFile.Url);
					}

					map.Add(bundle.Key, bundle);
					Log.LogMessage("Found bundle '{0}':\r\n{1}", bundle.Key, bundle.Html);
				}
				catch (Exception ex)
				{
					Log.LogError("Failed to load or parse bundle file '{0}'\r\n{1}", bundleFile, ex);
				}
			}

			return map;
		}
		public File(Context context, Bundle bundle, string path)
		{
			var fullPath = PathHelper.GetFullPath(context.ProjectDirectory, path);
			if (!context.DebugBuild && bundle.Minify)
			{
				fullPath = File.ExtensionRegex.Replace(fullPath, ".min.${type}");
			}

			Path = fullPath;

			_url = new Lazy<string>(() =>
			{
				var url = PathHelper.GetAbsoluteUrl(context.WebRootDirectory, fullPath);

				if (bundle.AddVersionQuery)
				{
					var hash = PathHelper.GetHash(fullPath);
					url += "?_v=" + hash;
				}

				return url;
			});
		}