title: How does Visual Studio's source control integration work with Perforce?
body: <p>We're using Perforce and Visual Studio. Whenever we create a branch, some projects will not be bound to source control unless we use "Open from Source Control", but other projects work regardless. From my investigations, I know some of the things involved:</p>
  
  <p>In our .csproj files, there are these settings:</p>
  
  <ul>
  <li>&lt;SccProjectName></li>
  <li>&lt;SccLocalPath></li>
  <li>&lt;SccAuxPath></li>
  <li>&lt;SccProvider></li>
  </ul>
  
  <p>Sometimes they are all set to "SAK", sometimes not. It seems things are more likely to work if these say "SAK".</p>
  
  <p>In our .sln file, there are settings for many of the projects:</p>
  
  <ul>
  <li>SccLocalPath#</li>
  <li>SccProjectFilePathRelativizedFromConnection#</li>
  <li>SccProjectUniqueName#</li>
  </ul>
  
  <p>(The # is a number that identifies each project.) SccLocalPath is a path relative to the solution file. Often it is ".", sometimes it is the folder that the project is in, and sometimes it is ".." or "..\..", and it seems to be bad for it to point to a folder above the solution folder. The relativized one is a path <em>from</em> that folder to the project file. It will be missing entirely if SccLocalPath points to the project's folder. If the SccLocalPath has ".." in it, this path might include folder names that are not the same between branches, which I think causes problems.</p>
  
  <p>So, to finally get to the specifics I'd like to know:</p>
  
  <ul>
  <li>What happens when you do "Change source control" and bind projects? How does Visual Studio decide what to put in the project and solution files?</li>
  <li>What happens when you do "Open from source control"?</li>
  <li>What's this "connection" folder that SccLocalPath and SccProjectFilePathRelativizedFromConnection refer to? How does Visual Studio/Perforce pick it?</li>
  <li>Is there some recommended way to make the source control bindings continue to work even when you create a new branch of the solution?</li>
  </ul>
  
  <hr>
  
  <p><em>Added June 2012:</em>
  I don't use Perforce any more, so I can't vouch for it, but have a look at <a href="https://stackoverflow.com/a/11148342/2283">KCD's answer</a> below. Apparently there's <a href="http://forums.perforce.com/index.php?/topic/1585-new-perforce-plugin-for-visual-studio-20121-beta-available-now/" rel="nofollow noreferrer">a new P4 VS plugin</a> under development. Hopefully it should clear up all this mess!</p>