2
votes

I have a .net solution to get a set of changesets into a TFS local workspace that are specified in a config file [values.xml]. Once the files associated to the changesets are downloaded to the local working folder associated with the workspace, I have a separate packaging script that creates a msi out of those files. The .net solution works fine, but usually. The problem arises under the following condition:

Say I have a changeset: C717171 which is associated to a change that I have done on web.config file. The config file [values.xml] lists this changeset in it which implies that the .net solution has to get this specific changeset into the TFS local workspace after which a separate packaging script will take over.

What actually happens is, the .net solution places all the web.config files that are in the repository along with the one that is required.

        var changesets = vcs.QueryHistory(repository, VersionSpec.Latest, 0, RecursionType.Full, null, versionFrom, versionTo, Int32.MaxValue, true, false).Cast<Changeset>();
            Workspace myworkspace = vcs.CreateWorkspace(workspaceName, tfsUser);
            var workingFolder = new WorkingFolder(repository, workspacePath);
            // create WorkingFolder and mapping
            myworkspace.CreateMapping(workingFolder);

            foreach (Changeset changeset in changesets.OrderBy(c => c.ChangesetId))
            {
                var version = new ChangesetVersionSpec(changeset.ChangesetId);

                foreach (Change change in changeset.Changes)
                {
                    myworkspace.Get(new[] { change.Item.ServerItem }, version, RecursionType.Full, GetOptions.Overwrite);
                }
            }

I may provide more details if required.

1
Is it all web.config files that get downloaded, or just the web.config files that are in the same folder and all subfolders of each 'server item' from each changeset? I would look at your use of RecursionType and see if not using Full corrects the issue.d3r3kk
All the web.config files get downloaded.Sourav Kundu

1 Answers

3
votes

If you want to get a single file, you need to use RecursionType.None, not RecursionType.Full.

When you use RecursionType.Full on a path that is a file, you are specifying that you want the file with that name in the specified folder, and any files with the same name in subfolders.

So if you specify $/Project/file.txt, it will download $/Project/file.txt as well as $/Project/subdir1/file.txt, $/Project/subdir2/file.txt, etc.

Specify RecursionType.None to match exactly the given path.