Handling common JavaScript files in Visual Studio 2010

前端 未结 9 818
说谎
说谎 2020-12-02 15:31

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).

9条回答
  •  青春惊慌失措
    2020-12-02 16:01

    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

    1. In the project that is going to 'import' the common code, I simply add the common .js file 'As Link' within /Assets/js/.
    2. Go to that new addition's Properties and set 'Copy to Output Directory' to 'Copy if newer'.
    3. Now I simply edit the project's post-build event command line to the following: 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.

提交回复
热议问题