I have a desktop application to modify some xml files that are under source control. The program should be able to get the files, modify them and make a checkin. I already know how to do all that with tf; however, I don't know how to run the developer command prompt for visual studio using code. Also, the program will be installed in computers that doesn't have visual studio; therefore, they won't have the tf command anywhere. Taking into account all that, what would be the best way to run the following commands?
mkdir C:\Temp\PROGRAM
cd C:\Temp\PROGRAM && tf workspace /new /noprompt PROGRAM /collection:"http://myserver:8080/tfs/mycollection"
cd C:\Temp\PROGRAM && tf workfold /map $/my/server/route/to/map C:\Temp\PROGRAM
cd C:\Temp\PROGRAM && tf get
I know that there are some libraries to work with tfvc, but I haven't used them and don't seem as clear as running the commands. Any solution that manage to do the same as the commands above will be welcomed.
- Create workspace
- Map a folder from the server to a local folder
- Download (checkout) all files in that folder (doesn't need to be recursive)
If possible to include in the solution:
- Make checkin of files changed
EDIT
The code that I finally used is this
static void Load(string local, string server, Uri urlCollection)
{
Directory.CreateDirectory(local);
Workspace workspace = GetWorkspace(urlCollection, "MyWorkspaceName");
workspace.Map(server, local);
workspace.Get();
}
static Workspace GetWorkspace(Uri urlCollection, string name)
{
VersionControlServer vcs = new TfsTeamProjectCollection(urlCollection)
.GetService<VersionControlServer>();
try
{ return vcs.GetWorkspace(name, vcs.AuthorizedUser))}
catch(Exception)
{ return vcs.CreateWorkspace(name, vcs.AuthorizedUser)); }
}