CoreCRM development record-build and test on macOS to implement. NET Core in Travis-CI [No watermarks], corecrmtravis-ci

Source: Internet
Author: User
Tags install openssl xunit

CoreCRM development record-build and test on macOS to implement. NET Core in Travis-CI [No watermarks], corecrmtravis-ci

In the previous article, I mentioned: In order to use the "national goods", I delegated the construction and testing on Linux to DaoCloud, but Travis-CI cannot be used. Fortunately, this product supports the macOS system. Therefore, CoreCRM's building and testing tasks on macOS are handed over to it.

I think there are already many blog articles on how to use Travis-CI in China, so I don't need to bother here. Of course, the best article is actually the Travis-CI document; the best help is on StackOverflow and GitHub. If I still feel that my English is not enough and I cannot understand these sites, I think there are only two ways to do it: 1. learn English well; 2. Give up as a programmer.

Here I want to record two problems encountered when using Travis-CI to build CoreCRM. In the process of solving these two problems, I found that these two problems are very common, basically in the present.. NET Core (Microsoft. NETCore. app 1.1.0) is a problem that must be encountered. After combining a lot of GitHub issue, I used 10 commit to solve these two problems.

1. OpenSSL Is Not Installed

The first problem encountered is that the following exception occurs during dotnet restore execution:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Crypto' threw an exception. ---> System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'System.Security.Cryptography.Native': The specified module could not be found.    (Exception from HRESULT: 0x8007007E)        at Interop.CryptoInitializer.EnsureOpenSslInitialized()        at Interop.CryptoInitializer..cctor()        --- End of inner exception stack trace ---        at Interop.Crypto..cctor()        --- End of inner exception stack trace ---        at Interop.Crypto.GetRandomBytes(Byte* buf, Int32 num)        at System.IO.Path.GetCryptoRandomBytes(Byte* bytes, Int32 byteCount)        at System.IO.Path.GetRandomFileName()        at Microsoft.DotNet.InternalAbstractions.TemporaryDirectory..ctor()        at Microsoft.Extensions.EnvironmentAbstractions.DirectoryWrapper.CreateTemporaryDirectory()        at Microsoft.DotNet.Configurer.NuGetPackagesArchiver..ctor()        at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel)        at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)        at Microsoft.DotNet.Cli.Program.Main(String[] args)/Users/travis/ line 57: 5310 Abort trap: 6 dotnet restore CoreCRM

This problem occurs because the dynamic library libssl of openssl is not correctly installed. In the Travis-CI environment, Homebrew can be used to install missing components. However, there is a problem that openssl must be manually linked to/usr/local/lib. I first used the link feature provided by Homebrew, but it did not solve this problem. I had to use ln to solve it myself:

before_install:- brew install openssl- ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/- ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/

Add the above 'before _ install' to the corresponding location to solve the problem above. (It took about three hours to solve the problem)

2. Too many open files

For performance and security considerations, each system limits the number of files that can be opened by a process. However, the macOS restrictions seem to be extremely strict. After the restore process is completed, test is executed. The following error is returned: .NET CLI test runner (64-bit .NET Core osx.10.12-x64)Unhandled Exception: System.IO.IOException: Too many open files    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)    at Interop.CheckIo[TSafeHandle](TSafeHandle handle, String path, Boolean isDirectory, Func`2 errorRewriter)    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(Func`1 fdFunc)    at System.ConsolePal.OpenStandardOutput()    at Xunit.Runner.DotNet.Program.UseTestSinksWithStandardOutputStreams()    at Xunit.Runner.DotNet.Program.Run(String[] args)    at Xunit.Runner.DotNet.Program.Main(String[] args)SUMMARY: Total: 1 targets, Passed: 0, Failed: 1.

Some of the solutions found at the beginning may take a long time, but they are all for some Mono methods. After further searching, we found a solution on StackExchange to increase the number of files allowed to be opened:

script:- ulimit -n 2048- dotnet test CoreCRM.IntegrationTest

In this way, you can solve the problem of opening too many files.

Complete. travis. yml can be viewed in my GitHub or Coding. NET. When I wrote this article, only the configuration files in the version library were used for the three CI platforms. In the future, I will download the configuration files of AppVeyor and DaoCloud and put them in the version library so that you can use these templates to implement your CI process. However, at this time, I have not achieved the ultimate test, but I still can see whether all tests are successful or fail. With the subsequent development, I will make the test end more detailed so that I can see online which tests are faulty.

Coding. NET:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.