简体   繁体   English

C# TFS 以编程方式设置文件的最新信息?

[英]C# TFS Set Latest Information of File programmatically?

I wrote an Visual Studio Extension for our Company, which gets the Specific Version of Files in a Solution based on Microsoft TFS.我为我们公司编写了一个 Visual Studio 扩展,它在基于 Microsoft TFS 的解决方案中获取特定版本的文件。 We use Visual Studio 2015 / 2019.我们使用 Visual Studio 2015 / 2019。

My question is, is there some way to set the "Latest" Information of an File which gets displayed in the Source Control Explorer programmatically?我的问题是,是否有某种方法可以以编程方式设置在源代码管理资源管理器中显示的文件的“最新”信息?

Like this: Latest Information Visual Studio像这样:最新信息 Visual Studio

So i have a list with all files which i want to get.所以我有一个包含我想要获取的所有文件的列表。 Before i used this method to get for every file:在我使用此方法获取每个文件之前:

WorkspaceInfo workspaceInfo = Workstation.Current.GetLocalWorkspaceInfo(filePath);
Workspace ws = workspaceInfo.GetWorkspace(new TfsTeamProjectCollection(workspaceInfo.ServerUri));

status = ws.Get(new GetRequest(new ItemSpec(filePath, RecursionType.Full), VersionSpec.Latest), GetOptions.GetAll);

This worked fine and refreshed the latest information.这工作正常并刷新了最新信息。 Sadly this method is to slow compared to the "real" Get Specific Version from Visual Studio.遗憾的是,与 Visual Studio 的“真实”获取特定版本相比,这种方法速度较慢。

Now I tried this method, which is much faster, but doesn´t change the latest information of the file:现在我尝试了这种方法,速度要快得多,但不会更改文件的最新信息:

item.DownloadFile(filePath);

Even if I downloaded the file (I checked the differences between changesets) and got the latest version of it, the information in Source Control Explorer keeps saying "No".即使我下载了文件(我检查了变更集之间的差异)并获得了它的最新版本,源代码管理资源管理器中的信息也一直说“不”。

Does someone know a solution for this, or even a better solution?有人知道解决方案,甚至更好的解决方案吗?

Why you don't use the VersionControlServer.DownloadFile instead the item.downloadfile ?为什么不使用VersionControlServer.DownloadFile代替item.downloadfile https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/bb138622(v%3Dvs.110) https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2012/bb138622(v%3Dvs.110)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM