I have a c++ dll which originally had CLR support for .net framework 4.8, I am updating the library this references to .net 7.0, and so have tried to update the CLR support for this c++ dll to also target .net 7.0, however this results in the warning:
Project 'projectName' targets 'net7.0'. It cannot be referenced by a project that targets '.NETStandard,Version=v2.0'
I have tried updating through the project settings GUI and in the .vcxproj file with no luck, I updated the platform toolset version to VS2022 (v143), the CLR support option from 'Common Language Runtime Support' to '.NET Core Runtime Support', hit apply and then set the .Net Core Target Framework to v7.0. Then building the project see's the above error show.
The above changes resulted in this for my global and build config specific vcxproj details:
<PropertyGroup Label="Globals">
<ProjectGuid>{78942B09-0F2D-49D7-A329-1363F20188A5}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>projectName</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<TargetFrameworkVersion>v7.0</TargetFrameworkVersion>
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
<DependsOnNETStandard>false</DependsOnNETStandard>
<TargetFramework>net7.0</TargetFramework>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>NetCore</CLRSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CLRSupport>NetCore</CLRSupport>
</PropertyGroup>
I have left other items as default, such as runtime identifier and windows target platform, though I did try removing these from the vcxproj but saw the same error. I have also tried .net 5.0 for both projects, with the same error (mentioning .net 5 instead)
Can a c++ clr dll targeting .net 7.0 cpr support, use a .net 7 c# project? What might I be missing?
Turns out we had a 'Directory.Build.props' file which was setting a target framework version to .netstandard2.0, updating this to .net7.0 resolved the warning