microsoft / DockerTools

Tools For Docker, including Visual Studio Provisioning and Publishing
Other
173 stars 26 forks source link

Windows container .NET 8 RC: MSB3052: The parameter to the compiler is invalid, '/define:$BUILD_CONFIGURATION' #402

Closed jozefizso closed 9 months ago

jozefizso commented 9 months ago

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:

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.

See: https://github.com/dotnet/dotnet-docker/discussions/4870

Other Information

Output of docker version

Client:
 Cloud integration: v1.0.35+desktop.4
 Version:           24.0.6
 API version:       1.43
 Go version:        go1.20.7
 Git commit:        ed223bc
 Built:             Mon Sep  4 12:32:48 2023
 OS/Arch:           windows/amd64
 Context:           default

Server: Docker Desktop 4.23.0 (120376)
 Engine:
  Version:          24.0.6
  API version:      1.43 (minimum version 1.24)
  Go version:       go1.20.7
  Git commit:       1a79695
  Built:            Mon Sep  4 12:31:39 2023
  OS/Arch:          windows/amd64
  Experimental:     false

Output of docker info

Client:
 Version:    24.0.6
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.11.2-desktop.4
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.21.0-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.20
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v0.1.0-beta.7
    Path:     C:\Program Files\Docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-sbom.exe
  scan: Docker Scan (Docker Inc.)
    Version:  v0.26.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-scan.exe
  scout: Command line tool for Docker Scout (Docker Inc.)
    Version:  0.24.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 82
 Server Version: 24.0.6
 Storage Driver: windowsfilter
  Windows:
 Logging Driver: json-file
 Plugins:
  Volume: local
  Network: ics internal l2bridge l2tunnel nat null overlay private transparent
  Log: awslogs etwlogs fluentd gcplogs gelf json-file local logentries splunk syslog
 Swarm: inactive
 Default Isolation: hyperv
 Kernel Version: 10.0 22621 (22621.1.amd64fre.ni_release.220506-1250)
 Operating System: Microsoft Windows Version 22H2 (OS Build 22621.2134)
 OSType: windows
 Architecture: x86_64
 CPUs: 16
 Total Memory: 31.73GiB
 Name: XPS15-HB55F
 ID: a23ea5d5-10fe-4b8b-a4a5-1c82683021c0
 Docker Root Dir: C:\ProgramData\Docker
 Debug Mode: false
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false
 Product License: Community Engine
patverb commented 9 months ago

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.