The Solution from @Craig Wilson worked great to pubish with Visual Studio 2022 and Core 6
The following is a sample to exclude all appsettings except for appsettings.json and also the appsetting.QA.json when you setup an Environment Variable at a system level like ASPNETCORE_ENVIRONMENT=QA
In windows, you can also setup the environment variable on the fly in the same powershell you use to run the dotnet pubish command.
$env:ASPNETCORE_ENVIRONMENT = 'QA'
That variable will be drop when you close that powershell
<!-- Publish Settings -->
<ItemGroup>
<Content Update="appsettings.*.json">
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</Content>
<Content Update="appsettings.$(ASPNETCORE_ENVIRONMENT).json">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</Content>
<Content Update="appsettings.$(ASPNETCORE_ENVIRONMENT).json">
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</Content>
</ItemGroup>
Please note, in Visual studio 2022 all files are included by default and you just need to use Update