Question

I was getting 404 Not found for the main-built.js file when I was running my DurandalJS SPA application published in release mode on a web server.

404 Not Found: main-built.js

So I figured out I needed to run the optimizer.exe to generete the missing file main-built.js

Is it possible to include the execution of optimizer.exe as part of Visual Studio 2012 build/publish process? If yes, how do I do that?

Thanks

Was it helpful?

Solution

I added the optimizer step as a Pre Build step.

So in the Pre Build Events box in the project properties of your web project I added this:

cd $(ProjectDir)App\durandal\amd

optimizer.exe

main-built.js is then generated as part of the build process.

Note you will probably have to add the main-built.js file to your project for it to be deployed automatically if you are using msdeploy. I had to do this because we are using TFS hosted build service with automatic Azure publishing. Without this step the file was not being deployed.

OTHER TIPS

Here is what I did:

Place these lines of code into Post Build Events

cd $(ProjectDir)App\durandal\amd
optimizer.exe

The main-built.js will be created under \App after the solution is built but it is not included in the project. I then select Show All Files and include the file.

Then the main-built.js will be available every time I publish the web app in the future.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top