microsoft / azure-devops-wit-client-om-migration-guide

.NET/C# samples for interacting with work items on Azure DevOps Services and Azure DevOps Server
MIT License
25 stars 9 forks source link

WorkItemStore and Project is deprecated #7

Open HasseEllsater opened 2 years ago

HasseEllsater commented 2 years ago

Hi,

I have an vsix project that extends visual studio 2019, I have used the following method to find the projects in DevOps:

TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri(Properties.Settings.Default.DevOpsUrl)); WorkItemStore workItemStore = tpc.GetService(); foreach (Project teamProject in workItemStore.Projects) { .... }

I am trying to use the preferred method VssConnection connection = new VssConnection(new Uri(Properties.Settings.Default.DevOpsUrl), new VssClientCredentials()); ProjectHttpClient projectClient = connection.GetClient(); IPagedList projects = await projectClient.GetProjects().ConfigureAwait(true);

I have tried many variants with or withour await, but all fails on the same error. If I create a standalone exe and use the same nuget package Microsoft.TeamFoundationServer.ExtendedClient it will work, but if I call it from my VS plugin it will fail with the following, I have no clue and has been trying to find a solution for days now, any help is appreciated.

System.MissingMethodException HResult=0x80131513 Message=Method not found: 'System.Threading.Tasks.Task1<Microsoft.VisualStudio.Services.WebApi.IPagedList1> Microsoft.TeamFoundation.Core.WebApi.ProjectHttpClient.GetProjects(System.Nullable1<Microsoft.TeamFoundation.Core.WebApi.ProjectState>, System.Nullable1, System.Nullable1<Int32>, System.Object, System.String, System.Nullable1)'

AcePalsgaard commented 2 years ago

You and me both sir. I'm gonna implement deprecated / obsolete for now. I Fear this will hit me in the back of my neck in a year or two.

[Rant]

I have wasted more than one weeks worth of work, trying to implement auto merge via command line or C# in a DevOps Pipeline build. TF.EXE merge, resolve and checkin worked after two hours. But what about those pesky work Items EVERYBODY wants?

Trying to use the REST API, I've read tens if not hundreds of forum threads, Stack Overflow and MSDN articles on the subject. They just made it so cryptic its beyond mere mortal developers with 20+ years of experience. Because.. It was too simple before? no they said - we cant have simple with Microsoft Azure. Lets do a cryptic convoluted JSON REST API Solution without strongly typed classes.

I cannot, for the love of all good things in the world, find a solution using the new REST API way in DevOps to do a C# Merge, Resolve and Checkin with associated WorkItem (this is crucial!) fetched from the source checkin (even more crucial!).

It was so easy with TF.exe checkin but they removed /associate : [workItemId] Because WHY? oh right.. too simple.

I'm so frustrated.

[/Rant]

ahh.. I feel better already :)

Let me know when they finally get around to making life simple for developers again; like they used to do ten years ago.