Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
richlander opened this issue Jul 14, 2023 · 10 comments
Closed

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

richlander opened this issue Jul 14, 2023 · 10 comments
Assignees
Labels
Area-CLI breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug good first issue Issues that would be a good fit for someone new to the repository. Narrow in scope, well-defined. needs-breaking-change-doc-created
Milestone

Comments

@richlander
Copy link
Member

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.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-ILLink untriaged Request triage from a team member labels Jul 14, 2023
@ghost
Copy link

ghost commented Jul 14, 2023

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

@nagilson
Copy link
Member

nagilson commented Jul 14, 2023

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.

@nagilson nagilson added Area-CLI and removed untriaged Request triage from a team member Area-ILLink labels Jul 14, 2023
@nagilson nagilson self-assigned this Jul 14, 2023
@nagilson nagilson added needs team triage Requires a full team discussion good first issue Issues that would be a good fit for someone new to the repository. Narrow in scope, well-defined. labels Jul 14, 2023
@richlander
Copy link
Member Author

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

@nagilson
Copy link
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.

@nagilson nagilson added the breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug label Jul 14, 2023
@ghost
Copy link

ghost commented Jul 14, 2023

Added needs-breaking-change-doc-created label because this issue has the breaking-change label.

  1. Create and link to this issue a matching issue in the dotnet/docs repo using the breaking change documentation template, then remove this needs-breaking-change-doc-created label.

Tagging @dotnet/compat for awareness of the breaking change.

@marcpopMSFT marcpopMSFT added this to the 8.0.1xx milestone Jul 18, 2023
@marcpopMSFT marcpopMSFT removed the needs team triage Requires a full team discussion label Jul 18, 2023
@nagilson
Copy link
Member

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

@richlander
Copy link
Member Author

What is the PR for this change @nagilson?

@mthalman
Copy link
Member

mthalman commented Sep 8, 2023

@nagilson - Is this fixed in RC1 yet?

@baronfel
Copy link
Member

baronfel commented Sep 8, 2023

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.

@nagilson
Copy link
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
Labels
Area-CLI breaking-change Using this label will notify dotnet/compat and trigger a request to file a compat bug good first issue Issues that would be a good fit for someone new to the repository. Narrow in scope, well-defined. needs-breaking-change-doc-created
Projects
None yet
Development

No branches or pull requests

6 participants