Skip to content

Unable to run jammy-chiseled from Visual Studio #409

@Arclight3

Description

@Arclight3

Describe the Bug

I have a .net 7 Web API with this config:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <UserSecretsId>MySecretGuid</UserSecretsId>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <NoWarn>$(NoWarn);1591</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.13" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
  </ItemGroup>
</Project>

I am using the latest version of Visual Studio (17.8.1) and Docker (4.25.2).
I have the .net 7 (7.0.311) and .net 8 (8.0.100) SDKs installed (latest patches).

I have this Dockerfile:

# Build stage/image
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy AS build

WORKDIR /source
COPY ["nuget.config", "."]
COPY ["MyApp/MyApp.Api.csproj", "MyApp.Api/"]

ENV NUGET_XMLDOC_MODE none
RUN dotnet restore "MyApp.Api/MyApp.Api.csproj" --configfile nuget.config

COPY [".", "."]
WORKDIR "/source/MyApp.Api"
ARG buildnumber
RUN dotnet publish "MyApp.Api.csproj" --no-restore -c Release -p:Version=$buildnumber -o /app

# Final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:7.0-jammy-chiseled as final
WORKDIR /app
COPY --from=build /app .

EXPOSE 8080
ENV ASPNETCORE_URLS=http://*:8080

ENTRYPOINT ["./MyApp.Api"]

My launchSettings.json is:

{
  "profiles": {
    "Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "dev",
        "ASPNETCORE_URLS": "http://+:8080"
      },
      "publishAllPorts": true
    }
  },
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:51940",
      "sslPort": 0
    }
  }
}

Initially I was using the mcr.microsoft.com/dotnet/aspnet:7.0 base image and everything worked fine.
After I update the Dockerfile to use the mcr.microsoft.com/dotnet/aspnet:7.0-jammy-chiseled image (or the 8.0-jammy-chiseled), I get this error in Visual Studio when I run the application in Docker:

1>ERROR: failed to solve: process "/bin/sh -c dotnet restore --configfile nuget.config" did not complete successfully: exit code: 1
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: The "ContainerBuildAndLaunch" task failed unexpectedly.
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: File name: 'Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at Microsoft.VisualStudio.Containers.Tools.Common.Client.DockerPathHelper.FindDockerCliPath()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at Microsoft.VisualStudio.Containers.Tools.Common.Prerequisites.DockerForWindowsDriveSharingPrerequisite.<EvaluateAsync>d__0.MoveNext()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at Microsoft.VisualStudio.Containers.Tools.Common.Prerequisites.CompositePrerequisite.<EvaluateAsync>d__2.MoveNext()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at Microsoft.VisualStudio.Containers.Tools.Tasks.ContainerBuildTask.<EvaluateBuildPrerequisitesAsync>d__31.MoveNext()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at Microsoft.VisualStudio.Containers.Tools.Tasks.ContainerBuildTask.<ExecuteAsync>d__30.MoveNext()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: --- End of stack trace from previous location where exception was thrown ---
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at Microsoft.VisualStudio.Containers.Tools.Tasks.ContainerBuildTask.Execute()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: 
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: WRN: Assembly binding logging is turned OFF.
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: Note: There is some performance penalty associated with assembly bind failure logging.
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018: To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
1>C:\Users\MyUser\.nuget\packages\microsoft.visualstudio.azure.containers.tools.targets\1.19.5\build\Container.targets(215,5): error MSB4018:
1>Done building project "MyApp.Api.csproj" -- FAILED.

I have read and followed the instructions from this page: https://github.com/dotnet/dotnet-docker/blob/main/documentation/ubuntu-chiseled.md and I think my Dockerfile looks ok. I think it's a support problem with Visual Studio or the Microsoft.VisualStudio.Azure.Containers.Tools.Targets NuGet package regarding the new jammy-chiseled Docker images.

Please let me know if I can provide more information.

Steps to Reproduce

Other Information

Output of docker version

Client:
Cloud integration: v1.0.35+desktop.5
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.25.2 (129061)
Engine:
Version: 24.0.6
API version: 1.43 (minimum version 1.12)
Go version: go1.20.7
Git commit: 1a79695
Built: Mon Sep 4 12:32:16 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
GitCommit: de40ad0

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.5
Path: C:\Program Files\Docker\cli-plugins\docker-buildx.exe
compose: Docker Compose (Docker Inc.)
Version: v2.23.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.9
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: Docker Scout (Docker Inc.)
Version: v1.0.9
Path: C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
Containers: 34
Running: 0
Paused: 0
Stopped: 34
Images: 51
Server Version: 24.0.6
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8165feabfdfe38c65b599c4993d227328c231fca
runc version: v1.1.8-0-g82f18fe
init version: de40ad0
Security Options:
seccomp
Profile: unconfined
cgroupns
Kernel Version: 6.4.16-linuxkit
Operating System: Docker Desktop
OSType: linux
Architecture: x86_64
CPUs: 16
Total Memory: 11.68GiB
Name: (none)
ID: df2cdba8-b0cb-46d8-b811-71928a942c2c
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
127.0.0.0/8
Live Restore Enabled: false

WARNING: daemon is not using the default seccomp profile

Just to track things, originally I reported this issue here: dotnet/dotnet-docker#5025.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions