Search code examples
.netnode.jsmsbuildcompressionuglifyjs

Node JS and MS Build - Is This Possible?


I am writing MS Build task for JavaScript compression and I hoped I could use Uglify as my compression provider.

Since Uglify is written in JavaScript I obviously needed a .NET port. Fortunately, there seem to be at least two possible options - Uglify CS and Uglify.NET. Unfortunately both haven't seen a single commit in the last year therefore I suppose they don't support the new version 2 of Uglify :)

Having this in mind I was wondering is there a way to somehow eval the original code from a .NET build task? Or more generally said, is there a way to invoke Node.JS from .NET?

I can imagine calling Node.JS service from my task, however, this seems to be an overkill.


Solution

  • I have done this in a build task (pre-build is probably what you want.) Simply add a call to node "my-script-to-uglify.js", and every time you build... presto!

    Also, in my case I actually included a node binary in the project (all devs were on same architecture, not all had node)