mono / monodevelop

MonoDevelop is a cross platform .NET IDE
http://www.monodevelop.com
2.84k stars 1.02k forks source link

(Linux/flatpak): can't open .NET Core / .NET Standard projects even if .NET Core is installed #3685

Open knocte opened 6 years ago

knocte commented 6 years ago

Steps to reproduce:

  1. Install alpha version of the flatpak in Debian9. (Version reported: 7.3.2 build 12)
  2. Open a solution that contains a .NET Core project (C#) or a .NET Standard 2.0 project (F#). (Haven't tested with a C# .NET Standard one yet.)
  3. MonoDevelop complains with dialog that says ".NET Core 2.0 SDK is not installed. This is required to build and run .NET Core 2.0 projects."
  4. Close MonoDevelop.
  5. Install .NET Core 2.0 (as per the official instructions).
  6. Reopen MonoDevelop.
  7. Try to open solution again.

Expected results: Should open the solution without errors.

Current results: (Same as step3) dialog with error ".NET Core 2.0 SDK is not installed. This is required to build and run .NET Core 2.0 projects"

mrward commented 6 years ago

Not sure if this is flatpak specific. However there is a known bug detecting .NET Core sdk on certain Linux distributions.

knocte commented 6 years ago

@mrward then it might be flatpak specific because my .NET Core 2.0 got installed in...

$ which dotnet
/usr/bin/dotnet
$ ls -lha /usr/bin/dotnet
lrwxrwxrwx 1 root root 22 Dec 13 16:15 /usr/bin/dotnet -> ../share/dotnet/dotnet

Which is different from what you say in that bug (maybe that was the case in .NET Core v1.x?):

Uses: /opt/dotnet/dotnet With a symlink of the above directory to: /usr/local/bin

directhex commented 6 years ago

There are two parallel efforts on this - the ability to build things outside the sandbox (in progress) and a .NET Core add-on for Flatpak (not started, community project tracked at https://github.com/flathub/com.visualstudio.code/issues/9)

zpodlovics commented 6 years ago

The problem is that flatpak works in an isolated "chrooted" environment. Take a look at File->Open and select "File System" from the left Places list. You will not have /usr/share/dotnet inside the monodevelop flatpak environment. The home directory mapping works well, but other directory mapping is not there yet (I tried almost every possible option and config modification to map /usr/share/dotnet to monodevelop flatpak environment).

Based on the about box texts, I managed to find the monodevelop code that's check the .NET Core SDK paths (you should put the sdk to /usr/share/dotnet).

As a last try (and probably flat out wrong way to do it) I copied (symlink will not work) the /usr/share/dotnet directory to /var/lib/flatpak/runtime/org.freedesktop.Sdk/x86_64/1.4/d6a8c46e30e0518c8f6c8278edf0bd59800193494bbdaeee7393646385247445/files/share/ and viola, I have dotnet sdk showed up in the flatpak environment. Please note, you may also have to copy some library dependency there, ldd will help you to find the missing libs (eg.: libunwind to /usr/lib/x86_64-linux-gnu in flatpak env). You should check each dotnet executable or shared library (eg.: /usr/share/dotnet/shared/Microsoft.NETCore.App/2.0.0/*.so).

You can simply debug the dotnet sdk from a flatpak shell, something like this:

flatpak run --command=sh com.xamarin.MonoDevelop
sh-4.3$ /usr/share/dotnet/dotnet --version
2.0.0
sh-4.3$ ldd /usr/share/dotnet/dotnet 
    linux-vdso.so.1 (0x00007ffd245e6000)
    libdl.so.2 => /lib/libdl.so.2 (0x00007f31cf053000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00007f31cee33000)
    libstdc++.so.6 => /lib/libstdc++.so.6 (0x00007f31ceab3000)
    libm.so.6 => /lib/libm.so.6 (0x00007f31ce7b3000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007f31ce59b000)
    libc.so.6 => /lib/libc.so.6 (0x00007f31ce1f3000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f31cf25b000)

ldd /usr/share/dotnet/shared/Microsoft.NETCore.App/2.0.0/libcoreclr.so 
ldd: warning: you do not have execution permission for `/usr/share/dotnet/shared/Microsoft.NETCore.App/2.0.0/libcoreclr.so'
    linux-vdso.so.1 (0x00007ffc948de000)
    libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00007fa129933000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00007fa129713000)
    librt.so.1 => /lib/librt.so.1 (0x00007fa12950b000)
    libunwind.so.8 => /lib/x86_64-linux-gnu/libunwind.so.8 (0x00007fa1292eb000)
    libdl.so.2 => /lib/libdl.so.2 (0x00007fa1290e3000)
    libuuid.so.1 => /lib/libuuid.so.1 (0x00007fa128edb000)
    libunwind-x86_64.so.8 => /lib/x86_64-linux-gnu/libunwind-x86_64.so.8 (0x00007fa128cbb000)
    libstdc++.so.6 => /lib/libstdc++.so.6 (0x00007fa12893b000)
    libm.so.6 => /lib/libm.so.6 (0x00007fa12863b000)
    libc.so.6 => /lib/libc.so.6 (0x00007fa128293000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fa12a263000)
    liblzma.so.5 => /lib/liblzma.so.5 (0x00007fa12806b000)

After you managed to get a working dotnet (project creation & build & etc) the command line version, you could check it from MonoDevelop about box details:

.NET Core
Runtime: /usr/share/dotnet/dotnet
Runtime Version: 2.0.0
SDK: /usr/share/dotnet/sdk/2.0.0/Sdks
SDK Version: 2.0.0
MSBuild SDKs: /app/lib/mono/msbuild/15.0/bin/Sdks

The simplest solution probably to ship .NET Core SDK and libunwind with MonoDevelop (if possible) until .NET Core SDK packaging flatpak resolved. A repackaged official .NET Core SDK will be fine for this purpose.

chmorgan commented 6 years ago

Any updates on this?