# Target INSTALL not restoring nuget package?

**URL:** https://discourse.cmake.org/t/target-install-not-restoring-nuget-package/11183
**Category:** Usage
**Tags:** os:windows
**Created:** [July 7, 2024, 12:27pm UTC](https://discourse.cmake.org/t/target-install-not-restoring-nuget-package/11183 "2024-07-07T12:27:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Holt59](https://discourse.cmake.org/user_avatar/discourse.cmake.org/holt59/32/4732_2.png) [@Holt59](https://discourse.cmake.org/u/Holt59)
#### Post date: [July 7, 2024, 12:27pm UTC](https://discourse.cmake.org/t/target-install-not-restoring-nuget-package/11183/1 "2024-07-07T12:27:00Z")

</div>

I have a C# project that uses `VS_PACKAGE_REFERENCES`, so I need to set CMAKE\_VS\_NUGET\_PACKAGE\_RESTORE to build it ([https://gitlab.kitware.com/cmake/cmake/-/issues/20646](https://gitlab.kitware.com/cmake/cmake/-/issues/20646)).

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?

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [July 8, 2024, 12:07am UTC](https://discourse.cmake.org/t/target-install-not-restoring-nuget-package/11183/2 "2024-07-08T00:07:21Z")

</div>

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:

```auto
cmake --install /path/to/build/dir --prefix /some/staging/area

```

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.

---

<div class="post-metadata">

### Author: ![Holt59](https://discourse.cmake.org/user_avatar/discourse.cmake.org/holt59/32/4732_2.png) [@Holt59](https://discourse.cmake.org/u/Holt59)
#### Post date: [July 8, 2024, 6:46am UTC](https://discourse.cmake.org/t/target-install-not-restoring-nuget-package/11183/3 "2024-07-08T06:46:53Z")

</div>

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.
