6

I have migrated to NET 8.0 all my NET 4.6.2 projects, except one that's a VTSO Add-in project (Office). Since Web Office addins is the only option offered in NET Core and doesn't have all the features I need for that project, I have no choice to remain in NET Framework for that specific project.

So, I have bundles all the libraries I used commonly and put them in a NETStandard 2.0 library project so it can be used in both NET Core projects, and this one NET Framework project. Which seemed to work just fine, EXCEPT...

There was a conflict between "netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
8>        "netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was chosen because it was primary and "netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was not.
8>                    logMessageDetails=    References which depend on "netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.7\ref\net8.0\netstandard.dll].
8>            C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.7\ref\net8.0\netstandard.dll
8>              Project file item includes which caused reference "C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.7\ref\net8.0\netstandard.dll".
8>                C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.7\ref/net8.0/netstandard.dll

NETStandard 2.1 is inherently in NET 8.0, so even though NETStandard 2.0 is supported in NET 8.0, it gives conflict error.

Libraries references by NETStandard are also conflicting:

There was a conflict between "System.ComponentModel.Annotations, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.ComponentModel.Annotations, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
There was a conflict between "System.Management, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

I'm hoping there is a way around that, isn't it supposed to be the purpose of NETStandard to be able to share pieces of code such as interfaces and models, between .NET Core and .NET Framework?

5
  • NetStandard2.0 is the glue between Framework and Core, but I believe NetStandard2.1 is just to get the final bits of Windows APIs into something that Core can understand (but isn't cross-platform). So, if you want to target Framework and Core, then 2.0 is your only option. Commented Jul 11, 2024 at 20:47
  • 2
    Can you give an example of project files that are causing this issue? (minimal reproducible example) The error message alone isn't a lot to go off of. Just note that .NET Standard 2.1 doesn't support any version of .NET Framework. Commented Jul 11, 2024 at 20:50
  • .NET 4.6.2 is not the newest .net framework version. Have you considered swithing that to .net 4.8.1? Commented Jul 12, 2024 at 0:35
  • 1
    You can try to target both netstandard2.0 and netstandard2.1 in that library project. In the .csproj you can conditionally add different versions of the same library depending on the target framework. So your .NET Framework VSTO project will use the netstandard2.0 version and all your .NET 8 projects will use the netstandard2.1 version. Commented Jul 12, 2024 at 0:42
  • "Since Web Office addins is the only option offered in NET Core and doesn't have all the features I need for that project". Its not only the only option in Net Core. It will be the only option for Apps in Office in the near future. All the COM stuff is phasing out. Commented Jul 12, 2024 at 7:40

1 Answer 1

1

Thank you @gunr2171, I made a copy of the project with the conflict and it's dependencies and I started removing dependencies 1 by 1. Turns out the issue was Microsoft.Bcl.Build.

Minimal reproductible example was with two library projects, 1x NET 8.0 that depends on 1x NETStandard 2.0 project. Just Microsoft.Bcl.Build as NET 8.0 project's dependency was enough to reproduce the conflict warning.

@Ralf I'm aware of it, and we plan to phase it out in the future, but we can't do that just yet

@Gabor Oh! thank you! I wasn't aware it is now an option, I think Microsoft.Build.Bcl did warn for it, but this might be the real solution

Sign up to request clarification or add additional context in comments.

1 Comment

After testing, doing as @Gabor suggested fixed my problem! Changing <TargetFramework>netstandard2.0</TargetFramework> to <TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks> Fixed the conflict. Thank you guys!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.