Home > Back-end >  WinUI3 Standalone Executible produces many additional files
WinUI3 Standalone Executible produces many additional files

Time:01-07

Background: I am switching from WinForm to WinUi3 and we have the need to deliver the application as a usually windows executable. Therefore the idea was to deliver it as a standalone exe program.

I have selected self hosted in the project and also the single file option. after publish I get a large collection of files in the folder. The dll files can still be accepted, but many language folders are superfluous, especially the program is monolingual.

Is there a possibility to get it under control or are there other possibilities?

enter image description here enter image description here

CodePudding user response:

You can remove unnecessary language folders, except your default language folder (en-us in this case), by adding these lines in your csproj file.

<Project...>


  <Target Name="RemoveFoldersWithMuiFiles" AfterTargets="Build">
    <ItemGroup>
      <RemovingFiles Include="$(OutDir)*\*.mui" Exclude="$(OutDir)en-us\*.mui" />
      <RemovingFolders Include="@(RemovingFiles->'%(RootDir)%(Directory)')" />
    </ItemGroup>
    <RemoveDir Directories="@(RemovingFolders)" />
  </Target>
</Project>
  • Related