How do I ignore .NET Framework on Linux?

Answered

Hi,

We're using Rider on Windows and Linux. We're migrating to .NET Core, but unfortunately one of our projects will need to stay on .NET Framework 4.7 for now. That's why we need to use multiple target frameworks for some projects: "netcoreapp2.1;net471". When I try to run them with Rider it does not work even though I've selected ".NETCoreApp,Version=2.1" in "Run/Debug Configurations" window. Here's an error:

Microsoft.Common.CurrentVersion.targets(1179, 5): [MSB3644] The reference assemblies for framework ".NETFramework,Version=v4.7.1" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

I guess there should be a way to simply ignore .NET Framework target, but I cannot find it.

Besides that, projects with "net471" are even missing correct syntax highlighting (pretty much everything is red). The only solution I've found out to build the project with Rider is to remove "net471" from csprojs (which is not an option for us as we need quite some transition period).

When building/running with "dotnet" SDK ("dotnet run --project ... --framework netcoreapp2.1") everything works fine.

Any ideas how to work with such project? I'd love to be able to simply select .NET Core 2.1 and just ignore .NET Framework on Linux.

Cheers, 
Damian.

0
6 comments

I actually wanted to IGNORE .Net Framework on Linux and not replace it by Mono.

I did do the following eventually in the csproj:

<TargetFrameworks Condition="'$(BuildNetCoreOnly)' == 'true'">netcoreapp2.2</TargetFrameworks>
<TargetFrameworks Condition="'$(BuildNetCoreOnly)' == 'false'">netcoreapp2.2;net472</TargetFrameworks>

And in the RIder settings for MSBuild global properties:

BuildNetCoreOnly true

 

2

Hi Damian,

Unfortunately, Rider cannot build a project targeting classic framework with .NET Core MSBuild at the moment, see RIDER-7969. The possible workaround is to use Mono MSBuild. You can configure it in "File | Settings | Build, Execution, Deployment | Toolset and Build". Is it an option for you?

1

Would be great if it was possible just to ignore .Net Framework on Linux.

0

Hello Alexander,

As you can notice we have added an ability to pass custom parameters to MSBuild in Rider 2019.1. It means that since Rider 2019.1 you can set FrameworkPathOverride environment variable to use .Net framework assemblies installed by Mono. Does it work for you?

0

Hello Alexander,

Thank you for sharing your workaround, there is one similar request, upvoting for it would help us to understand the interest in it.  

0

Hello @Alexander

years later, the issue persists. If you still face it, please check the thread linked by Olga Diakonova to see my comment with an alternative solution

0

Please sign in to leave a comment.