Skip to content

Build STROOP on Linux platforms (with Mono and Docker) #72

@norbjd

Description

@norbjd

Hello ✋,

I'd like to help on this project but I am not working on a Windows platform. I'm not an expert in C# too. I'm just a regular developer impressed by the work made on this project to find new strategies for the different challenges (ABC and others).

So, I'm trying to build the application under Linux environment using Mono, an open-source implementation of Microsoft's .NET Framework. I'm using a Docker image to create reproducible builds, using an official base Mono image based on Debian 9 (Stretch).

You can see the different updates I've made here on my fork of STROOP and the branch (linux-build) I've created : Development...norbjd:6f219e3c6efa509a045504f4163db9c8c43ceb70.

To summarize quickly, here are the steps I have made :

  • copy STROOP/STROOP.csproj to STROOP/STROOP_linux.csproj to avoid side effects with current builds. I'll use and modify this STROOP/STROOP_linux.csproj for the Linux build.
  • rename some files in STROOP/TTC folder (apparently, Windows does not matter about case but Linux does), precisely replacing Ttc to TTC
  • change PreBuildEvent and PostBuildEvent to match Linux commands (cp instead of xcopy and rm instead of del). Not sure that the PostBuildEvent makes sense, but I did it just for the sake of consistency

The difference between STROOP/STROOP.csproj and STROOP/STROOP_linux.csproj can be seen using diff tool :

437,461c437,461
<     <Compile Include="Ttc\TtcPendulum2.cs" />
<     <Compile Include="Ttc\TtcRng2.cs" />
<     <Compile Include="Ttc\TtcSaveStateByteIterator.cs" />
<     <Compile Include="Ttc\TtcUtilities.cs" />
<     <Compile Include="Ttc\TtcSimulation.cs" />
<     <Compile Include="Ttc\TtcRng.cs" />
<     <Compile Include="Ttc\TtcMain.cs" />
<     <Compile Include="Ttc\TtcSaveState.cs" />
<     <Compile Include="Ttc\TtcWheel.cs" />
<     <Compile Include="Ttc\TtcTreadmill.cs" />
<     <Compile Include="Ttc\TtcThwomp.cs" />
<     <Compile Include="Ttc\TtcSpinningTriangle.cs" />
<     <Compile Include="Ttc\TtcSpinner.cs" />
<     <Compile Include="Ttc\TtcRotatingTriangularPrism.cs" />
<     <Compile Include="Ttc\TtcPusher.cs" />
<     <Compile Include="Ttc\TtcRotatingBlock.cs" />
<     <Compile Include="Ttc\TtcPitBlock.cs" />
<     <Compile Include="Ttc\TtcPendulum.cs" />
<     <Compile Include="Ttc\TtcHand.cs" />
<     <Compile Include="Ttc\TtcElevator.cs" />
<     <Compile Include="Ttc\TtcDust.cs" />
<     <Compile Include="Ttc\TtcCog.cs" />
<     <Compile Include="Ttc\TtcBobomb.cs" />
<     <Compile Include="Ttc\TtcAmp.cs" />
<     <Compile Include="Ttc\TtcObject.cs" />
---
>     <Compile Include="TTC\TTCPendulum2.cs" />
>     <Compile Include="TTC\TTCRng2.cs" />
>     <Compile Include="TTC\TTCSaveStateByteIterator.cs" />
>     <Compile Include="TTC\TTCUtilities.cs" />
>     <Compile Include="TTC\TTCSimulation.cs" />
>     <Compile Include="TTC\TTCRng.cs" />
>     <Compile Include="TTC\TTCMain.cs" />
>     <Compile Include="TTC\TTCSaveState.cs" />
>     <Compile Include="TTC\TTCWheel.cs" />
>     <Compile Include="TTC\TTCTreadmill.cs" />
>     <Compile Include="TTC\TTCThwomp.cs" />
>     <Compile Include="TTC\TTCSpinningTriangle.cs" />
>     <Compile Include="TTC\TTCSpinner.cs" />
>     <Compile Include="TTC\TTCRotatingTriangularPrism.cs" />
>     <Compile Include="TTC\TTCPusher.cs" />
>     <Compile Include="TTC\TTCRotatingBlock.cs" />
>     <Compile Include="TTC\TTCPitBlock.cs" />
>     <Compile Include="TTC\TTCPendulum.cs" />
>     <Compile Include="TTC\TTCHand.cs" />
>     <Compile Include="TTC\TTCElevator.cs" />
>     <Compile Include="TTC\TTCDust.cs" />
>     <Compile Include="TTC\TTCCog.cs" />
>     <Compile Include="TTC\TTCBobomb.cs" />
>     <Compile Include="TTC\TTCAmp.cs" />
>     <Compile Include="TTC\TTCObject.cs" />
1026,1029c1026,1029
<     <PostBuildEvent>del "$(TargetDir)OpenTK.dll.config"
< del "$(TargetDir)OpenTK.GLControl.xml"
< del "$(TargetDir)OpenTK.xml"
< del "$(TargetDir)STROOP.exe.config"
---
>     <PostBuildEvent>rm -f "$(TargetDir)OpenTK.dll.config"
> rm -f "$(TargetDir)OpenTK.GLControl.xml"
> rm -f "$(TargetDir)OpenTK.xml"
> rm -f "$(TargetDir)STROOP.exe.config"
1033c1033
<     <PreBuildEvent>xcopy /E /Y /I "$(ProjectDir)Resources" "$(TargetDir)Resources" /D</PreBuildEvent>
---
>     <PreBuildEvent>cp -R "$(ProjectDir)Resources" "$(TargetDir)Resources"</PreBuildEvent>

