How to version the dotnet core assemblies when creating image using a dockerfile
I have a dotnet core 6.0 api running which is building perfectly fine using a docker file and being deployed to aks. We are using Azure devops pipelines. Our team lead wants to version the assemblies now.
Heres what I have tried so far but doesn't seem to work (following is part of a docker file)
ARG assemblyversion # < recently added for versioning
RUN dotnet restore "lpi.csproj" \
--configfile "/build/sources/NuGet.Config" \
-r alpine-x64 /p:configuration=release
RUN dotnet publish "lpi.csproj" \
--no-restore \
-c Release \
-o ./output \
-r alpine-x64 \
--self-contained true \
/p:Version=$assemblyversion \ # < recently added for versioning
/p:PublishReadyToRun=false \
/p:PublishReadyToRunShowWarnings=false \
/p:PublishSingleFile=true
#command used in pipeline to build the image
docker-compose build lpi --build-arg assemblyversion=$(build.buildnumber)
#Getting this error everytime I run the command above.
ERROR: Service 'lpi' failed to build. The command '/bin/sh ..... returned a non-zero code: 1
When I remove the /p:Version=$assemblyversion \ from docker file. It builds fine.
Is it the correct way to version the assemblies when docker is involved?