Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a Linux build menu #1830

Merged
merged 37 commits into from
Oct 15, 2018
Merged

Conversation

lillo42
Copy link
Contributor

@lillo42 lillo42 commented Aug 22, 2018

Hi,

In this PR I'm improving linux support to debug.

I've tested on Ubuntu with IDE Jetbrains Rider, I tried to test on Fedora but I had some problem to run NUnit, the test neve begin.

  • Add ShowBuildMenu.sh
  • Modify BuildTool
  • Modify ShowBuildMenu.bat

I create a new file ShowBuildMenu.sh , this file is similar to ShowBuildMenu.bat, but with less function because I think some function are not useful to linux environment, today with this file is possible create and activated a new Database, build and execute test.

I recreated BuildTool to .NET Core and change ShowBuildMenu.bat to use this project, now to debug on Windows is necessary .NET Core installed

@@ -10,8 +10,10 @@
<AssemblyVersion>$(VersionMajor).$(VersionMinor).0.0</AssemblyVersion>
<FileVersion>$(VersionPrefix).0</FileVersion>

<NhAppTargetFrameworks>net461;netcoreapp2.0</NhAppTargetFrameworks>
<NhLibTargetFrameworks>net461;netcoreapp2.0;netstandard2.0</NhLibTargetFrameworks>
<NhAppTargetFrameworks Condition="'$(OS)' == 'Windows_NT'">net461;netcoreapp2.0</NhAppTargetFrameworks>
Copy link
Member

@hazzik hazzik Aug 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of this change? I can debug net461 without problems on my non windows laptop. These days I rarely run Windows at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? Every time I try to build Nhiberte fail, says I don’t have .Net Framework 4.6.1

Have you installed Mono on your laptop? I didn’t try to install mono

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I do have mono.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To debug NHibernate on Linux , Should be necessary install mono?

@lillo42 lillo42 changed the title Add Linux support to debug Improve linux support to debug Sep 1, 2018
Copy link
Member

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am currently testing working under Linux (Debian 9, Stretch).
I have done it only with master current state so far. I will likely update your branch to test it soon.