When building, I've got some errors :

"/app/STROOP.sln" (default target) (1) ->
"/app/STROOP/STROOP.csproj" (default target) (2) ->
(CoreCompile target) -> 
  Controls/VisualLinkLineText.cs(10,28): error CS0234: The type or namespace name 'TextFormatting' does not exist in the namespace 'System.Windows.Media' (are you missing an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/DecompilerView.xaml.cs(11,22): error CS0234: The type or namespace name 'Controls' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/DecompilerView.xaml.cs(13,22): error CS0234: The type or namespace name 'Documents' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/DecompilerView.xaml.cs(16,28): error CS0234: The type or namespace name 'Imaging' does not exist in the namespace 'System.Windows.Media' (are you missing an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/DecompilerView.xaml.cs(17,22): error CS0234: The type or namespace name 'Navigation' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/DecompilerView.xaml.cs(18,22): error CS0234: The type or namespace name 'Shapes' does not exist in the namespace 'System.Windows' (are you missing an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/VisualLinkLineText.cs(43,25): error CS0246: The type or namespace name 'TextRun' could not be found (are you missing a using directive or an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/VisualLinkLineText.cs(59,47): error CS0246: The type or namespace name 'QueryCursorEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/VisualLinkLineText.cs(68,45): error CS0246: The type or namespace name 'MouseButtonEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/VisualLinkLineText.cs(43,33): error CS0012: The type 'TextRun' is defined in an assembly that is not referenced. You must add a reference to assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. [/app/STROOP/STROOP.csproj]
  Controls/DecompilerView.xaml.cs(26,43): error CS0246: The type or namespace name 'UserControl' could not be found (are you missing a using directive or an assembly reference?) [/app/STROOP/STROOP.csproj]

I have fixed some of them by removing some unused (maybe?) using imports, more precisely in STROOP/Controls/DecompilerView.xaml.cs (see this commit : norbjd@c217ea5). This may be wrong (it may add some side effects?), but it removed some errors :

"/app/STROOP.sln" (default target) (1) ->
"/app/STROOP/STROOP.csproj" (default target) (2) ->
(CoreCompile target) -> 
  Controls/VisualLinkLineText.cs(10,28): error CS0234: The type or namespace name 'TextFormatting' does not exist in the namespace 'System.Windows.Media' (are you missing an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/DecompilerView.xaml.cs(21,43): error CS0246: The type or namespace name 'UserControl' could not be found (are you missing a using directive or an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/VisualLinkLineText.cs(43,25): error CS0246: The type or namespace name 'TextRun' could not be found (are you missing a using directive or an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/VisualLinkLineText.cs(59,47): error CS0246: The type or namespace name 'QueryCursorEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/VisualLinkLineText.cs(68,45): error CS0246: The type or namespace name 'MouseButtonEventArgs' could not be found (are you missing a using directive or an assembly reference?) [/app/STROOP/STROOP.csproj]
  Controls/VisualLinkLineText.cs(43,33): error CS0012: The type 'TextRun' is defined in an assembly that is not referenced. You must add a reference to assembly 'PresentationCore, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. [/app/STROOP/STROOP.csproj]

I have also noticed that some warnings appeared before the errors (which may explain the errors) :

"/app/STROOP.sln" (default target) (1) ->
"/app/STROOP/STROOP.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 "PresentationCore". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/STROOP/STROOP.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 "PresentationFramework". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/STROOP/STROOP.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 "UIAutomationProvider". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/STROOP/STROOP.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 "WindowsFormsIntegration". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/app/STROOP/STROOP.csproj]

The build could not locate the assemblies PresentationCore, PresentationFramework, UIAutomationProvider and WindowsFormsIntegration. Indeed, WPF (Windows Presentation Foundation) APIs are not implemented by Mono. That explains why PresentationCore is not available for example.

By not using WPF APIs, it will be possible to build STROOP for Linux (and probably MacOS). It may (or not) attract some developers like me to contribute to this project. The problem is : I don't know how many efforts one have to make to not use WPF APIs. @scob will probably be able to answer this question. Do you think it's worth it? Maybe I'm chasing ghosts here.

If you have any questions, feel free to ask.

Thank you very much and great job on this tool once again. 👍

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions