because there are other installed sdks, so, I assume, whenever publish , i used the latest sdks
just add global.json in solution folder to force using some sdk version , in my case
dotnet new globaljson --sdk-version 5.0.408
try publish from visual studio 2022 preview, OK
detailed explanation , you can find from this :
https://github.com/dotnet/sdk/issues/26061
another case is as stated in above link, that in VS 2022 v.17.2.4 if there are space in source folder path, it shows error dotnet exit code 1 and MSB6006 error
in my case if the source folder inside in a mapped folder (shared folder), this error is also shown. after moved source folder to local drive, there was no error shown anymore