What some of the tutorials I’ve found for using dotnet with mono miss, are these issues:



This will give you the following error:​​​​

/usr/share/dotnet/sdk/2.2.203/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(5,5): Error MSB4018: The "GenerateDepsFile" task failed unexpectedly.
System.TypeLoadException: Could not load type of field 'Microsoft.NET.Build.Tasks.DependencyContextBuilder:_filteredPackages' (12) due to: Could not resolve type with token 01000027 from typeref (expected class 'NuGet.Packaging.Core.PackageIdentity' in assembly 'NuGet.Packaging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35') assembly:NuGet.Packaging, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35 type:NuGet.Packaging.Core.PackageIdentity member:(null)
at Microsoft.NET.Build.Tasks.TaskBase.Execute () [0x00000] in :0
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00029] in <58f0218f988743a48dd7c84cbe933f4e>:0
at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x001f6] in <58f0218f988743a48dd7c84cbe933f4e>:0 (MSB4018) (. . .

However, the solution to downgrade to 2.2.105 is not available in the most recent releases for ubuntu 18.04 (it would require selecting a previous snapshot but this doesn’t seem to be possible with the microsoft repository for ubuntu 18.04 https://packages.microsoft.com/ubuntu/18.04/prod

Instead you should downgrade to 2.1.105 SDK and runtime envirnoment 2.0.7. To see how I got this look here:


After you install the right SDK version:

joel@joel-Aspire-E5-575G:~$ sudo apt-cache search dotnet | grep 2.1.105
dotnet-sdk-2.1.105 - Microsoft .NET Core SDK - 2.1.105
joel@joel-Aspire-E5-575G:~$sudo apt install dotnet-sdk-2.1.105

You can see what the corresponding runtime should be to your SDK by doing this: (here we see SDK 2.1.105 is supposed to use runtime 2.0.7, bolded text is my own)

joel@joel-Aspire-E5-575G:~$ dotnet --info
.NET Command Line Tools (2.1.105)

Product Information:
Version: 2.1.105
Commit SHA-1 hash: 141cc8d976

Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /usr/share/dotnet/sdk/2.1.105/

Microsoft .NET Core Shared Framework Host

Version : 2.0.7
Build : 2d61d0b043915bc948ebf98836fefe9ba942be11

You can search for it like so:

joel@joel-Aspire-E5-575G:~$ sudo apt-cache search dotnet | grep 2.0.7
dotnet-hostfxr-2.0.7 - Microsoft .NET Core Host FX Resolver - 2.0.7 2.0.7
dotnet-hosting-2.0.7 - Microsoft .NET Core 2.0.7 Linux Server Hosting
dotnet-runtime-2.0.7 - Microsoft .NET Core Runtime - 2.0.7 Microsoft.NETCore.App 2.0.7

So to install everything

joel@joel-Aspire-E5-575G:~$ sudo apt install dotnet-sdk-2.1.105  dotnet-runtime-2.0.7 dotnet-hosting-2.0.7 dotnet-hostfxr-2.0.7
joel@joel-Aspire-E5-575G:~$ sudo apt install mono-devel mono-complete monodevelop

And then the instructions for running your “ASP.NET Core Web API” in mono will work here: https://www.c-sharpcorner.com/article/create-net-core-web-api-c-sharp-in-monodevelop-on-ubuntu-18-04/

The version of mono I am using (so I know it works with this) is

joel@joel-Aspire-E5-575G:~$ mono --version
Mono JIT compiler version (tarball Thu Apr 11 09:02:17 UTC 2019)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(600)
Suspend: hybrid
GC: sgen (concurrent by default)


Leave a Reply

Avatar placeholder

This site uses Akismet to reduce spam. Learn how your comment data is processed.