Skip to content

-a sets app to framework-dependent when SelfContained is true #34026

@richlander

Description

@richlander

I'm working on some samples and following the excellent guidance at https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/. The guidance doesn't work as intended when I target SCD.

My project file.

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

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <PublishSingleFile>true</PublishSingleFile>
    <PublishTrimmed>true</PublishTrimmed>
    <PublishReadyToRun>true</PublishReadyToRun>
    <PublishSelfContained>true</PublishSelfContained>
  </PropertyGroup>

</Project>

In Dockerfile:

# copy csproj and restore as distinct layers
COPY *.csproj .
RUN dotnet restore -a $TARGETARCH

# copy and publish app and libraries
COPY . .
RUN dotnet publish -a $TARGETARCH -o /app

This fails.

5.453 /root/.nuget/packages/microsoft.net.illink.tasks/8.0.0-preview.6.23329.7/build/Microsoft.NET.ILLink.targets(193,5): error NETSDK1102: Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app. [/source/releases.csproj]

Works if I do:

RUN dotnet publish -a $TARGETARCH -o /app --self-contained

We should fix -a to be less strong. It should not override SelfContained or PublishSelfContained if set.

Metadata

Metadata

Assignees

Labels

Area-CLIbreaking-changeUsing this label will notify dotnet/compat and trigger a request to file a compat buggood first issueIssues that would be a good fit for someone new to the repository. Narrow in scope, well-defined.needs-breaking-change-doc-created

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions