It should be possible - when you enable webgrease using NuGet, you also get the βWGβ command line tool, which does exactly what you are trying to accomplish above. Code for the webgrease dll and WG utilities are available on CodePlex . There are no specific ASP.Net DLL references.
If you have ILSpy or Reflector, see the code for "WebGrease.Program.ProcessJsFileSet" for how to compress Javascript. The WebGrease.Activities.MinifyJSActivity class is the one you need to use, and you can also see it on CodePlex.
source share