question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`-a` sets app to framework-dependent when `SelfContained` is `true`

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 2 months ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
nagilsoncommented, Jul 18, 2023

Fix is targeted for rc1 as its too late to fix this for the last preview now

1reaction
msftbot[bot]commented, Jul 14, 2023

@dotnet/illink-contrib a new issue has been filed in the ILLink area, please triage

Read more comments on GitHub >

github_iconTop Results From Across the Web

Should I use self-contained or framework-dependent ...
In this post I compare the impact of the framework-dependent vs self-contained mode on Docker image size, taking layer caching into account.
Read more >
NET application publishing overview
When publishing your app and creating an executable, you can publish the app as self-contained or framework-dependent. Publishing an app as self ...
Read more >
Converting a Framework-Dependent App to Self ...
Below are instructions on how to change a Framework-Dependent .NET Core application to a Self-Contained one (i.e. where all the assemblies ...
Read more >
.NET Core Self-Contained and Framework-Dependent ...
When you publish a .NET Core project, you can choose between two deployment modes: Framework-Dependent and Self-Contained.
Read more >
Self-Contained Applications: Great Tool in .NET 8
The ultimate benefit of a self-containerized application is that it easily deploys an application to an external user. It deploys with all its...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found