docker icon indicating copy to clipboard operation
docker copied to clipboard

Mono Gtk# dockerize

Open drstil opened this issue 5 years ago • 0 comments

Im trying to dockerize my Gtk# application on macOS. Works perfectly with msbuild and mono, but not with docker:

This is the code of the Program.cs:

using System;
using Gtk;

namespace GtkSharp
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Application.Init();
            MainWindow win = new MainWindow();
            win.Show();
            Application.Run();
        }
    }
}

Dockerfile:

FROM mono:latest
WORKDIR /app
COPY . ./
RUN msbuild GtkSharp.sln
RUN mono GtkSharp.exe

When building with docker I got the following error:

sudo docker build -t gtk-sharp .
Sending build context to Docker daemon  132.6kB
Step 1/6 : FROM mono:latest
 ---> ecda9bfba7e6
Step 2/6 : WORKDIR /app
 ---> Using cache
 ---> 410a69a4fddf
Step 3/6 : COPY . ./
 ---> 0636d3cf8bec
Step 4/6 : RUN mono --version
 ---> Running in d51fb15246e9
Mono JIT compiler version 6.10.0.104 (tarball Fri Jun 26 19:40:42 UTC 2020)
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(610)
	Suspend:       hybrid
	GC:            sgen (concurrent by default)
Removing intermediate container d51fb15246e9
 ---> 3d316c4f80e6
Step 5/6 : RUN msbuild GtkSharp.sln
 ---> Running in 86d53326fd3f
Microsoft (R) Build Engine version 16.6.0 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "-m" switch.
Build started 08/30/2020 21:49:11.
Project "/app/GtkSharp.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|anycpu".
Project "/app/GtkSharp.sln" (1) is building "/app/GtkSharp/GtkSharp.csproj" (2) on node 1 (default targets).
ResolveAssemblyReferences:
  Primary reference "gtk-sharp".
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "gtk-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
          For SearchPath "{TargetFrameworkDirectory}".
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/gtk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/gtk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/gtk-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/gtk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/gtk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/gtk-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gtk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gtk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gtk-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gtk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gtk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gtk-sharp.exe", but it didn't exist.
          For SearchPath "{GAC}".
          Considered "gtk-sharp", which was not found in the GAC.
          For SearchPath "{RawFileName}".
          Considered treating "gtk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" as a file name, but it didn't exist.
          For SearchPath "bin/Debug/".
          Considered "bin/Debug/gtk-sharp.winmd", but it didn't exist.
          Considered "bin/Debug/gtk-sharp.dll", but it didn't exist.
          Considered "bin/Debug/gtk-sharp.exe", but it didn't exist.
  Primary reference "gdk-sharp".
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "gdk-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
          For SearchPath "{TargetFrameworkDirectory}".
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/gdk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/gdk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/gdk-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/gdk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/gdk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/gdk-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gdk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gdk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gdk-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gdk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gdk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/gdk-sharp.exe", but it didn't exist.
          For SearchPath "{GAC}".
          Considered "gdk-sharp", which was not found in the GAC.
          For SearchPath "{RawFileName}".
          Considered treating "gdk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" as a file name, but it didn't exist.
          For SearchPath "bin/Debug/".
          Considered "bin/Debug/gdk-sharp.winmd", but it didn't exist.
          Considered "bin/Debug/gdk-sharp.dll", but it didn't exist.
          Considered "bin/Debug/gdk-sharp.exe", but it didn't exist.
  Primary reference "glib-sharp".
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "glib-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
          For SearchPath "{TargetFrameworkDirectory}".
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/glib-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/glib-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/glib-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/glib-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/glib-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/glib-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glib-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glib-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glib-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glib-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glib-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glib-sharp.exe", but it didn't exist.
          For SearchPath "{GAC}".
          Considered "glib-sharp", which was not found in the GAC.
          For SearchPath "{RawFileName}".
          Considered treating "glib-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" as a file name, but it didn't exist.
          For SearchPath "bin/Debug/".
          Considered "bin/Debug/glib-sharp.winmd", but it didn't exist.
          Considered "bin/Debug/glib-sharp.dll", but it didn't exist.
          Considered "bin/Debug/glib-sharp.exe", but it didn't exist.
  Primary reference "glade-sharp".
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "glade-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
          For SearchPath "{TargetFrameworkDirectory}".
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/glade-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/glade-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/glade-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/glade-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/glade-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/glade-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glade-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glade-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glade-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glade-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glade-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/glade-sharp.exe", but it didn't exist.
          For SearchPath "{GAC}".
          Considered "glade-sharp", which was not found in the GAC.
          For SearchPath "{RawFileName}".
          Considered treating "glade-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" as a file name, but it didn't exist.
          For SearchPath "bin/Debug/".
          Considered "bin/Debug/glade-sharp.winmd", but it didn't exist.
          Considered "bin/Debug/glade-sharp.dll", but it didn't exist.
          Considered "bin/Debug/glade-sharp.exe", but it didn't exist.
  Primary reference "pango-sharp".
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "pango-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
          For SearchPath "{TargetFrameworkDirectory}".
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/pango-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/pango-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/pango-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/pango-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/pango-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/pango-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/pango-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/pango-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/pango-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/pango-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/pango-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/pango-sharp.exe", but it didn't exist.
          For SearchPath "{GAC}".
          Considered "pango-sharp", which was not found in the GAC.
          For SearchPath "{RawFileName}".
          Considered treating "pango-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" as a file name, but it didn't exist.
          For SearchPath "bin/Debug/".
          Considered "bin/Debug/pango-sharp.winmd", but it didn't exist.
          Considered "bin/Debug/pango-sharp.dll", but it didn't exist.
          Considered "bin/Debug/pango-sharp.exe", but it didn't exist.
  Primary reference "atk-sharp".
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "atk-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
          For SearchPath "{TargetFrameworkDirectory}".
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/atk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/atk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/xbuild-frameworks/.NETFramework/v4.7.2/atk-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/atk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/atk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/atk-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/atk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/atk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/atk-sharp.exe", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/atk-sharp.winmd", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/atk-sharp.dll", but it didn't exist.
          Considered "/usr/lib/mono/4.7.2-api/Facades/atk-sharp.exe", but it didn't exist.
          For SearchPath "{GAC}".
          Considered "atk-sharp", which was not found in the GAC.
          For SearchPath "{RawFileName}".
          Considered treating "atk-sharp, Version=2.4.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" as a file name, but it didn't exist.
          For SearchPath "bin/Debug/".
          Considered "bin/Debug/atk-sharp.winmd", but it didn't exist.
          Considered "bin/Debug/atk-sharp.dll", but it didn't exist.
          Considered "bin/Debug/atk-sharp.exe", but it didn't exist.
