问题
We are slowly moving projects from old file based storage (don't ask) to tfs. Our coders are still used to find the code in the file System.
Since we are talking about 100 Projects each with some sort of history, we have to move them carefully one by one. Resulting that we will have to live for some time with the already existing file structure mixed with the TFS managed files.
To make life easier for our coders, I would like to create a shortcut in the filesystem, for each project that we moved. So the developers can look up if the Project has already been moved, and if yes, go by double click to open up the TFS Source Control Explorer pointing directly to the correct Project.
Is this possible? Thanks for your Response.
回答1:
I found a simple solution for my needs, which is based on a small batch script, that you'll have to click. It's not a shortcut so to say even though you can still create a shortcut of the batchfile.
Here's the script:
CALL "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86
REG ADD "HKCU\Software\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\Explorer\<GUIDofTFS>" /v "SceMostRecentPath" /d "$/<PathToTfsProject>" /f
devenv /Command View.TfsSourceControlExplorer
In fact I combined 2 ideas found in separate sources:
1. Start VS with Source Control Explorer
2. Manipulate Registry to open Source Control Explorer in a specific path
With the command devenv /Command View.TfsSourceControlExplorer
you can actually start VS and automatically open Source Control Explorer. Unfortunately there is no way to give a parameter to point it directly to a location you wish. But I noticed that VS2010 seems to persist the last used path and reopens to that place on restarts. A quick research resulted in the registry entry
HKCU\Software\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\Explorer\058104ed-f0e2-4126-9ccc-0e37e19c4f91\SceMostRecentPath
By manipulating the value of SceMostRecentPath
you can trick VS2010 to open Source Control Explorer with the path in there.
Keep in mind: You will need to replace 058104ed-f0e2-4126-9ccc-0e37e19c4f91
with the GUID of your TFS Installation.
Since we are all using VS 2010 but the installation paths differ, I implemented the path dynamically by making use of the VS100COMNTOOLS variable. First we set up the TFS command line environment:
CALL "%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat" x86`
Then we change the registry:
REG ADD "HKCU\Software\Microsoft\VisualStudio\10.0\TeamFoundation\SourceControl\Explorer\[PutYourTfsGUIDHere]" /v "SceMostRecentPath" /d "$/<YourTfsPath>" /f
Finally we do a simple call of devenv.exe with the source Explorer command:
devenv /Command View.TfsSourceControlExplorer
回答2:
Until they're mapped to a local file path, I don't think this is possible. Though there might be an undocumented way to craft a vstfs:///VersionControl/LatestItemVersion/{itemid}
link that might work, I haven't been able to craft one that does the trick.
You could create a powershell script that would check for the local mapping, otherwise ask them where they want to put it and setup the mapping, do a get-latest and go from there...
A bit of trickery with the tf
commandline should get you pretty far.
tf workspaces /owner /collecion /computer
to see whether there's a local workspace to the right team project.tf workspace
/new /collection to create one if neededtf workfold /map
to create a folder mapping, you could prompt them for a target locationtf get
to fetch the latest sources.
Place the .ps1 file in the folder and when opened check for the workspace, if it's there open the local files in the mapped folder. if it isn't, go through the workspace mapping process by invoking the right commands.
来源:https://stackoverflow.com/questions/17750980/how-to-create-explorer-shortcuts-to-specific-tfs-2010-source-control-paths