Skip to content

CmdPal: Don't trim the template proj in debug builds #39463

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

Merged
merged 4 commits into from
Jun 6, 2025

Conversation

zadjii-msft
Copy link
Member

This saves a LOT of compilation time

@zadjii-msft zadjii-msft added Needs-Review This Pull Request awaits the review of a maintainer. Product-Command Palette Refers to the Command Palette utility labels May 15, 2025
@davidegiacometti
Copy link
Collaborator

I noticed the same, but decided to keep it. How "safe" is to trim only when compiled in release mode?
I guess it's safe as far the extension is well tested in release before shipping it.
Not sure what are the best practices 🤔

@zadjii-msft
Copy link
Member Author

This is vaguely inspired by this block out of the WinAppSdk project templates:

  <!-- Publish Properties -->
  <PropertyGroup>
    <PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
    <PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
    <PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
    <PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
  </PropertyGroup>

I assumed setting

    <IsAotCompatible>true</IsAotCompatible>

would leave things checked for being AoT (including trim) safe, but I'm clearly off my rocker.

https://learn.microsoft.com/en-us/dotnet/core/deploying/trimming/prepare-libraries-for-trimming

Looks like we want

  <PropertyGroup Condition="'$(Configuration)'=='Debug'">
    <IsAotCompatible>false</IsAotCompatible>
    <PublishTrimmed>false</PublishTrimmed>

    <EnableTrimAnalyzer>true</EnableTrimAnalyzer>
    <EnableSingleFileAnalyzer>true</EnableSingleFileAnalyzer>
    <EnableAotAnalyzer>true</EnableAotAnalyzer>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)'!='Debug'">
    <PublishTrimmed>true</PublishTrimmed>
    <IsAotCompatible>true</IsAotCompatible>
  </PropertyGroup>

i think?

<CsWinRTAotOptimizerEnabled>true</CsWinRTAotOptimizerEnabled>
<CsWinRTAotWarningLevel>2</CsWinRTAotWarningLevel>
<!-- Suppress DynamicallyAccessedMemberTypes.PublicParameterlessConstructor in fallback code path of Windows SDK projection -->
<WarningsNotAsErrors>IL2081</WarningsNotAsErrors>
<WarningsNotAsErrors>IL2081;$(WarningsNotAsErrors)</WarningsNotAsErrors>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay

Copy link
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make the template ZIP something that's produced by the build system instead, later?

@zadjii-msft
Copy link
Member Author

Can we make the template ZIP something that's produced by the build system instead, later?

I would very much like that.

@zadjii-msft
Copy link
Member Author

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

zadjii-msft added a commit that referenced this pull request May 16, 2025
Squashed commit of the following:

commit 3fb7ebe
Author: Mike Griese <migrie@microsoft.com>
Date:   Thu May 15 16:38:17 2025 -0500

    update template

commit 167266a
Author: Mike Griese <migrie@microsoft.com>
Date:   Thu May 15 16:37:46 2025 -0500

    More correct

commit fa672c6
Author: Mike Griese <migrie@microsoft.com>
Date:   Thu May 15 10:23:31 2025 -0500

    add template zip

commit 97205ea
Author: Mike Griese <migrie@microsoft.com>
Date:   Thu May 15 10:22:51 2025 -0500

    CmdPal: Don't trim in debug for template
@crutkas
Copy link
Member

crutkas commented May 28, 2025

this good to go?

@michaeljolley michaeljolley removed the Needs-Review This Pull Request awaits the review of a maintainer. label Jun 6, 2025
@michaeljolley michaeljolley merged commit c1e49ba into main Jun 6, 2025
16 checks passed
@michaeljolley michaeljolley deleted the dev/migrie/b/dont-trim-debug branch June 6, 2025 02:50
@yeelam-gordon yeelam-gordon added this to the PowerToys 0.92 milestone Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Product-Command Palette Refers to the Command Palette utility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants