Search code examples
build-processdurandal

Durandal.js .NET VS2012 How to use Weyland in build process


I'm using the VSIX Durandal template (version 2.0). The previous version (1.2) had an optimizer.exe which could be run as part of the build process. I think Weyland has replaced this but I'm not sure how I can get this running as a build step in release mode.


Solution

  • Here's how I do it:

    if $(ConfigurationName) == Release (
      cd "$(ProjectDir)"
      attrib -R App\main-built.js
      weyland build
    )
    

    I like to clear the read-only flag just in case main-built.js is put in source control, but you may not need that line.

    Note: If the build fails (or you don't have node and weyland installed), then refer to the following page for more info: https://github.com/BlueSpire/Durandal/issues/254

    Update:

    To setup npm to use an authenticated proxy, try these commands in an elevated command prompt (last 2 may not be necessary, but are useful for other tools):

    npm config set proxy http://username:password@proxy:8080 
    npm config set https-proxy http://username:password@proxy:8080
    setx http_proxy http://username:password@proxy:8080 /M
    setx https_proxy http://username:password@proxy:8080 /M
    

    Then restart Visual Studio (or reboot). I think some might need to use https in the urls. If username or password contains @, then surround with quotes like this: http://"username:p@assword"@proxy:8080