Some notes about my tests so far:
Under my setup, trying to load the nhibernate-core folder under VS Code triggers failures in Omnisharp (extension required for having basic C# support) if NHibernate project has not been already externally compiled. It tries to compile it but fails loading the ANTLR task. Otherwise once compiled externally, it seems to work.
Compiling under Rider fails on a clean project but succeed when launched a second time, then does no more fail. The failure is due to ANTLR build task too, but this time that is some kind of internal error in the build task: it fails finding some files it is supposed to have generated.

README.md Outdated

If you want to debug NHibernate on Linux, I need install [mono](https://www.mono-project.com/download/stable/)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Development information is in Contributing.md. I think this should be moved in this other file, likely in "Setting up For Development" section.

Maybe also reword to something like:

 Compiling the solution under Linux requires installation of [Mono](https://www.mono-project.com/download/stable) and of the [.NET Core SDK](https://www.microsoft.com/net/download).

<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
<PackageReference Include="System.Security.Permissions" Version="4.4.1" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to this files are undue. But merging master in this PR branch should remove them.

@fredericDelaporte fredericDelaporte changed the title Improve linux support to debug Add a Linux build menu Oct 10, 2018
ShowBuildMenu.sh Outdated
echo "B. Add a test configuration for Firebird."
echo "C. Add a test configuration for SQLite."
echo "D. Add a test configuration for PostgreSQL."
echo "E. Add a test configuration for Oracle(NOT Support yet)."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better remove unsupported databases.

ShowBuildMenu.sh Outdated
echo "."
echo "--- BUILD ---"
echo "D. Build NHibernate (Debug)"
echo "E. Build NHibernate (Release)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the Contributing.md files references the test menu options by letters, better keep the same letters.

echo "E. Build NHibernate (Release)"
echo "."
echo "--- Exit ---"
echo "X. Make the beautiful build menu go away."

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

.editorconfig Outdated
@@ -31,3 +31,6 @@ indent_size = 2
[*.cshtml]
indent_style = space
indent_size = 4

[*.sh]
end_of_line = LF
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise code editors wrecks the sh file by switching it to CRLF. But maybe we should instead remove end_of_line = CRLF from the start of this file. Normally, this is handled by the .gitattributes file (text=auto) anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this needs to be in the .gitattributes, but not in for of text=auto (but rather an explicit)

ShowBuildMenu.sh Outdated
echo "B. Add a test configuration for Firebird."
echo "C. Add a test configuration for SQLite."
echo "D. Add a test configuration for PostgreSQL."
echo "E. Add a test configuration for SQL Server Compact."
Copy link
Member

@fredericDelaporte fredericDelaporte Oct 10, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can SQL Server CE run? It fails on my setup, when tried with Mono. If no one can get it working, we would have better removing it from the menu.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a search if is possible run SQL Server CE on Linux, it isn't possible run SQL Server CE:
Stack Overflow

ShowBuildMenu.sh Outdated

testRun(){
eval "dotnet test ./src/NHibernate.Test/NHibernate.Test.csproj" -f netcoreapp2.0
eval "dotnet test ./src/NHibernate.Test.VisualBasic/NHibernate.Test.VisualBasic.vbproj" -f netcoreapp2.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Limiting tests to netcoreapp2.0. On Windows, we do limit them to net461 when launched from the build menu.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? Isn't better run the tests with netcoreapp2.0 and net461?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mono has issues running all the NHibernate tests. Many of them always fail with Mono.

<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<TargetFramework>netcoreapp2.0</TargetFramework>

This comment was marked as resolved.

Remove SQL Server CE from .sh
set BUILD_TOOL_SLN_PATH=%~dp0Tools\BuildTool\BuildTool.sln
set BUILDTOOL=dotnet run -p %BUILD_TOOL_PATH% -c Release --no-build
set BUILD_TOOL_PATH=%~dp0Tools\BuildTool\bin\BuildTool.dll
set BUILDTOOL=dotnet %BUILD_TOOL_PATH%
Copy link
Member

@fredericDelaporte fredericDelaporte Oct 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be it under Linux or Windows, I was noticing a lag in the build menu for displaying the letter choices prompt. And there was also a startup lag due to relaunching the build.

There were also some differences in the way the build tool was handled between Linux and Windows, without me seeing why they would need to be differently handled.

So I have changed the logic for building only if the binary is not already there, and for running directly the binary (dotnet pathOfBinary) instead of running the project from sources (dotnet run pathToSrc).

This eliminates the lag in the build menu both under Linux and Windows.

For simplicity, I have redirected the build output directly in the bin folder instead of letting it go into Release\netcoreapp2.0.

Let Git handle that, it does a better job of putting the right eol
according to the target OS. (editorconfig could have got the option,
but this was unfortunately rejected: editorconfig/editorconfig#226)
Unfortunately, async generator fails running on my setup.
It needs it in some case under Windows, better do it under Linux too
@fredericDelaporte
Copy link
Member

fredericDelaporte commented Oct 11, 2018

I have added the async generator option.
I am still unable to get it run "out of the box" on my setup, but maybe someone else could see what is wrong, if anything, with the way I am launching it.
I have tried with versions 0.8.2.8, 0.8.2.9, 0.8.2.10 and 0.13.0, all do fail with the same error, being unable to load SQLitePCLRaw.core dependency, seemingly coming from Microsoft.CodeAnalysis.Workspaces.Common, although the generator is supposed to depend on 2.7.0 version of Microsoft.CodeAnalysis.Workspaces.Common while this SQLite dependency seems to be there only since 2.9.2 version.

But when inspecting the 2.7.0 assembly with ILSpy, it actually already depends on it. Manually adding the assembly in the async generator folder solves the trouble.

So it seems this thing is a somewhat "rogue" dependency causing issues only on some setup (Mono version maybe?), and using latest Microsoft.CodeAnalysis.Workspaces.Common versions should solve it since it now explicitly depends on it.

For now I have added a hack for including it in the async generator directory.

In other words, this script now works for launching the async generator, but it would be better to not need the SQLitePCLRaw hack it has.

gitreleasemanager.*
SQLitePCLRaw.core.*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Required for the Linux/Mono hack I have used to get async generator running.

wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
fi

async_generator_path="CSharpAsyncGenerator.CommandLine.$(cat packages.config | grep id=\"CSharpAsyncGenerator.CommandLine | cut -d\" -f4)/tools"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hack for parsing the async generator version out of the packages.config file:

  • Output the content of packages.config
  • Filter out any line not containing id=\"CSharpAsyncGenerator.CommandLine
  • Split the remaining line(s) by " and take the fourth string resulting of the split

If you know a better way, of course propose it.
I need it to build the path to the async generator version we have to use.

CONTRIBUTING.md Outdated
@@ -20,7 +20,7 @@ The main GitHub repository is at [https://github.com/nhibernate/nhibernate-core]

## The Build Menu

**ShowBuildMenu.bat** will be your friend throughout this journey. He's easiest to work with if you make his box bigger by following these steps:
**ShowBuildMenu.bat** will be your friend throughout this journey. A .sh version exists for Linux. He's easiest to work with if you make his box bigger by following these steps:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ShowBuildMenu.bat is referenced as "He"? Shouldn't it be "It"?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

ShowBuildMenu.sh Outdated

if [ ! -d $async_generator_path ]
then
eval "mono nuget.exe install"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just nuget install should be enough. (Without ".exe", and at least in my installation).

hazzik
hazzik previously approved these changes Oct 15, 2018
@fredericDelaporte fredericDelaporte dismissed stale reviews from hazzik and themself via 91b0e3a October 15, 2018 08:00
@fredericDelaporte fredericDelaporte merged commit baee90e into nhibernate:master Oct 15, 2018
@lillo42 lillo42 deleted the linux-support branch October 28, 2018 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants