0

If I add the Microsoft.TeamFoundationServer.ExtendedClient package to a .NET 6.0 console application, I get the following warning:

E:\tmp\test\test.csproj : warning NU1701: Package 'Microsoft.AspNet.WebApi.Core 5.2.7' was restored using '.NETFramewor
k,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework
,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net
6.0'. This package may not be fully compatible with your project.

Am I referencing the correct package? How can I get rid of this warning? Or can I just ignore it?

(The purpose of this application will be to access and manipulate TFS Source Control items.)

Steps to reproduce:

From a Visual Studio 2022 command prompt, type the following commands:

dotnet new console -n test
cd test
dotnet add package Microsoft.TeamFoundationServer.ExtendedClient
dotnet build

The build will now generate the warning shown above.

The ".csproj" file produced looks like this:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.TeamFoundationServer.ExtendedClient" Version="16.170.0" />
  </ItemGroup>

</Project>
Matthew Watson
  • 104,400
  • 10
  • 158
  • 276
  • 1
    The following link is from 2019. Some issues may of been solved with core since this time. But it is worth reading : https://stackoverflow.com/questions/59529137/microsoft-teamfoundationserver-extendedclient-not-compatible-with-asp-net-core-3?force_isolation=true – jdweng Oct 20 '22 at 10:46
  • What version of Nuget are you using? https://www.nuget.org/packages/Microsoft.TeamFoundationServer.ExtendedClient?force_isolation=true – jdweng Oct 20 '22 at 10:49
  • Thanks @jdweng, I'll investigate that. I was (perhaps stupidly) trying to use [Microsoft's devops sample code](https://github.com/microsoft/azure-devops-auth-samples) which was for .NET 4.5, and then tried to update to .NET 6... I'm using the version of NuGet that comes with VS2022. – Matthew Watson Oct 20 '22 at 10:49
  • I was just reading the note. – jdweng Oct 20 '22 at 11:44

1 Answers1

1

Thanks to /u/jdweng who set me on the right track:

For .NET 6.0 you need to use the package "Microsoft.TeamFoundationServer.Client" and then the error does not arise.

After adding that package (and only that package) I was able to modify the Microsoft ClientLibraryConsoleApp sample to compile and run without errors.

For completeness, here's the project file I ended up with:

<PropertyGroup>
  <OutputType>Exe</OutputType>
  <TargetFramework>net6.0</TargetFramework>
  <ImplicitUsings>enable</ImplicitUsings>
  <Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.170.0" />
</ItemGroup>

And the "Program.cs" file:

using Microsoft.TeamFoundation.WorkItemTracking.WebApi;
using Microsoft.TeamFoundation.WorkItemTracking.WebApi.Models;
using Microsoft.VisualStudio.Services.Common;
using Microsoft.VisualStudio.Services.WebApi;

const string AZURE_DEV_OPS_ORGANIZATION_URL = "Your URL here";

var connection = new VssConnection(new Uri(AZURE_DEV_OPS_ORGANIZATION_URL), new VssCredentials());

Console.WriteLine($"User: {connection.AuthenticatedIdentity.DisplayName}");

// create http client and query for results

var witClient    = connection.GetClient<WorkItemTrackingHttpClient>();
var query        = new Wiql { Query = "SELECT [Id], [Title], [Description] FROM workitems WHERE [Work Item Type] = 'Bug' AND [Assigned To] = @Me" };
var queryResults = await witClient.QueryByWiqlAsync(query);

// Display results in console

if (queryResults == null || !queryResults.WorkItems.Any())
{
    Console.WriteLine("Query did not find any results");
    return;
}

var items = await witClient.GetWorkItemsAsync(queryResults.WorkItems.Select(item => item.Id));

foreach (var item in items)
{
    Console.WriteLine($"ID: {item.Id}, Title: {item.Fields["System.Title"]}");
}
Matthew Watson
  • 104,400
  • 10
  • 158
  • 276