Adding a folder and file using the Team Foundation Server SDK

I had a problem with the folder and file that appears in my project, which is under my solution. Files are added to TFS, but my project does not know that the file exists and shows it as white

Dim tfs As TeamFoundationServer = TeamFoundationServerFactory.GetServer(txtServer.Text) ' Get a reference to Source Control. Dim versionControl As VersionControlServer = CType(tfs.GetService(GetType(VersionControlServer)), VersionControlServer) ' Create a workspace. Dim workspace As Workspace = versionControl.GetWorkspace(txtProject.Text) If Not String.IsNullOrEmpty(txtUpdateScript.Text) Then Dim fooString = Array.Find(Of WorkingFolder)(workspace.Folders, Function(m) m.ServerItem.Contains("$/FOO.NET")) Directory.CreateDirectory(IO.Path.Combine(IO.Path.Combine(txtProject.Text, "FOOAdmin\Updates"), txtVersion.Text)) Directory.CreateDirectory(fooString.ServerItem & "/FOOAdmin/Updates/" & txtVersion.Text) IO.File.Copy(txtUpdateScript.Text, IO.Path.Combine(IO.Path.Combine(IO.Path.Combine(txtProject.Text, "FOOAdmin\Updates"), txtVersion.Text), "Update.sql"), True) workspace.PendAdd(IO.Path.Combine(IO.Path.Combine(txtProject.Text, "FOOAdmin\Updates"), txtVersion.Text)) workspace.PendAdd(IO.Path.Combine(IO.Path.Combine(IO.Path.Combine(txtProject.Text, "FOOAdmin\Updates"), txtVersion.Text), "Update.sql")) End If ' Get Pending changes Dim pendingChanges As PendingChange() = workspace.GetPendingChanges() ' Checkin the items we added. Dim changesetNumber As Integer = workspace.CheckIn(pendingChanges, "FOO.Net AutoBuild") 

If I do not add this line

  Directory.CreateDirectory(fooString.ServerItem & "/FOOAdmin/Updates/" & txtVersion.Text) 

Then the project does not know about the folder or file.

+4
source share
1 answer

Just because a file exists on the server does not mean that it is part of a solution or project. I am not 100% sure what your code should do, but it will not affect any projects unless you also modify the corresponding * .vbproj file (or something else).

PS - you do not need to change directory changes. PendAdd ("$ / path / to / file.txt") will cause implicit additions to parent directories if they do not already exist.

+3
source

All Articles