2 years ago

#70047

test-img

Josef Širůčka

How to add dependency with different dotnet version (CLI = net6.0 / DLLProject = net6.0-windows)

I have this situation:

I have a Class library with a target framework set to net6.0-windows

<TargetFramework>net6.0-windows</TargetFramework>

And then I have added a new CLI application which I want to build, pack and install as a global CLI app, which has:

<TargetFramework>net6.0</TargetFramework>

Normally I would change the class library to net6.0, but when I do it - the build says that -windows parameter is mandatory for this kind of project. On top of that, there are other projects in net6.0-windows that need to be set as they are.

I have tried to switch CLI to net6.0-windows, but 'dotnet pack' says - that -windows is not supported.

I also tried to use multi-platform target:

<TargetFrameworks>net6.0;net6.0-windows</TargetFrameworks>

But then dotnet pack says:

C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.PackTool.targets(95,5): error NETSDK1146: PackAsTool does not support TargetPlatformIdentifier being set. For example, TargetFramework cannot be net5.0-windows, only net5.0. PackAsTool also does not support UseWPF or UseWindowsForms when targeting .NET 5 and higher.

Any solution how to access classes from DLL - within my CLI? Is this even the correct approach?

.net-core

.net-6.0

dotnet-cli

0 Answers

Your Answer

Accepted video resources