user1044169
user1044169

Reputation: 2866

Bundles are not generated when running dotnet build in docker

I have an ASP.NET Core 5 application. For js/css bundling, I installed BuildBundlerMinifier nuget package and added bundleconfig.json to the root of the project.

The project runs under Docker with the following Dockerfile:

FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["BundleTest/BundleTest.csproj", "BundleTest/"]
RUN dotnet restore "BundleTest/BundleTest.csproj"
COPY . .
WORKDIR "/src/BundleTest"
RUN dotnet build "BundleTest.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "BundleTest.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "BundleTest.dll"]

If I run the project under Docker from Visual Studio, the bundles folder is created:

enter image description here

But, if I run the docker build and run commands from the command prompt, the bundles folder is NOT created. Also, the bundles folder is not created when I execute the docker build command from the Azure CI/CD:

enter image description here

What is missing? Why the BuildBundlerMinifier is not executed when the docker build command is executed from the command prompt?

Upvotes: 0

Views: 286

Answers (1)

Qiang Fu
Qiang Fu

Reputation: 8451

In my project, all bundles are generated automatically even before build. So why not build it in visual studio first. After bundles are there, Then use docker build.

Upvotes: 0

Related Questions