views:

684

answers:

1

I am having a problem with a folder and a file showing up under my project which is under my solution. The files are being added to TFS but my project has no idea 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 the file.

+1  A: 

Just because a file exists on the server doesn't mean it's part of a solution or project. I'm not 100% sure what your code is supposed to do, but it won't affect any projects unless you also modify the corresponding *.vbproj (or whatever) file.

PS - you shouldn't need to pend changes on a directory. PendAdd("$/path/to/file.txt") will pend implicit adds on the parent dirs if they do not exist yet.

Richard Berg