Sean Holmesby

.NET and Sitecore Developer

By

CopySauce, a file Copying Utility for Sitecore Development

A while ago a good friend of mine, Dave Nicolson, created a utility that assists front-end developers with Sitecore development. The tool watches changes to front-end files in your Source directory, and copies them over to your Website directory….saving the need for a full Visual Studio build, and thus, no App Pool recycle.

Download CopySauce here.

Note: Basic documentation is included in the download.

CopySauce was branded by Igloo (now Authentic Entertainment), and my original post of the utility can be found here.

Recently, Kiran Patil wrote a post about a similar utility, where he mentioned that he had troubles with the configuration of CopySauce. While the documentation for CopySauce has some instructions, I decided to write this post about the configuration, in case anyone else has issues with it.

Once you’ve run CopySauce, there are two simple JSON files you have to worry about.
1. The configured projects file in your AppData directory.
2. The project configuration file in your project’s source directory.

The Configured Projects File

The configured projects file is created and automatically updated when you run CopySauce. Any previous projects you’ve used it on will have the Source code directory saved to it. This allows you to quickly rerun CopySauce on projects, without having to re-select the Source and WebRoot directories.
The config file lives here:-
C:\Users\[username]\AppData\Local\CopySauce\CopySauce Projects.json

{
    "projects": [
        "D:\\TFS\\MyDemoSite\\Source\\WebApp",
        "D:\\Github\\LaunchSitecoreTDS\\Source\\LaunchSitecore.Client"
    ]
}

The Project Configuration file

The project configuration file contains specific settings for the project, including:-
1. Folders to watch. (/css, /js, /Views etc.)
2. Files to ignore. (.cs)
3. The web root directory we’re copying to.

This information will tell CopySauce what files to copy and where to copy them to.

The file lives in the project’s root directory, and is called ‘.CopySauce.json’.

{
    "cmd_after_copy": "",
    "file_exclude_patterns": [
        "^\\.",
        ".*\\.cs$"
    ],
    "folder_exclude_patterns": [
        "^\\."
    ],
    "folders_to_watch": [
        "css",
        "images",
        "img",
        "javascript",
        "js",
        "layouts",
        "views",
        "xsl"
    ],
    "web_root": "D:\\Sites\\LaunchSitecore\\Website"
}

You can get even more advanced with the ‘cmd_after_copy’ attribute, to perform additional tasks when files are copied.

A fix for TFS

If you’re using TFS, you will need to set ‘cmd_to_copy’ to ‘attrib -r’.
This is because TFS sets files to Read Only when they’re not checked out. Normally that would mean that when you commit, TFS would set the file to Read Only, and CopySauce would copy a read only file to your webroot, which would break future builds.
See here for more information.

Multiple Source Projects

If you have multiple website projects (think a combined WebForms and MVC site), then you can simple run two CopySauce windows at the same time.
Just setup each project on load and you’re good to go.
If you want to change the config for any project, close CopySauce for that project, make the changes, and reload it.

– See more at: http://igloo.com.au/blog/copysauce-igloos-sitecore-development-utility/#sthash.NvrBpfkW.dpuf

5 Responses to CopySauce, a file Copying Utility for Sitecore Development

  1. Matt says:

    I’m trying to set this up for a multi-instance environment (one CM and one CD), but I’ve not seen a way to set two targets for CopySauce. Have you faced this scenario yet, and if so, how did you address it?

  2. Mark Stiles says:

    Nice tool but beware of it’s limitations. Switching branches of code can be a recipe for disaster.

    As the name implies Copy Sauce only copies files over but does not remove files that no longer exist. I’ve been left scratching my head a few times wondering why binaries referenced in patch config files were being called when they shouldn’t have been.

    Sprinkle in a dash of not copying certain files over and VOILA, you’ve got yourself a YSOD souffle!

    Pairs nicely with your favorite adult beverage and a slice of humble pie.

  3. Mark Stiles says:

    So as I’ve found, it will remove files ~some of the time~ but not all of the time.

    Pass the humble pie.

    • sholmesby says:

      I’d be interested to see what messages are logged in the output window when files are removed, both when it works and when it doesn’t.
      I assume you’re using Git, so Read-Only won’t be an issue. Maybe files are locked by another process?

      Also, FYI, if you’re using TDS 5.5, you can now enable Content File Sync instead of using CopySauce.
      https://www.youtube.com/watch?v=8lECUysnYB0
      This will be from within Visual Studio though, in case you’re editing files in another editor.

Leave a Reply

Your email address will not be published. Required fields are marked *