dotnet / sdk-container-builds

Libraries and build tooling to create container images from .NET projects using MSBuild
https://learn.microsoft.com/en-us/dotnet/core/docker/publish-as-container
MIT License
175 stars 30 forks source link

Missing debug profile (compability) with worker projects #562

Open Herdo opened 2 months ago

Herdo commented 2 months ago

I've tried to enable debugging a worker project using the SDK container build, but failed to do so. Apparently, only the Web SDK supports SDK container style debugging.

It'd be great if the other SDKs would also support the SDK container style debugging like the Web SDK does.

I tried with this project and launch settings:

Worker.csproj

<Project Sdk="Microsoft.NET.Sdk.Worker">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>

  <PropertyGroup>
    <IsPublishable>true</IsPublishable>
    <EnableSdkContainerSupport>true</EnableSdkContainerSupport>
    <EnableSdkContainerDebugging>True</EnableSdkContainerDebugging>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    <ContainerRuntimeIdentifier>linux-x64</ContainerRuntimeIdentifier>
    <ContainerRepository>test-worker</ContainerRepository>
    <ContainerImageTag>latest</ContainerImageTag>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.20.1" />
  </ItemGroup>
</Project>

launchSettings.json

{
  "profiles": {
    "Container (.NET SDK)": {
      "commandName": "SdkContainer",
      "launchBrowser": false,
      "environmentVariables": {
        "DOTNET_ENVIRONMENT": "Development"
      }
    }
  },
  "$schema": "http://json.schemastore.org/launchsettings.json"
}

Results in Visual Studio 17.9 giving me this error message: grafik

When chaning the project SDK to Microsoft.NET.Sdk.Web, debugging works fine.

Publishing is not affected. This works fine. The debug functionality is missing.

baronfel commented 2 months ago

Interesting catch! @danegsta is this something that should be reported in VS developer community for triage on the VS docker tools side?

baronfel commented 2 months ago

Broadly speaking in 8.0.100 Worker SDK projects should be able to be debugged in this way, and from 8.0.200 onwards any project with the EnableSdkContainerSupport property set to true should be able to be debugged in this way.

Herdo commented 2 months ago

Installed SDK version is 8.0.204.

For me it feels like the Visual Studio tooling is lacking some things, as most of it had to be assembled by hand, taken from the Web SDK. Just reporting here due to the error message.

baronfel commented 2 months ago

Sorry @Herdo - you're totally right, my comments were intended for the VS Docker tools team as a guideline for how to think about what project types can be containerized in what SDK versions when updating the VS features. No reflection on you or your report at all.