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

Build the docker image failed #135

Closed
jeancz opened this issue Nov 23, 2018 · 5 comments
Closed

Build the docker image failed #135

jeancz opened this issue Nov 23, 2018 · 5 comments

Comments

@jeancz
Copy link

jeancz commented Nov 23, 2018

I have got this error when I tried to build the image on Windows.

Step 8/14 : RUN dotnet build src/BaGet -c Release -o /app
 ---> Running in 5ba65c918ade
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 48.98 ms for /src/src/BaGet.Core/BaGet.Core.csproj.
  Restore completed in 48.98 ms for /src/src/BaGet.Azure/BaGet.Azure.csproj.
  Restore completed in 25.99 ms for /src/src/BaGet/BaGet.csproj.
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/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 shared library '/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/lib/linux/x86_64/libgit2-6311e88.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libssl.so.1.0.0: cannot open shared object file: No such file or directory [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(String unmanagedDllPath) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.LoadUnmanagedDllFromPath(String unmanagedDllPath) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at MSBuildExtensionTask.ContextAwareTask.CustomAssemblyLoader.LoadUnmanagedDll(String unmanagedDllName) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.LoadNativeLibrary() [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    --- End of inner exception stack trace --- [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_opts(Int32 option, UInt32 level, String path) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.GlobalSettings.SetConfigSearchPaths(ConfigurationLevel level, String[] paths) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.GitExtensions.OpenGitRepo(String pathUnderGitRepo) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.Create(String projectDirectory, String gitRepoDirectory, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset, String projectPathRelativeToGitRepoRoot) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() [/src/src/BaGet.Core/BaGet.Core.csproj]

Build FAILED.

/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/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 shared library '/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/lib/linux/x86_64/libgit2-6311e88.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libssl.so.1.0.0: cannot open shared object file: No such file or directory [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.InternalLoadUnmanagedDllFromPath(String unmanagedDllPath) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.LoadUnmanagedDllFromPath(String unmanagedDllPath) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at MSBuildExtensionTask.ContextAwareTask.CustomAssemblyLoader.LoadUnmanagedDll(String unmanagedDllName) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.LoadNativeLibrary() [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    --- End of inner exception stack trace --- [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_opts(Int32 option, UInt32 level, String path) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at LibGit2Sharp.GlobalSettings.SetConfigSearchPaths(ConfigurationLevel level, String[] paths) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.GitExtensions.OpenGitRepo(String pathUnderGitRepo) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.VersionOracle.Create(String projectDirectory, String gitRepoDirectory, ICloudBuild cloudBuild, Nullable`1 overrideBuildNumberOffset, String projectPathRelativeToGitRepoRoot) [/src/src/BaGet.Core/BaGet.Core.csproj]
/root/.nuget/packages/nerdbank.gitversioning/2.2.13/build/Nerdbank.GitVersioning.targets(63,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() [/src/src/BaGet.Core/BaGet.Core.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.16
The command '/bin/sh -c dotnet build src/BaGet -c Release -o /app' returned a non-zero code: 1
@loic-sharma
Copy link
Owner

That's strange. The Dockerfile sets the environment variable IS_DOCKER (see this code), which should skip the Nerdbank.GitVersioning dependency (see this code). It seems that this isn't working on Windows for whatever reason.

@loic-sharma
Copy link
Owner

It seems the issue is that Docker's environment variables are process-level on Windows. We should instead use an MSBuild property to set the IS_DOCKER property.

@jeancz
Copy link
Author

jeancz commented Nov 28, 2018

You are right, the problem is in the Directory.Build.props file.

I have maybe some old version, but I am pretty sure, that I cloned the repository on 11/22/2018.

Here is my old file version, as you can see some variable conditions missing ...

<Project>

  <PropertyGroup>
    <Product>BaGet</Product>
    <PackageProjectUrl>https://loic-sharma.github.io/BaGet/</PackageProjectUrl>
    <PackageLicenseUrl>https://github.com/loic-sharma/BaGet/blob/master/LICENSE</PackageLicenseUrl>
    <RepositoryUrl>https://github.com/loic-sharma/BaGet</RepositoryUrl>
    <RepositoryType>git</RepositoryType>
    <PublishRepositoryUrl>true</PublishRepositoryUrl>

    <LangVersion>7.1</LangVersion>
  </PropertyGroup>

  <PropertyGroup>
    <DebugType>portable</DebugType>
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63127-02" PrivateAssets="All"/>
  </ItemGroup>

  <ItemGroup Condition="$(IsPackable) == 'true'">
    <PackageReference Include="Nerdbank.GitVersioning" Version="2.2.13" PrivateAssets="all" />
  </ItemGroup>

</Project>

@jeancz jeancz closed this as completed Nov 28, 2018
@loic-sharma
Copy link
Owner

Did updating your project fix the issue?

@jeancz
Copy link
Author

jeancz commented Nov 29, 2018

Yes, it is working now. Thanks :-)

loic-sharma added a commit that referenced this issue Sep 15, 2019
This replaces `Nerdbank.GitVersioning` with Azure DevOps queue-time variables for versioning. This is a simpler model that should avoid issues like #211 and #135.

Part of #57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants