This is a small command line utility for saving and restoring Visual Studio
- document window layouts,
- debugger breakpoints and
across different Git branches.
Visual Studio saves all its user-specific settings for a solution in a
.suo file. Due to that user-specific nature, it makes no sense to put the
.suo file in version control. This means that things like open documents, breakpoints and bookmarks always stay the same when going back and forth between branches, leading to a (for me) annoying behavior:
- You work on a new feature in branch
A. You have added new code files here and arranged your code tabs and windows in a way that is suitable for what you need to do.
- An issue pops up that needs to be fixed immediately. You checkout branch
Bfrom the main branch and get to work. Visual Studio tries to apply the previous document window layout, but the new files you added in branch
Ado not exist in branch
B, so those tabs and windows can't be opened. The files that you had open which exist in this branch as well will be opened, but chances are you don't need those, so you'll either close or leave them, and open other files that are involved in the fix you need to make.
- You finish the fix in branch
Band get back to branch
A. The document settings stored in the
.suofile are now those from your work in branch
B- although your new branch
Afiles are now present again, Visual Studio doesn't remember you had them open, and instead presents you with the files from your branch
Bfix that are not relevant to your work in branch
A. You need to close those and then find your new branch
Afiles again and restore your working layout by hand.
The Sol.... Crutch
This is a small command line tool that can do one of two things:
- Extract the document window layout, breakpoints and bookmarks from a
.suofile and remember them for the current Git branch
- Overwrite the document window layout, breakpoints and bookmarks in the
.suofiles for supported Visual Studio versions with those previously stored for the current branch
amagatsha.exe is in
$PATH, the workflow is as follows:
If you need to switch branches, close the solution; this is necessary to make Visual Studio save the current solution settings to the
amagatsha savein the repository's root directory. This will look for any
.slnfiles in the directory, try to find the respective
.suofiles and add or update the entry with the current branch's name in
.suofiles for more than one supported Visual Studio version (currently 2015 and 2017) are found, settings are backed up from the most recently changed one.
Checkout the other branch.
amagatsha restore. This will look for an entry with the current branch name in the
.branchdocumentsfile, and if found, will replace the solution settings in the
.suofile with that data. If
.suofiles for more than one supported Visual Studio version (currently 2015 and 2017) are found, settings are restored into all of them.
Reopen the solution.
amagatsha cleanup -bremoves solution settings for branches that do not exist in the local repository (the
-bparameter is optional)
amagatsha cleanup -d <n>removes solution settings for branches that have not been updated in
This is probably too cumbersome for most people to use but helps me in the short term. A much nicer solution would be a Visual Studio extension that takes care of this, but that would obviously be a lot more effort, and I don't know how feasible that really would be.
This currently only works when calling
amagatsha.exe from the directory that contains the
.sln file. (It does not have to be located there.)
Clone the repository and run
build.cmd or build the solution in Visual Studio.
If you just want to use the application, download the zip file from the Releases section.
Amagatsha is Zulu for "branches".