GenerateBindingRedirects:
  No suggested binding redirects from ResolveAssemblyReferences.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
  /usr/lib/mono/msbuild/Current/bin/Roslyn/csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:anycpu32bitpreferred /errorreport:prompt /warn:4 /define:DEBUG /highentropyva+ /reference:/usr/lib/mono/4.7.2-api/Mono.Posix.dll /reference:/usr/lib/mono/4.7.2-api/mscorlib.dll /reference:/usr/lib/mono/4.7.2-api/System.Core.dll /reference:/usr/lib/mono/4.7.2-api/System.dll /debug+ /debug:full /optimize- /out:obj/anycpu/Debug/GtkSharp.exe /subsystemversion:6.00 /resource:gtk-gui/gui.stetic,gui.stetic /target:winexe /utf8output /langversion:7.3 gtk-gui/generated.cs MainWindow.cs gtk-gui/MainWindow.cs Program.cs Properties/AssemblyInfo.cs "obj/anycpu/Debug/.NETFramework,Version=v4.7.2.AssemblyAttributes.cs"
  Using shared compilation with compiler from directory: /usr/lib/mono/msbuild/Current/bin/Roslyn
MainWindow.cs(2,7): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
Program.cs(2,7): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
MainWindow.cs(4,35): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
MainWindow.cs(11,49): error CS0246: The type or namespace name 'DeleteEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
gtk-gui/generated.cs(9,35): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
gtk-gui/generated.cs(20,17): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
gtk-gui/generated.cs(25,17): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
Done Building Project "/app/GtkSharp/GtkSharp.csproj" (default targets) -- FAILED.
Done Building Project "/app/GtkSharp.sln" (default targets) -- FAILED.

Build FAILED.

"/app/GtkSharp.sln" (default target) (1) ->
"/app/GtkSharp/GtkSharp.csproj" (default target) (2) ->
(ResolveAssemblyReferences target) -> 
  /usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "gtk-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
  /usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "gdk-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
  /usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "glib-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
  /usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "glade-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
  /usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "pango-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]
  /usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "atk-sharp". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/GtkSharp/GtkSharp.csproj]


"/app/GtkSharp.sln" (default target) (1) ->
"/app/GtkSharp/GtkSharp.csproj" (default target) (2) ->
(CoreCompile target) -> 
  MainWindow.cs(2,7): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
  Program.cs(2,7): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
  MainWindow.cs(4,35): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
  MainWindow.cs(11,49): error CS0246: The type or namespace name 'DeleteEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
  gtk-gui/generated.cs(9,35): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
  gtk-gui/generated.cs(20,17): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]
  gtk-gui/generated.cs(25,17): error CS0246: The type or namespace name 'Gtk' could not be found (are you missing a using directive or an assembly reference?) [/app/GtkSharp/GtkSharp.csproj]

    6 Warning(s)
    7 Error(s)

Time Elapsed 00:00:01.96

Seems that Gtk# library is missing.

docker version:

Client: Docker Engine - Community
 Version:           19.03.12
 API version:       1.40
 Go version:        go1.13.10
 Git commit:        48a66213fe
 Built:             Mon Jun 22 15:41:33 2020
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.12
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.10
  Git commit:       48a66213fe
  Built:            Mon Jun 22 15:49:27 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.2.13
  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Do you need more information? What could I do to add Gtk# to docker build?

Thank you and best!

drstil avatar Aug 30 '20 21:08 drstil