I have a .net6 sdk project that I need to upgrade to .net8 for some new functionality. It has some shared project libraries with other projects that are still .net6.
Project A
includes Project B
which includes Project C
. I need A and C to be .net8, but B and C still need to support .net6 projects. So I tried multi-targeting B and C to .net8 and .net6 and upgrading A to .net8. But when I run project A it's reference to C is still the .net6 version.
B and C are outputting dlls for both net6 and net8, but I can't get A to pull in the new versions.
Project A csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AssemblyName>A</AssemblyName>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="B.csproj" AdditionalProperties="TargetFramework=net8.0" />
</ItemGroup>
</Project>
Project B csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<AssemblyName>B</AssemblyName>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="C.csproj" />
</ItemGroup>
</Project>
Project C csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks>
<AssemblyName>C</AssemblyName>
</PropertyGroup>
</Project>
This is a simplified view of what I have. There are many more dependencies, so maybe there's some interference from another project or package. But I'm not sure why A doesn't have the .net8 version of C with this setup. Any ideas on how to achieve this?
AdditionalProperties
as metadata onProjectReference
. I don't think it is supported. ButProjectReference
does support aSetTargetFramework
which may be what you need.