As suggested by @liyun-zhang-msft, I've tried publishing the app via CLI: I followed the article step by step, creating a certificate and configuring the project settings (=adding the <PropertyGroup>'s to the .csproj file).
At first, I ran dotnet publish -f net8.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win-x64
and it didn't work. That's because in the same article there is a warning saying that the dotnet publish should be scoped only to the single app project you want to publish. In fact, the other projects were throwing errors such as "restore and make sure net8.0-windows... is in the TargetFrameworks", which didn't make sense since I already included it in the project file.
So here is the final answer:
dotnet publish .\{project name} -f net8.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win-x64