Reputation: 18857
How do I force Visual Studio 2012 to always use the most recent version of the generated JavaScript file created by TypeScript?
I am using the following definition in my project file:
<Target Name="BeforeBuild">
<Exec Command=""$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc" -out scripts\app.js scripts\app.ts -target ES5 @(TypeScriptCompile ->'"%(fullpath)"', ' ')" IgnoreExitCode="true" />
</Target>
When I clean and rebuild the project, app.js is updated accordingly.
However, for some strange reason, when I try to debug the solution using Internet Explorer, Visual Studio is using an outdated version of app.js, which invalidates my breakpoints.
What is going on here?
Upvotes: 2
Views: 1323
Reputation: 251012
The most likely problem here isn't really TypeScript or JavaScript - Internet Explorer is just caching the JavaScript file and using the out-dated version.
If you are referencing an individual script, you can cache-bust it by changing an arbitrary part of the URI:
<script src="myscript.js?1"></script>
If you increment the 1 each time you want to replace the cached version, it will cause the new script to be loaded. You could automate this by dumping a timestamp in place of the 1.
If you are using bundling, which I recommend in MVC4, the bundler will append a hash of the scripts, which does the same thing.
Upvotes: 4