Search code examples
asp.net-mvc-3google-chrome-devtoolslivereload

Tincr for ASP.NET MVC 3


I am trying to use the tincr extension in Chrome. It allows you to refresh CSS and JavaScript without having to reload the page again. I'm having some trouble getting it working.

My Setup

Source code root directory: C:\dev\tfs\MyApp\Development Branches\3.3.0.0\Presentation\MyApp.

IIS website directory points to the root directory above. The Scripts directory underneath the folder path above contains the js files that I am changing.

I created a tincr.json file and put it in the root directory

tincr.json

{
    "toFile" : [],
    "fromFile" : [
        {"from": "C:\\\\dev\\\\tfs\\\\MyApp\\\\Development Branches\\\\3.3.0.0\\\\Presentation\\\\MyApp\\\\Scripts\\\\(.+\\.js)",
         "to": "http://localhost/MyApp/Scripts/$1"}
    ]
}

Is this correct? How can I get tincr working with ASP.NET MVC 3?


Solution

  • After playing around and reading google groups and other web sites I pieced together the following

    • Tincr does not work with query parameters in windows (eg. common.js?var=1 will fail)
    • You need to be careful of ajax queries that append to the url for js files that come from references to ajax code. Use Fiddler and watch the URLS. I had to make sure that the js file was added to the _Layout.cshtml file and then it would come out without query parameters.

    I put a more detailed how to for Tincr on my website http://aboutdev.wordpress.com/2013/01/26/using-tincr-with-asp-net-mvc-in-windows-7/ but here is what you need.

    The tincr.js file I used looks as follows:

    {
        "toFile" : [],
        "fromFile" : 
        [
            {
                "from": "\\\\Scripts\\\\([a-zA-Z]+)\\.js",
                "to": "/MyApp/Scripts/$1.js"
            }
        ]
    }
    

    This file does not update the file on disk because 'tofile' is not filled in. This file will look for files in the Scripts directory that is directly under the root where you put your tincr.json file.

    I hope this helps you with using Tincr in your pojects.