Skip to content

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

Closed

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.

Activity

  1. ghost added
    untriaged
    on Jul 14, 2023
  2. nagilson commented on Jul 14, 2023

    @nagilson
    Member

    Interesting, yeah it looks like the RID Short-Hand Resolution is called by the Architecture Flag, and if you haven't specified SelfContained then it will inject this:

    properties = properties.Append("-property:SelfContained=false").ToArray(); , and since it's injected as a global property it would override your selfcontained or publishselfcontained value.

    Not great, good catch! We should fix this. Marking as 'team triage' to discuss timeline.

  3. added and removed
    untriaged
    on Jul 14, 2023
  4. self-assigned this
    on Jul 14, 2023
  5. added
    needs team triage
    good first issue
    on Jul 14, 2023
  6. richlander commented on Jul 14, 2023

    @richlander
    MemberAuthor

    -property:SelfContained=false") ... That shouldn't be needed anymore, right?

  7. nagilson commented on Jul 14, 2023

    @nagilson
    Member

    Ya, that really shouldn't be there anymore. It is definitely going to break people when we fix it (yay) but it should be fixed.

  8. added
    breaking-change
    on Jul 14, 2023
  9. added this to the 8.0.1xx milestone on Jul 18, 2023
  10. removed
    needs team triage
    on Jul 18, 2023
  11. nagilson commented on Jul 18, 2023

    @nagilson
    Member

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

  12. richlander commented on Aug 4, 2023

    @richlander
    MemberAuthor

    What is the PR for this change @nagilson?

  13. mthalman commented on Sep 8, 2023

    @mthalman
    Member

    @nagilson - Is this fixed in RC1 yet?

  14. baronfel commented on Sep 8, 2023

    @baronfel
    Member

    No, we haven't done it yet. I'll bring it up at standup today and we'll get it prioritized. Noah's been doing a lot of work on the VSCode extension to support DevKit, and this got lost in the shuffle.

  15. assigned and unassigned on Sep 8, 2023
  16. nagilson commented on Sep 12, 2023

    @nagilson
    Member

    This has been solved by @MiYanni for RC-2. Sorry for forgetting this one, it got put down a continuously growing list for CDK 😄 Thanks again @MiYanni for taking this one up, a document has also been made which @baronfel attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area-CLIbreaking-changegood first issueneeds-breaking-change-doc-created

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions