Generating Visual Studio 2019 project without Visual Studio installed

Hey,

I got a Windows machine on which I am building some VS 2019 projects using a prepared “portable” folder of MSBuild and related tools, on that system an installation of any Visual Studio is not present.
I am wondering whether it is possible to generate a VS 2019 project on that machine using CMake? I looked for some solutions and found out about CMAKE_GENERATOR_INSTANCE variable (https://cmake.org/cmake/help/latest/variable/CMAKE_GENERATOR_INSTANCE.html#variable:CMAKE_GENERATOR_INSTANCE) and it seemed like this part " New in version 3.23: A portable VS instance, which is not known to the Visual Studio Installer, may be specified by providing both location and version= ." would be helpful to me but when I call cmake like this:

C:\myCmakeFolder\cmake.exe . -G “Visual Studio 16 2019” -DCMAKE_GENERATOR_INSTANCE=“C:\pathTo\Microsoft Visual Studio\2019”[,version=16.10.2.30804]

It throws an error:

CMake Error at CMakeLists.txt:25 (project):
Generator

Visual Studio 16 2019

given instance specification

C:\pathTo\Microsoft Visual Studio\2019[,version=16.10.2.30804]

but the version field is not 4 integer components starting in 16.

The version number I’m trying to use I got from calling msbuild. Wanted to see if it works, however the error seems not related to that but rather a syntax issue. What am I missing here?

Thanks in advance for any answer.

The square brackets in the manual usually indicates that something is optional. So do not use them calling CMake:

C:\myCmakeFolder\cmake.exe . -G “Visual Studio 16 2019” -DCMAKE_GENERATOR_INSTANCE=“C:\pathTo\Microsoft Visual Studio\2019”,version=16.10.2.30804