We’re beginning work on a couple of fully JavaScript-dependent web apps (our previous apps have been ASP.NET MVC, with JavaScript ‘goodness’ sprinkled over-the-top).
We have a few files that will be shared across the board, and it would be nice to store these files in a Common project, and ‘Add As Link’ them into individual projects (as would be possible with compiled code).
Obviously this doesn’t work with something like JavaScript as the file isn’t actually ‘there’ in the correct location.
Does anyone have any suggestions on keeping a single version of a shared JavaScript file, for use across multiple projects?
In the end, this is how I’ve achieved it. It may not be to everyone’s taste – but worked a treat for me.
Note: In all of our projects, static resources are in a root directory called ‘Assets’, so for example JavaScript is always in /Assets/js/ and CSS /Assets/css/.
Solution
xcopy /Y /E “$(TargetDir)\Assets” “$(ProjectDir)\Assets”
When the project builds, it copies the imported files to \bin\Assets\js – the post-build event then takes a copy of those over to the project directory – in time for the site to use them.