When building using cmake --build build --target my_target --config RelWithDebInfo, it builds fine, but when using the INSTALL target, the restore step is not performed.
Is there a way to cmake --build build --target INSTALL --config RelWithDebInfo performs the restore step as if building?
Keep in mind that install is not always run with the build tool (and I generally don’t recommend invoking it that way). You can do an install that doesn’t involve the build tool at all like so:
There’s in opportunity to do a restore when invoked like the above. If your install logic relies on doing a NuGet restore, then you’re probably going to run into problems. If you absolutely must to a NuGet as part of your install, you will need to do it explicitly yourself with an install(SCRIPT) or install(CODE) very early in your project, ideally before any other install(...) command is called.
It’s not really that my install logic relies on the restore, but that using the --target INSTALL is a short way of building+installing.
From my understanding, cmake --install does not trigger the build step, which is expected, so I do not expect that command to trigger a nuget restore. On the other hand cmake --build XXX --target INSTALL does trigger the build step, I assume because INSTALL depends on ALL_BUILD or something like that, so I would expect it to do the nuget restore step.
My current workaround is to set INSTALL_REQUIRES_VS_PACKAGE_RESTORE, which seems to work.