我在一个相当大的组织工作,我们面临一个问题,因为我们需要迁移我们的解决方案之一。
总而言之,我们有一个内部工具浏览或旧的TFS 2013服务器,并解析几个csproj和配置文件,以更新一些内容,以便能够将我们的网站迁移到IIS10。
以前的解决方案,使用NuGet包Machado.Microsoft.TeamFoundation和Machado.Microsoft.TeamFoundation.client(现已过时)并且不再适用。
决定将我们的解决方案迁移到“Microsoft.TeamFoundation”NuGet包。一切都很顺利,而不是办理登机手续的部分。
private TfvcChangesetRef Checkin(TfvcItem item, string newContent)
{
// Establish a connection using Windows Credentials
using (var connection = TfsHelper.GetConnection())
// Create TFS Client
using (var tfvcClient = connection.GetClient<TfvcHttpClient>())
{
item.ContentMetadata = new FileContentMetadata();
var changeset = new TfvcChangeset();
var tfvcChange = new TfvcChange(item, versionControlChangeType.Edit);
tfvcChange.NewContent = new ItemContent();
tfvcChange.NewContent.Content = newContent;
tfvcChange.NewContent.ContentType = ItemContentType.RawText;
tfvcChange.Item.Path = item.Path;
var changesList = new List<TfvcChange>();
changesList.Add(tfvcChange);
changeset.Author = new IdentityRef();
changeset.Changes = changesList;
changeset.Comment = "This is a test";
return tfvcClient.CreateChangesetAsync(changeset).Result;
}
}
TfsHelper.GetConnection()
定义如下:
public static VssConnection GetConnection()
{
var connection = new VssConnection(new Uri(ConfigurationManager.AppSettings["TfsUri"]), new VssAadCredential());
connection.ConnectAsync().SyncResult();
// Correctly contains the AAD user account
return connection;
}
在使用由以下组成的变更集调用tfvcClient.CreateChangesetAsync(changeset)
时应用程序正在破坏:
Changes Count = 1 (Correct, one change to be checked in)
Comment "This is a test"
Author typeof(IdentifyRef)
Other values Default ones.
抛出的异常是:
System.AggregateException: 'One or more errors occurred.'
InnerException: VssServiceResponseException: Method Not Allowed
StackTrace of innerException:
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<HandleResponseAsync>d__52.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__50.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__47`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__28`1.MoveNext()
我们已经检查并实施了一些通过Internet找到的解决方案,但目前没有任何工作。你知道什么是错的或遗失的吗?
谢谢
在ExtendedClient
库中使用SOAP对象模型用于TFS 2013; TFS 2013不完全支持REST客户端使用的REST API。