Skip to content

PublishTrimmed with --no-restore silently skips trimming if not previously restored #37049

Open
@sbomer

Description

@sbomer

From @LXGaming in dotnet/linker#3168 (comment):

Documenting an issue I encountered with GitHub Actions Runner ubuntu22/20231115.7 (includes .NET 8) when building a .NET 7 project.

I use GitHub Actions for publishing trimmed .NET binaries, my workflow consists of a restore step and all subsequent steps use --no-restore, I found that builds were no longer being trimmed due to ILLink having disappeared. I eventually stumbled upon this issue and its linked PRs which noted that a restore would be required for ILLink to be downloaded, because I use /p:PublishTrimmed=true and --no-restore on the publish command ILLink is never downloaded.

The solution is to add /p:PublishTrimmed=true to the restore command or alternatively avoid using --no-restore to ensure that ILLink is present.

I believe there should be a warning or error when PublishTrimmed is specified but ILLink isn't present.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions