Failed to load Xamarin Forms project with .NET Standard 2.0 Lib in Rider
Asked Answered
H

2

9

TL;DR; Are Xamarin Forms projects with .NET Standard library 2.0 supported in Rider?

I created a small Xamarin project in Visual Studio 2017.3 (Windows) using the blank forms app multiplatform wizard. Microsoft dropped the the option to create a PCL recently in the Windows version of VS and provides .NET Standard only. Thus I selected that one.

Now I wanted to try out development on Mac directly using Rider so that I don't have to run a Windows VM (I really like Resharper so I am bound to Windows on my Mac)

When I open this project in Rider on Mac OS, it throws a bunch of errors and it looks like all paths are messed up. Opening it in VS for Mac works fine on the other hand.

I then created a new blank project in VS on Mac with PCL and Rider opens it without complaining. So my Question:
Are Xamarin Forms projects with .NET Standard library 2.0 supported in Rider?

  • If they are supported: What am I supposed to do to make it work without breaking the fallback to VS?
  • If not: Are there any plans to support it in the near future?

Some of my Errors:

  • load failed: The imported project "/usr/local/share/dotnet/sdk/2.0.3/Xamarin/Android/Xamarin.Android.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
  • MSBuild targets were not found: Make sure that all SDKs required for projects in this solution are installed, or specify a different MSBuild version in settings.
  • Xamarin.Android SDK was not found: Rider was unable to find Xamarin SDK on this machine. Xamarin-based projects will not be loaded. Please install Xamarin SDK or change toolset
  • The "Xamarin.Forms.Build.Tasks.GetTasksAbi" task could not be loaded from the assembly /Users/kay/.nuget/packages/xamarin.forms/2.5.0.122203/build/netstandard1.0/Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

I think I could start fixing the paths and so on manually, but I am afraid of doing stuff that I don't undersatnd in depth. I used to work with Unity game engine for years but I am new in Xamarin development.

Holmgren answered 5/2, 2018 at 17:36 Comment(4)
Go to File | Settings | Build, Execution, Deployment | Toolset and Build and change MsBuild from mono. I guess you have all Xamarin targets installed in that msbuild.Stets
But Rider uses .net core msbuild (without targets) by default for .net standard projectsStets
@xtmq: GREAT! Selecting /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/15.0/bin/MSBuild.dll instead of /usr/local/share/dotnet/sdk/2.0.3/MSBuild.dll did the trick and the project could be built. At first there were some errors when I tried to deploy on Android. After restarting Rider everything was fine. Please put your comment into an answerHolmgren
Not a problem =) Moreover we are implementing an improved version of MsBuild autodetection to avoid such issues in the future... will be shipped in 2018.1 or 2018.2 =) See youtrack.jetbrains.com/issue/RIDER-7112Stets
S
9

Go to File | Settings | Build, Execution, Deployment | Toolset and Build and change MsBuild from mono. I guess you have all Xamarin targets installed in that msbuild.

Stets answered 6/2, 2018 at 10:23 Comment(0)
F
8

The problem is caused by Rider selecting the wrong MSBuild file to use. The .NET Core SDK installs a version of MSBuild that isn't configured to use the Xamarin SDK.

In Rider goto File > Settings > Build, Execution Deployment > Toolset and Build > Use MSBuild version. Select the MSBuild.dll that does not reside in the .NET Core SDK path:

enter image description here

On Windows that will be under Microsoft Visual Studio on MacOS that appears to be under the Mono.framework.

It is important that you fully restart Rider after making this change. After making the change, Rider will try to do a rebuild and fail. Making it seem like your change didn't work. But it appears that the setting doesn't take effect until Rider is fully restarted.

Faustinafaustine answered 27/3, 2018 at 18:3 Comment(1)
Selecing msbuild v15 solved the issue. Is it that we cannot use msbuild v16 for Xamarin projects for now?Noncooperation

© 2022 - 2024 — McMap. All rights reserved.