Upgrading from .NET 5 to .NET 6 is proving not so straightforward as I expected.
All my unit test projects fail to compile due to the following error
Severity Code Description Project File Line Suppression State
Error CS0433 The type 'ServiceCollection' exists in both 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and 'Microsoft.Extensions.DependencyInjection, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' Sample.DynamoDb.FunctionalTests C:\src\my-solution\test\Sample.DynamoDb.FunctionalTests\DependencyInjectionTests\GetServiceTests.cs 22 Active
They reference class libraries that depend on Microsoft.Extensions.DependencyInjection.Abstractions
version 6
but for some reason it seems there is a dependency on Microsoft.Extensions.DependencyInjection
in the test project itself. Probably dragged across by some of the packages I use (and I don't know which one).
This is my test project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>Enable</Nullable>
<IsPackable>False</IsPackable>
<IsPublishable>False</IsPublishable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="6.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Sample.DynamoDb.DependencyInjection\Sample.DynamoDb.DependencyInjection.csproj" />
</ItemGroup>
</Project>
Anyone with a similar problem or an idea on how to troubleshoot and find the issue or a workaround?
csproj
forSample.DynamoDb.DependencyInjection
? – PermuteSample.DynamoDb.DependencyInjection.csproj
? Or the test project? – Auspex