Pregunta

I used to have a .js file in /Public/javascripts/jquery1.1js.

Everything was working perfectly but then I needed to delete this file from my project, so I just removed it from the solution in Visual Studio.

Now when I visit my application, I get:

Reference error in "~/Public/javascripts/jquery.unobtrusive-ajax.js", line 1. Cannot find "~/Public/javascripts/jquery-1.5.1.js". Reference error in "~/Public/javascripts/jquery.validate.unobtrusive.js", line 1. Cannot find "~/Public/javascripts/jquery-1.5.1.js".

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Cassette.AssetReferenceException: Reference error in "~/Public/javascripts/jquery.unobtrusive-ajax.js", line 1. Cannot find "~/Public/javascripts/jquery-1.5.1.js". Reference error in "~/Public/javascripts/jquery.validate.unobtrusive.js", line 1. Cannot find "~/Public/javascripts/jquery-1.5.1.js".

Here's a stacktrace:

[AssetReferenceException: Reference error in "~/Public/javascripts/jquery.unobtrusive-ajax.js", line 1. Cannot find "~/Public/javascripts/jquery-1.5.1.js".
Reference error in "~/Public/javascripts/jquery.validate.unobtrusive.js", line 1. Cannot find "~/Public/javascripts/jquery-1.5.1.js".]
   Cassette.BundleContainer.ValidateAssetReferences() +387
   Cassette.BundleContainer..ctor(IEnumerable`1 bundles) +41

Granted, I know why this is happening, Cassette is still trying to find the deleted file, but I'm not sure how to tell Cassette: "Hey, this file is no longer relevant. Scan the folder again and rebuild a list of files you need to work with."

But I just don't know how to accomplish this.

The documentation has no mention of this and just implies that it should do this automatically for me.

Here's my Configuration class:

using Cassette.Configuration;
using Cassette.Scripts;
using Cassette.Stylesheets;

namespace XXX.WebUI
{
    /// <summary>
    /// Configures the Cassette asset modules for the web application.
    /// </summary>
    public class CassetteConfiguration : ICassetteConfiguration
    {
        public void Configure(BundleCollection bundles, CassetteSettings settings)
        {
            bundles.AddPerIndividualFile<ScriptBundle>("Public/javascripts/");
            bundles.AddPerIndividualFile<StylesheetBundle>("Public/stylesheets/");
        }
    }
}

And in my _Layout.cshtml file:

@{
    Bundles.Reference("Public/javascripts/site.js");
    Bundles.Reference("Public/javascripts/jquery.validate.unobtrusive.js");
    Bundles.Reference("Public/stylesheets/site.less");
}
<!DOCTYPE html>
    ...

    <head>
        <title>@ViewBag.Title</title>
        @Bundles.RenderStylesheets()

            ...
        @Bundles.RenderScripts()
    </body>
¿Fue útil?

Solución

Does the jquery.validate.unobtrusive.js file contain a JavaScript reference at the top to jquery-1.5.1.js?

The line would look like:

 /// <reference path="jquery-1.5.1.js" />

If so, remove that line. Cassette uses those references to determine build order.

ref: http://getcassette.net/documentation/scripts

Otros consejos

This can also happen if you reference files with the same root

e.g. easyXDM.js and easyXDM.debug.js

When you reference easyXMD.js it gives the exception and the solution seems to be use a different naming convention that ensures the roots are different such as easyXMDdebug.js.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top