You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering how i would go about achieving multi-targeting for my project, as I'm making Two separate extensions for Two different versions of an application.
Touch-Gestures targets net5.0, while Touch-Gestures-0.6.x targets net6.0.
Both of those libraries have Touch-Gestures.Lib as a dependency. Ideally, this Library should target multiple version of .NET & dependencies in .modules.
Now here is the issue i am encountering:
If i target multiple frameworks in Touch-Gestures.Lib (using <TargetFrameworks>net5.0;net6.0</TargetFrameworks>) then,
Dependencies with net6.0 as target will overwrite the ones with .net5.0 target.
This result in builds of Touch-Gestures failing, because it's targeting net5.0, but the libraries isn't making use of the net5.0 dependencies as it should.
<ProjectSdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
<RootNamespace>TouchGestures.Lib</RootNamespace>
<NoWarn>$(NoWarn); NETSDK1138; VSTHRD200</NoWarn>
<Nullable>enable</Nullable>
<!-- TODO: Change obj path to obj/0.5.x to avoid conflicts with 0.6.x (.NET bug) -->
</PropertyGroup>
<!-- Only Embed debug symbols for the Release configuration -->
<PropertyGroupCondition="'$(Configuration)' == 'Release'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<!-- Only for OTD 0.5.x (Running on .NET 5) -->
<ItemGroupCondition="'$(TargetFramework)' == 'net5.0'">
<ProjectReferenceInclude="../.modules/OpenTabletDriver.External/.modules/OpenTabletDriver/OpenTabletDriver.Desktop/OpenTabletDriver.Desktop.csproj"PrivateAssets="all" />
<ProjectReferenceInclude="../.modules/OpenTabletDriver.External/OpenTabletDriver.External.Common/OpenTabletDriver.External.Common.csproj" />
</ItemGroup>
<!-- Only for OTD 0.6.x (Running on .NET 6) -->
<ItemGroupCondition="'$(TargetFramework)' == 'net6.0'">
<ProjectReferenceInclude="../.modules/OpenTabletDriver.External-0.6.x/.modules/OpenTabletDriver/OpenTabletDriver.Desktop/OpenTabletDriver.Desktop.csproj"PrivateAssets="all" />
<ProjectReferenceInclude="../.modules/OpenTabletDriver.External-0.6.x/OpenTabletDriver.External.Common/OpenTabletDriver.External.Common.csproj" />
</ItemGroup>
</Project>
If you build Touch-Gestures (which targets net5.0) as is, dotnet will say that the project isn't compatible with the library, because it and its dependencies are targeting net6.0, which shouldn't be the case since the condition is there to prevent that.
Now what i've also tried is using different csproj files, targeting different versions of .NET & dependencies.
That approach seems to work on individual builds, however, i am unable to build the solution as a whole, as nuget will only restore Touch-Gestures.Lib.csproj, skipping Touch-Gestures.Lib-0.6.x.csproj, the following error occur.
error NETSDK1005: Assets file 'Touch-Gestures\Touch-Gestures.Lib\obj\project.assets.json' doesn't have a target for 'net5.0'. Ensure that restore has run and that you have included 'net5.0' in the TargetFrameworks for your project. [Touch-Gestures\Touch-Gestures.Lib\Touch-Gestures.Lib.csproj::TargetFramework=net5.0]
After that error occurred, i have tried to change the obj folder for each csproj, but that also ended up not working, as .NET's compiler ended up detecting source generated files for each of these folders as duplicates, also it still generate an obj folder. containing the same content as without having that Directory.Build.Props file.
Touch-Gestures\Touch-Gestures\Touch-Gestures.csproj : error NU1201: Project OpenTabletDriver.Desk is not compatible with net5.0 (.NETCoreApp,Version=v5.0). Project OpenTabletDriver.Plugin supports: net6.0 (.NETCoreApp,Version=v6.0) [Touch-Gestures\Touch-Gestures.sln]
Of course, using <Compile Remove="obj-0.6.x" /> in net5.0 or <Compile Remove="obj-0.5.x" /> in net6.0 does not solve the issue.
The same applies to DefaultItemExcludes.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I was wondering how i would go about achieving multi-targeting for my project, as I'm making Two separate extensions for Two different versions of an application.
My solution goes as follows:
Touch-Gestures
targetsnet5.0
, whileTouch-Gestures-0.6.x
targetsnet6.0
.Both of those libraries have
Touch-Gestures.Lib
as a dependency. Ideally, this Library should target multiple version of .NET & dependencies in.modules
.Now here is the issue i am encountering:
If i target multiple frameworks in
Touch-Gestures.Lib
(using<TargetFrameworks>net5.0;net6.0</TargetFrameworks>
) then,Dependencies with
net6.0
as target will overwrite the ones with.net5.0
target.This result in builds of
Touch-Gestures
failing, because it's targetingnet5.0
, but the libraries isn't making use of thenet5.0
dependencies as it should.Touch-Gestures
csproj file:Touch-Gestures-0.6.x
csproj file:Touch-Gestures.Lib
csproj file:If you build
Touch-Gestures
(which targetsnet5.0
) as is, dotnet will say that the project isn't compatible with the library, because it and its dependencies are targetingnet6.0
, which shouldn't be the case since the condition is there to prevent that.Now what i've also tried is using different csproj files, targeting different versions of .NET & dependencies.
That approach seems to work on individual builds, however, i am unable to build the solution as a whole, as nuget will only restore
Touch-Gestures.Lib.csproj
, skippingTouch-Gestures.Lib-0.6.x.csproj
, the following error occur.After that error occurred, i have tried to change the obj folder for each csproj, but that also ended up not working, as .NET's compiler ended up detecting source generated files for each of these folders as duplicates, also it still generate an obj folder. containing the same content as without having that
Directory.Build.Props
file.Of course, using
<Compile Remove="obj-0.6.x" />
innet5.0
or<Compile Remove="obj-0.5.x" />
innet6.0
does not solve the issue.The same applies to
DefaultItemExcludes
.Any way i can achieve what i want?
This feels similar to dotnet/sdk#17013.
Beta Was this translation helpful? Give feedback.
All reactions