Building shouldn't necessarily require an installation/licensing of the VisualStudio IDE as there are VisualStudio Build Tools packages available via the VisualStudio installer that are designed for CI systems or other cases where you want to build or run tests without needing a full IDE with code completion etc.
Technically even installing VS 2017 or the VC/VC++ components from 2017 or earlier versions of the .NET framework uses the latest VisualStudio installer (which is used for both IDE and/or BuildTools and other components like the Windows SDKs).
The biggest thing to watch out for is the IDE (paid or community edition) installs to a different path than the Build Tools, so if you hard code any paths you'd likely want to add an additional location to search for those components.