Domanda

There's a pretty spectacular example a DurandalJS based, ASP.NET MVC 5 backed SPA over at:

https://durandalauth.azurewebsites.net/

There's a problem with it, though, is the Weyland powered optimization fails for Visual Studio's Post-Build events with a message like the below

enter image description here

Which is strange because the post build event is this:

cd $(ProjectDir)
weyland build

Which when executed from the command line works just fine:

enter image description here

Why would this be? I've search all over the net and all I keep finding are references to a similar but (perhaps) an unrelated problem where an additional line of the config

"insertRequire: ['main'],"

[EDIT]

I'm using Visual Studio 2013 Pro Update 2, no plugins.

I've git clone'd the latest project from DurandalAuth on GitHub using this url:

git clone https://github.com/yagopv/DurandalAuth.git

You can see the project here: https://github.com/yagopv/durandalauth

I'm using this in my post-build event in visual studio:

cd $(ProjectDir)
weyland build

My output from my build can be found at this pastebin: http://pastebin.com/ezpTEPk7

Everything I'm doing has zero modifications from the original project as seen from a Git Clone.

È stato utile?

Soluzione

When you look at your build output you'll find several lines like

ERR! jshint Found 52 issues while linting ....

You'll also find lines like

WARN: Dropping unused ....

While these are not showstoppers regarding to execution they cause the build to return fail.

This is why Visual Studio reports a failed build.

EDIT

I did some major cleanup using ReSharper.

To completely ignore your .js files - you could remove .task.jshint from the weyland-config.js

Also to mention is the fact that your main-built.js does not get uglified with shipped weyland-config.js

In the first .task.uglify add an exclude for the App/mail-built.js and add a new .task.uglify as the last task. This path to main-built.js must be prepended with ../ since the path is relative to build folder.

Also found issues in when debug=false in web.config Haven't resolved that yet.

My weyland-config.js looks like this:

exports.config = function(weyland) {
    weyland.build('main')
        .task.jshint({
            include: 'App/**/*.js',
            exclude: 'App/main-built.js'
        })
        .task.uglifyjs({
            include: ['App/**/*.js', 'Scripts/durandal/**/*.js'],
            exclude: 'App/main-built.js'
        })
        .task.rjs({
            include:['App/**/*.{js,html}', 'Scripts/durandal/**/*.js'],
            loaderPluginExtensionMaps:{
            '.html':'text'
        },
        rjs: {
            name:'../Scripts/almond-custom', //to deploy with require.js, use the build's name here instead
            insertRequire: ['main'], //not needed for require
            baseUrl: 'App',
            wrap:true, //not needed for require
            paths: {
                'text': '../Scripts/text',
                'durandal': '../Scripts/durandal',
                'plugins': '../Scripts/durandal/plugins',
                'transitions': '../Scripts/durandal/transitions',
                'knockout': '../Scripts/knockout-3.1.0',
                'bootstrap': '../Scripts/bootstrap',
                'jquery': '../Scripts/jquery-2.1.1',
                'jquery.utilities': '../Scripts/jquery.utilities',
                'toastr': '../Scripts/toastr',
                'stashy': '../Scripts/stashy'
            },
            inlineText: true,
            optimize: 'none',
            pragmas: {
                build: true
            },
            stubModules: ['text'],
            keepBuildDir: true,
            out:'App/main-built.js'
        }
    })
    .task.uglifyjs({
        include: ['../App/main-built.js']
    });
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top