Question

I've just started using visualstudio.com today with VS2013 (first time using source control), and have a web site project running. My structure is as follows:

MyCompany.VisualStudio.com\DefaultCollection
 - My Site (project)
    - BuildProcessTemplates
    - Site (folder)
       - My Site (folder)
          - Site (branch)
              - subfolders
          - Site Branch 1 (branch - created just now from "Site")
              - subfolders

Within Solution Explorer, I only see "Site" with its respective files. How do I switch to working on "Site Branch 1"? I assume I can "Open Existing Web Site" and find it on the file system, but is that the correct way? I had hoped there'd be an option to work with the files from Source Control Explorer.

Currently (before branching), Solution Explorer reflects what I see in the Control Explorer: enter image description here

After branching (creating "Development" branch), if I click on a file in the "Development" branch, it gets opened under a "Miscellaneous Files" folder under the current project, which then causes compilation errors: enter image description here

So, to forget about working on "Main" and work on "Development" instead, would I have to "Open Web Site" from within VS, or can I add the "Development" web site to the current solution (which sounds incorrect)?

Was it helpful?

Solution

Solution Explorer will show you the files in your solution; Source Control Explorer will show any files in source control, and you should be able to open them directly (assuming a workspace mapping exists for that source control path). For example, starting with this (where - is a folder and * is a file, note I've modified things a little):

MyCompany.VisualStudio.com\DefaultCollection
 - My Site (team project)
    - BuildProcessTemplates
    - Main (branch)
        * MyGreatProject.sln
        - MyGreatProject (folder)
            * MyGreatProject.csproj
            * MyGreatPage.html
            * web.config

If you open the solution, it will show you the contents of Main\MyGreatProject\.... Now let's branch:

MyCompany.VisualStudio.com\DefaultCollection
 - My Site (team project, source path = $/MyGreatProject)
    - BuildProcessTemplates
    - Main (branch)
        * MyGreatProject.sln
        - MyGreatProject (folder)
            * MyGreatProject.csproj
            * MyGreatPage.html
            * web.config
    - development (branch)
        * MyGreatProject.sln
        - MyGreatProject (folder)
            * MyGreatProject.csproj
            * MyGreatPage.html
            * web.config

If you open $/MyGreatProject/Main/MyGreatProject.sln, it will still only show those files (and that 1 project). Source Control Explorer will show you all the files, and you can open them directly. If you make a change (say you edit $/MyGreatProject/development/MyGreatProject/web.config), it will be a pending edit in your workspace. If you open $/MyGreatProject/development/MyGreatProject.sln from the Source Control Explorer, it will now open and show those files under $/MyGreatProject/development.

Updates based on yours (also fixed up my TFS paths):

The solution file should be checked in to the branch as one of the source files. If you add projects in one branch (e.g. you create a control library in Development) you want that in the solution, but only in the branch where the work is being done.

Here's how I've structured it. You can see how $/MyGreatProject/Main/ contains the solution file, and the website is in a folder underneath that (this is kind of important, as VS doesn't handle web site projects where the solution is in the website folder very well):

Main Main website

Development looks the same.

If I have $/MyGreatProject/Main/MyGreatProject.sln open in VS, and from Source Control Explorer, I open $/MyGreatProject/Development/MyGreatWebsite/Default.aspx, it opens fine; I'm not seeing any compilation issues, and it's not getting added as a misc file. Here's my workspace mapping:

workspace mapping

You can see that the workspace mapping is at the root for my project, so it knows about all files in any branches. I've synced all the files to disk locally when I branched, so it's not opening in the %temp% folder.

When I changed the workspace mapping to only include Main, and then opened files from Development, it did download to %temp%, and I did see compilation issues around the code-behind file missing, which makes sense as it will only download the file that you just opened (I think). I didn't see it opening as a misc file though... not sure why it's behaving differently between the two of us.

Anyways, if you have the workspace mapping including both folders, the Team Explorer gets some handy features. For one, it will provide you with all solutions available in the workspace on the Home page so you don't have to browse through Source Control Explorer or Windows Explorer to find them:

list of solutions

If the list of solutions gets too long (it will show up to 20), the Open... link will show a file picker dialog from the root of your workspace.

It will also show you pending changes across all files in the workspace, so if you make changes in multiple branches, you can either check them in together, or you can exclude files in one branch from the current check in and submit them separately (this view doesn't call out the branches separately as well, but you can see the paths to the files):

pending changes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top