Problem with compiling my solution with .Net5 as the framework target

Hello.

I'm trying to compile my solution after I have updated all projects in the solution to .Net5. 

For my C++ projects I get always the error message

Microsoft.NuGet.targets(198, 5): Your project does not reference ".NETCoreApp,Version=v5.0" framework. Add a reference to ".NETCoreApp,Version=v5.0" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.

My project file contains the correct target framework. When I open and compile the solution with Visual Studio I get no error, everything works fine.

Here is a part of my project file

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{D2F0AFB1-A1A1-4648-8389-CA36AD689563}</ProjectGuid>
<TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>LicenseDllWrapper</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CLRSupport>NetCore</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>

I tried some different values for the TargetFramework as net5.0 or net5.0-windows or net5.0-windows7.0, but always the
same error.

How can I fix this problem?
This problem prevents me from using Rider.

Best regards
Jörg

P.S.
After some more investigations I found something. Rider generates
a different projects.assets.json file then Visual Studio.

Here the generated file from VSS:
{
"version": 3,
"targets": {
"net5.0-windows7.0": {
"LicenseDllWrapper.Core/1.0.0": {
"type": "project",
"compile": {
"bin/placeholder/LicenseDllWrapper.Core.dll": {}
},
"runtime": {
"bin/placeholder/LicenseDllWrapper.Core.dll": {}
}
},
"LicenseWrapperData/1.0.0": {
"type": "project",
"framework": ".NETCoreApp,Version=v5.0",
"compile": {
"bin/placeholder/LicenseWrapperData.dll": {}
},
"runtime": {
"bin/placeholder/LicenseWrapperData.dll": {}
}
}
}
},

And here the generated file from Rider:
{
"version": 3,
"targets": {
"net5.0-windows7.0": {
"LicenseDllWrapper.Core/1.0.0": {
"type": "project",
"framework": "Unsupported,Version=v0.0",
"compile": {
"bin/placeholder/LicenseDllWrapper.Core.dll": {}
},
"runtime": {
"bin/placeholder/LicenseDllWrapper.Core.dll": {}
}
},
"LicenseWrapperData/1.0.0": {
"type": "project",
"framework": ".NETCoreApp,Version=v5.0",
"compile": {
"bin/placeholder/LicenseWrapperData.dll": {}
},
"runtime": {
"bin/placeholder/LicenseWrapperData.dll": {}
}
}
}
},

I hope that helps a little bit.


0
5 comments

The line 

"framework": "Unsupported,Version=v0.0",

could be the point here. Are you still using the version 2020.2 or have you already updated your rider to 2020.3 which was released yesterday (https://blog.jetbrains.com/dotnet/2020/09/16/rider-2020-3-roadmap/ )?

I had a similar problem when trying out .NET 5 with 2020.2 but I didn't investigate too much time because I knew .NET 5 will be fully supported with 2020.3. However, I haven't tried out .NET 5 with 2020.3 either but you should give it a run if you need .NET 5.

0

Hello.

Of course, I have used Rider 2020.3 for the Net 5 solution. Unfortunately it doesn't work.

0

I have this issue as well. It all started after the upgrade to VS2019 16.8, prior to that, both 2020.2 and 2020.3 of Rider worked fine. With that version of VS, all versions of Rider do not work with my VCXPROJ projects. I tracked the issue through this at first:

Restore for vcxproj failed : R̶I̶D̶E̶R̶-̶5̶5̶1̶8̶3̶ (jetbrains.com)

But then they claimed my issue was "different" and opened up another here:

Support restore for C++ projects : RIDER-56511 (jetbrains.com)

Honestly, I'm frustrated at the way this is being handled. Instead of addressing the issue and being transparent, they just say "it isn't supported" when it worked fine prior to Visual Studio v16.8. They have no interest in fixing the issue.

Note: As a workaround, switching the Nuget engine to Console *does* allow the nuget restore and build to succeed, but the IDE analysis shows errors all over the place because it doesn't recognize the package imports as valid (e.g. `using` statements that bring in the nuget package library).

Please help me put pressure on Jetbrains to properly address this regression.

0

I had the same problem after upgrading a project from .net framework 4.6 to 4.7.2. The solution contains vb and c# projects. After googleing a bit i found a solution that worked for me.Maybe you have the same problem. It's that there was a project.assets.json file in some of the obj folders which contains a reference to the old framework.

https://developercommunity.visualstudio.com/content/problem/317628/your-project-does-not-reference-netframeworkversio.html

 

0

Thanks Andreas, however unfortunately that solution does not work for me. I did a `git clean -fdx` at the top of my repo which does delete all obj directories. But even after doing that, it fails. I think the logic inside Rider's Nuget engine is broken somehow, but I'm still curious why this worked prior to the updates.

0

Please sign in to leave a comment.