Unable to reference Net5.0 C# project from Net5.0 C++ project
See original GitHub issueI have C# library which is targeting net5.0. This is referenced by a C++ project where the TargetFrameworkVersion property is set to "5.0*. Unfortunately this results in this error
2>C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(1806,5): error : Project '..\cslib\cslib.csproj' targets 'net5.0'. It cannot be referenced by a project that targets '.NETFramework,Version=v5.0'.
This occurs regardless of whether PlatformToolset is at v142 or v143 (VS2020 preview)
Is there a workaround for this or do we just have to wait for the tools to catch up?
(I appreciate this may be considered an issue with the C++ build chain rather than the dotnet sdk - happy to raise elsewhere if you can point me to somewhere more appropriate.)
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (1 by maintainers)
Top GitHub Comments
If you want to target .NET 5 and set
<TargetFrameworkVersion>5.0</TargetFrameworkVersion>
, I think you need to set<TargetFrameworkIdentifier>.NETCoreApp</TargetFrameworkIdentifier>
as well. This is what Microsoft.NET.TargetFrameworkInference.targets would infer from<TargetFramework>net5.0</TargetFramework>
. I don’t know whether the C++/CLI or C++/CX build system supports that, though.Closing this because I think the capability is supported albeit not very discoverable. Have raised a VS issue suggesting some discoverability improvements at https://developercommunity.visualstudio.com/t/net50-c-project-cannot-reference-net50-c-project/1511480