Building Windows docker image with a build from the latest .NET 8 samples results in warning being emited during dotnet build phase.
Steps to Reproduce
Use Visual Studio 2022 17.8.0 Preview 1.0 to create a new .NET 8 Web API project with a Windows container.
The sample creates a Dockerfile with these build steps:
FROM mcr.microsoft.com/dotnet/sdk:8.0-nanoserver-ltsc2022 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["ppas.csproj", "."]
RUN dotnet restore "./ppas.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "ppas.csproj" -c $BUILD_CONFIGURATION -o /app/build
When building image from this definition, the warning MSB3052: The parameter to the compiler is invalid, '/define:$BUILD_CONFIGURATION' will be issued.
The application will be compiled into the literal $BUILD_CONFIGURATION folder instead of the Release folder.
Expected behavior:
.NET app should be built using the value of the $BUILD_CONFIGURATION argument in Dockerfile.
The sample Dockerfile for Windows Server containers must use the %BUILD_CONFIGURATION% instead of $BUILD_CONFIGURATION.
This is fixed in 17.8 preview 2 to scaffold the docker files with %BUILD_CONFIGURATION% instead just as you pointed out. It was only a mistake in preview 1.
Describe the Bug
Building Windows docker image with a build from the latest .NET 8 samples results in warning being emited during
dotnet build
phase.Steps to Reproduce
Use Visual Studio 2022 17.8.0 Preview 1.0 to create a new .NET 8 Web API project with a Windows container.
The sample creates a
Dockerfile
with these build steps:When building image from this definition, the warning
MSB3052: The parameter to the compiler is invalid, '/define:$BUILD_CONFIGURATION'
will be issued.The application will be compiled into the literal
$BUILD_CONFIGURATION
folder instead of theRelease
folder.Expected behavior:
.NET app should be built using the value of the
$BUILD_CONFIGURATION
argument in Dockerfile.The sample Dockerfile for Windows Server containers must use the
%BUILD_CONFIGURATION%
instead of$BUILD_CONFIGURATION
.See: https://github.com/dotnet/dotnet-docker/discussions/4870
Other Information
Output of
docker version
Output of
docker info