The officially recommended VS 2022 version for UE 5.4 is 17.8. I saw fixes online for certain issues that are probably what you’re encountering as well while using UE 5.4 with the latest VS version, you didn’t specify the errors you got but that’s probably the case, but I’d recommend trying it with VS 2022 17.8.
If your issue persists, you can provide more context along with your error messages for us to take a look at.
Hope this helps!
Hmmm… Maybe that’s not the case, but it sounds like you’re trying to build the project while the editor is open. Can it be that by any chance?
You can click on the icon that’s a square made of squares at the bottom to compile. Sometimes it doesn’t work when making changes to the header file, in which case you should just close the editor and build the project again from VS.