"Web Compiler" compile on save not working
Sadly, the solution offered here did not work. Seems I'm not alone in this.
In case it helps anyone else, I found another workaround, which seems to offer an extra side benefit.
If you add a Razor view to your project (I named it JsHelper.cshtml
and added it in \Views\Shared
) and use the following for the contents (extra line breaks added to make it fit in the SO width)...
@model string
@{
string ext = HttpContext.Current != null
&& HttpContext.Current.Request.Url.Host.Contains("localhost")
? ""
: ".es5.min";
}
<script src="/Scripts/@Model@(ext).js" type="text/javascript"></script>
...then instead of adding script tags like this...
<script src="/Scripts/General.es5.min.js" type="text/javascript"></script>
...you can add this...
@Html.Partial("~/Views/Shared/JsHelper.cshtml", "General")
When you are running the web site in Visual Studio, the uncompiled version of the Javascript file will be used. When running anywhere else (eg on the production server), the .es5.min.js
version will be used.
As publishing a web project involves building it, which will compile the .js files, you can be confident that the compiled and minified files that are published are up-to-date.
This has the side-benefit that when debugging your scripts in the browser, you have access to the full version of the .js
file, instead of the compiled and minified version that you would get if you referenced them directly. As another breaking change that occurred in the latest version of Web Compiler is that they no longer produce .map.js
files when compiling, this is a huge side benefit.
Hope this helps.
Found the answer in a forum. I just needed to remove some temp files and restart Visual Studio:
%localappdata%\temp\WebCompiler1.xx
Forum post: https://github.com/madskristensen/WebCompiler/issues/158
Hope this helps someone!