private string GetLatestVerstion(VersionControlServer versionControl, TfsGetCodeParams objTfsGetCodeParams) { Workspace[] workspaces = versionControl.QueryWorkspaces(objTfsGetCodeParams.WorkStationName, versionControl.AuthenticatedUser, Workstation.Current.Name); if (workspaces.Length > 0) { versionControl.DeleteWorkspace(objTfsGetCodeParams.WorkStationName, versionControl.AuthenticatedUser); } Workspace workspace = versionControl.CreateWorkspace(objTfsGetCodeParams.WorkStationName, versionControl.AuthenticatedUser, "Temporary Workspace"); try { workspace.Map(objTfsGetCodeParams.SourcePath, objTfsGetCodeParams.TargetPath+"/"+objTfsGetCodeParams.BuildVersion ); GetRequest request = new GetRequest(new ItemSpec(objTfsGetCodeParams.SourcePath, RecursionType.Full), VersionSpec.Latest); GetStatus status = workspace.Get(request, GetOptions.GetAll | GetOptions.Overwrite); // this line doesn't do anything - no failures or errors return "done"; } finally { if (workspace != null) { workspace.Delete(); } } }
private static void RemoveWorkspace(string workspaceName, VersionControlServer server) { TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "Removing Workspace{0}", workspaceName); if (server.QueryWorkspaces(workspaceName, server.AuthenticatedUser, Environment.MachineName).Length > 0) { server.DeleteWorkspace(workspaceName, server.AuthenticatedUser); } }
private void SetupWorkspace(string workingDirectory, string cpSourceBranch, VersionControlServer versionControl) { List<WorkingFolder> workingFolders = new List<WorkingFolder>(); workingFolders.Add(new WorkingFolder(cpSourceBranch, workingDirectory)); // Create a workspace. Workspace[] workspaces = versionControl.QueryWorkspaces(sourcePuller.WorkspaceName, versionControl.AuthorizedUser, Environment.MachineName); if (workspaces.Length > 0) versionControl.DeleteWorkspace(sourcePuller.WorkspaceName, versionControl.AuthorizedUser); workspace = versionControl.CreateWorkspace(sourcePuller.WorkspaceName, versionControl.AuthorizedUser, "Work for GetTFSSourceUtil tool", workingFolders.ToArray(), Environment.MachineName); }