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 image with docker file raise exception #1154

Open
mahdiyar021 opened this issue Jan 15, 2025 · 1 comment
Open

build image with docker file raise exception #1154

mahdiyar021 opened this issue Jan 15, 2025 · 1 comment

Comments

@mahdiyar021
Copy link

mahdiyar021 commented Jan 15, 2025

the error from Nerdbank.GitVersioning , get exception building image with docker file

exception :

/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]
/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: Nerdbank.GitVersioning.GitException: An commit object with SHA 8bcda87b7e597bb11b97f6faeb13ac31c9bd5fed could not be found. [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]
/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.GetObjectBySha(GitObjectId sha, String objectType) [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]
/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.GetCommit(GitObjectId sha, Boolean readAuthor) [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]
/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.ManagedGit.GitRepository.GetHeadCommit(Boolean readAuthor) [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]
/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.Managed.ManagedGitContext..ctor(String workingDirectory, String dotGitPath, String committish) [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]
/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.GitContext.Create(String path, String committish, Engine engine) [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]
/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at Nerdbank.GitVersioning.Tasks.GetBuildVersion.ExecuteInner() in D:\a\1\s\src\Nerdbank.GitVersioning.Tasks\GetBuildVersion.cs:line 236 [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]
/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor) [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]
/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018:    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr) [/root/.nuget/packages/nerdbank.gitversioning/3.6.146/build/PrivateP2PCaching.proj]

here it is inside docker file :

# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081


# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
RUN dotnet workload install wasm-tools
COPY ["Directory.Build.props", "."]
COPY ["Datanex/Datanex.Application.csproj", "Datanex/"]
COPY ["Datanex.Frontend.Host.WebAssemly/Datanex.Frontend.Host.WebAssembly.csproj", "Datanex.Frontend.Host.WebAssemly/"]
COPY ["Datanex.Frontend.App/Datanex.Frontend.App.csproj", "Datanex.Frontend.App/"]
COPY ["Datanex.Frontend.Infrastructure/Datanex.Frontend.Infrastructure.csproj", "Datanex.Frontend.Infrastructure/"]
COPY ["Datanex.Frontend.Core/Datanex.Frontend.Core.csproj", "Datanex.Frontend.Core/"]
COPY ["Datanex.Shared/Datanex.Shared.Model.csproj", "Datanex.Shared/"]
COPY ["Datanex.Shared.Core/Datanex.Shared.Core.csproj", "Datanex.Shared.Core/"]
COPY ["Tailwind.Design.Blazor/Tailwind.Design.Blazor.csproj", "Tailwind.Design.Blazor/"]
COPY ["Datanex.Frontend.UseCases/Datanex.Frontend.Application.csproj", "Datanex.Frontend.UseCases/"]
COPY ["Datanex.Shared.Logic/Datanex.Shared.Logic.csproj", "Datanex.Shared.Logic/"]
COPY ["Datanex.Shared.Seeds/Datanex.Shared.Seeds.csproj", "Datanex.Shared.Seeds/"]
COPY ["Datanex.Frontend.Host.WebAssembly.Datalayer/Datanex.Frontend.Host.WebAssembly.DataLayer.csproj", "Datanex.Frontend.Host.WebAssembly.Datalayer/"]
COPY ["SqliteWasmHelper/SqliteWasmHelper.csproj", "SqliteWasmHelper/"]
COPY ["Datanex.Backend.Infrastructure/Datanex.Backend.Infrastructure.csproj", "Datanex.Backend.Infrastructure/"]
COPY ["Datanex.Backend.Domain/Datanex.Backend.Core.csproj", "Datanex.Backend.Domain/"]
COPY ["Datanex.Backend.UseCases/Datanex.Backend.Application.csproj", "Datanex.Backend.UseCases/"]
COPY ["Datanex.Backend.Migration.MySQL/Datanex.Backend.Migrations.MySQL.csproj", "Datanex.Backend.Migration.MySQL/"]
COPY ["Datanex.Backend.Migration.Oracle/Datanex.Backend.Migrations.Oracle.csproj", "Datanex.Backend.Migration.Oracle/"]
COPY ["Datanex.Backend.Migration.PostgreSQL/Datanex.Backend.Migrations.PostgreSQL.csproj", "Datanex.Backend.Migration.PostgreSQL/"]
COPY ["Datanex.Backend.Migration.SqlServer/Datanex.Backend.Migrations.SqlServer.csproj", "Datanex.Backend.Migration.SqlServer/"]
COPY ["Datanex.Backend.Migration.SQLite/Datanex.Backend.Migrations.SQLite.csproj", "Datanex.Backend.Migration.SQLite/"]
COPY ["MigrationGenerate/MigrationGenerate.csproj", "MigrationGenerate/"]

RUN dotnet restore "./Datanex/Datanex.Application.csproj"
COPY . .
WORKDIR "/src/Datanex"
RUN dotnet build "./Datanex.Application.csproj" -c $BUILD_CONFIGURATION -o /app/build

# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Datanex.Application.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Datanex.Application.dll"]

here is my PropertyGroup :

	<PropertyGroup>
		<TargetFramework>net9.0</TargetFramework>
		<Nullable>enable</Nullable>
		<ImplicitUsings>enable</ImplicitUsings>
		<InvariantGlobalization>false</InvariantGlobalization>
		<UserSecretsId>8093f23b-ae37-4fde-b0bf-2655476144d8</UserSecretsId>
		<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
		<EnableSdkContainerDebugging>True</EnableSdkContainerDebugging>
		<DockerfileRunArguments>--link sqlpreview:sqlpreview </DockerfileRunArguments>
	</PropertyGroup>

dotnet build will work but i cannt get publish from app.

i use dotnet sdk because need build migration through run of application cant change to runtime.

docker desktop 4.37.1

@AArnott
Copy link
Collaborator

AArnott commented Jan 16, 2025

I don't build .NET apps with docker. There are several past issues related to docker that you may profit from searching through, but I can't immediately tell you what's wrong or whether I would expect what you're doing to work. As your scenario is outside of my personal needs and interests, I cannot spare the time to investigate further. If you do, and find a change to NB.GV that would do the trick, I'd be willing to review and potentially merge a PR.

--

Sponsorship may be an effective way to lead a contributor of this repo to prioritize the feature. As a free and open source library, all or the majority of its development is done without any monetary benefit to its authors, and all of it is made available free of charge. But sponsorship is very much appreciated and, with agreement from a particular contributor and/or the owning team, can be a great way to support the project and help get your favorite features or bugs addressed in an upcoming version.
If sponsorship to drive completion of a feature or bug fix is an interesting option to you, please let us know. You can reach out to me privately as well.

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