TL/DR: Desktop .NET Core apps might be missing a Publish directory because it's in the .github ignore list. The files are actually all very similar and can be copy-pasted from another project.
Background:
A part of the .NET Core is that projects are both "built" and "published". This has apparently been around for ages. The problem is that there's a terrible split in the tooling: some parts of the tooling consider "publishing" to be essential and won't work if you don't have some publishing files set up. But other parts of the tooling consider "publishing" to be dangerous and therefore should be excluded from GitHub.
Helpful links:
Format of the .gitignore file: git-scm.com
There is no findable documentation for pubxml files. A web search shows a bunch of information related to ASP.NET
Solution:
The solution has two parts: get new version of the missing pubxml files and add them to GitHub.
1. Get new pubxml files from a new WinUI Blank App (packaged) project that you create in a temporary directory. Copy the entire PublishProfiles directory (it has to be called that for the builds to work). The directory should have three pubxml files in it.
AFAICT, the files are always the same for each project.
2. Update your .GITIGNORE file to allow the PublishProfiles directory to be saved. Warning: not all pubxml files should be put into GitHub. Some pubxml files include secret information like passwords and connection strings.
Perhaps the safest change is to add this line:
# 2025-07-19: shipwreck software: WinUI Blank App (Packaged) requires the win-arm64.pubxml,
# win-x64.pubxml and win-x86.pubxml files for the Release mode compile to work
# BUT pubxml files can include secret information, so we should not just allow all
# pubxml files to be added to GitHub.
!win-*.pubxml
Error messages:
These error messages pop up when building a WinUI Blank App Packaged (2025-07-18)
Code Description Project File
NETSDK1198 A publish profile with the name 'win-x64.pubxml' was not found in the project. Set the PublishProfile property to a valid file name. WinUI_Blank_App_Packaged_2025_07_15 C:\Program Files\dotnet\sdk\9.0.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets
NETSDK1102 Optimizing assemblies for size is not supported for the selected publish configuration. Please ensure that you are publishing a self-contained app. WinUI_Blank_App_Packaged_2025_07_15 C:\Users\USER\.nuget\packages\microsoft.net.illink.tasks\8.0.18\build\Microsoft.NET.ILLink.targets
No comments:
Post a Comment