question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fails when building using microsoft/aspnetcore-build docker image

See original GitHub issue

Docker file

# Sample contents of Dockerfile
# Stage 1
FROM microsoft/aspnetcore-build AS builder
WORKDIR /source

# caches restore result by copying csproj file separately
COPY *.csproj .
RUN dotnet restore

# copies the rest of your code
COPY . .
RUN dotnet publish --output /app/ --configuration Release

# Stage 2
FROM microsoft/aspnetcore

WORKDIR /app
COPY --from=builder /app .
ENTRYPOINT ["dotnet", "WebApi.dll"]

Relevant Output

Step 6/16 : RUN dotnet publish --output /app/ --configuration Release
 ---> Running in e3e69838076b
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 91.92 ms for /source/WebAPI.csproj.
  Restore completed in 91.9 ms for /source/WebAPI.csproj.
  Restore completed in 105.77 ms for /source/WebAPI.csproj.
  Restore completed in 43.17 ms for /source/WebAPI.csproj.
  Restore completed in 23.07 ms for /source/WebAPI.csproj.
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL '/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/MSBuildFull/lib/linux/x86_64/libgit2-1196807.so': The specified module or one of its dependencies could not be found. [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:  (Exception from HRESULT: 0x8007007E) [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(String unmanagedDllPath) [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at MSBuildExtensionTask.ContextAwareTask.CustomAssemblyLoader.LoadUnmanagedDll(String unmanagedDllName) [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.LibraryLifetimeObject..ctor() [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    --- End of inner exception stack trace --- [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_opts(Int32 option, UInt32 level, String path) [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.GlobalSettings.SetConfigSearchPaths(ConfigurationLevel level, String[] paths) [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.OpenGitRepo(String repoRoot) [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.Create(String projectDirectory, String gitRepoDirectory, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset, String projectPathRelativeToGitRepoRoot) [/source/Brandmuscle.LocationData.WebAPI.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.1.23/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() [/source/Brandmuscle.LocationData.WebAPI.csproj]
The command '/bin/sh -c dotnet publish --output /app/ --configuration Release' returned a non-zero code: 1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
directhexcommented, Jun 27, 2018

So I’ve tracked this down to the version of OpenSSL in the image is 1.1.0 but the version of libgit2 being used depends on OpenSSL 1.0.0.

This is absolutely #143

0reactions
AArnottcommented, Jun 7, 2018

Try the jesse variant of the base image:

FROM microsoft/aspnetcore-build:2.0-jessie AS base
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to build docker image from docker file, for dotnet ...
I am getting following error at step 10/16. Application builds & runs locally but docker is not able to build image out of...
Read more >
Fails when building using microsoft/aspnetcore ...
So I've tracked this down to the version of OpenSSL in the image is 1.1.0 but the version of libgit2 being used depends...
Read more >
Issue while building Docker with ASP.Net - dotnet restore ...
hi, I'm running into issues trying to build a simple Docker container for my ASP.NET app. The build fails at the docker restore...
Read more >
.Net Core / Docker project fails to build in release with ...
Created a barebones Asp.Net Core 2.1 REST API then added Docker support. Solution builds fine in debug. In release I get bogus errors:...
Read more >
Why isn't my ASP.NET Core app in Docker working?
In this post I described a situation in which I was trying to build a CentOS Docker image to run ASP.NET Core. I...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found