In Visual Studio 2022, there is a Analyze and Code Cleanup
feature which is really good.
I'd like to know that is there any equivalent tool I can use in VS Code or in .NET CLI or in MSBuild?
There are plenty of those, I have used dotnet-format and heard about ReSharper Command Line Tools those are being distributed as a dotnet-tool.
There is even a ready to use github action for dotnet-format and it is being configured through editorconfig so there is no problem at all to integrate it in a CI\CD pipelines.