BundlerMinifier
BundlerMinifier copied to clipboard
Support .NET Core 3.1
dotnet bundle
fails on the .NET 3.1 SDK Docker image (mcr.microsoft.com/dotnet/core/sdk:3.1
) using BundlerMinifier.Core version 3.2.435:
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' was not found.
- The following frameworks were found:
3.1.0 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Is anyone working on this or it can be picked up? Can I help? Have the same issue in the project I'm working on right now.
Same problem, real blocker for us
Up.
I agree this is annoying, but it shouldn't be too much of a blocker. Create your own sdk image and add both .net core 2.2 and 3.1, or whatever combo you need. Something like this will work:
RUN apt-get update &&\
apt-get install wget -y &&\
apt-get install apt-transport-https -y &&\
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb &&\
dpkg -i packages-microsoft-prod.deb &&\
apt-get update &&\
apt-get install dotnet-sdk-2.1 -y &&\
apt-get install dotnet-sdk-3.1 -y &&\
apt-get remove --auto-remove apt-transport-https -y &&\
apt-get remove --auto-remove wget -y &&\
apt-get autoremove &&\
apt-get clean
See the file I created here.
Hit this today as well. This is straight hacky, but instead of building a custom sdk image I just made a Docker stage that does the bundling with netcoreapp2.1...
ARG BUILD_IMAGE=mcr.microsoft.com/dotnet/core/sdk:3.1.101-alpine
ARG BUNDLE_IMAGE=mcr.microsoft.com/dotnet/core/sdk:2.1-alpine
ARG RUNTIME_IMAGE=mcr.microsoft.com/dotnet/core/aspnet:3.1.1-alpine
# Copy csproj and restore
FROM ${BUILD_IMAGE} AS build
WORKDIR /app
COPY *.csproj .
RUN dotnet restore
# Copy everything else and bundle (must use 2.1 because of issue with BundlerMinifier.Core)
FROM ${BUNDLE_IMAGE} AS bundle
WORKDIR /app
COPY . .
# Rename current .csproj's to .csproj2
RUN for file in *.csproj; do mv "$file" "${file%.*}.csproj2"; done
# Write temporary bundle.csproj with only the BundlerMinifier tool
RUN echo "<Project Sdk=\"Microsoft.NET.Sdk.Web\"><PropertyGroup><TargetFramework>netcoreapp2.1</TargetFramework></PropertyGroup><ItemGroup><DotNetCliToolReference Include=\"BundlerMinifier.Core\" Version=\"3.2.435\" /></ItemGroup></Project>" > bundle.csproj
# Restore the tool, run bundle, and remove the temporary csproj
RUN dotnet restore && dotnet bundle && rm bundle.csproj
# Rename original .csproj's back
RUN for file in *.csproj2; do mv "$file" "${file%.*}.csproj"; done
# Pickup on original build image, copy from bundle image (includes bundled/minified files now), and publish app
FROM build AS build2
WORKDIR /app
COPY --from=bundle /app ./
RUN dotnet publish -c Release -o out
# Copy from final build and run
FROM ${RUNTIME_IMAGE}
WORKDIR /app
COPY --from=build2 /app/out ./
ENTRYPOINT ["dotnet", "myapp.dll"]
I'm rather upset the bundle output didn't even state it was running a dotnet bundle
since I was overseeing a migration of a project from 2.2 -> .NET 5, and this was causing me issues for a good few hours until I figured out what was happened. My initial solution was also to just add a 2.2 build image to my Dockerfile so glad to see it's worked for someone else.
Interestingly I'm using the latest version which supposedly has added 3.1 support but was still getting this error...
Same problem. Have make migration from 3.1 to net 5 and I can't minify anymore. I have the 3.1.12 framework, but yet I cannot minify.
I am upset that I have to waste time because no version for .NET 5 exists.
I found this https://github.com/rwasef1830/BundlerMinifier, but I can't use and you can't add into your csproj as DotNetCliToolReference
Still a problem in .NET 6. What is the recommended workaround or alternative?