# cpack -G NuGet : how does one generate the targets file?

**URL:** https://discourse.cmake.org/t/cpack-g-nuget-how-does-one-generate-the-targets-file/1633
**Category:** Usage
**Created:** [July 27, 2020, 3:50pm UTC](https://discourse.cmake.org/t/cpack-g-nuget-how-does-one-generate-the-targets-file/1633 "2020-07-27T15:50:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![masariello](https://discourse.cmake.org/user_avatar/discourse.cmake.org/masariello/32/769_2.png) [@masariello](https://discourse.cmake.org/u/masariello)
#### Post date: [July 27, 2020, 3:50pm UTC](https://discourse.cmake.org/t/cpack-g-nuget-how-does-one-generate-the-targets-file/1633/1 "2020-07-27T15:50:29Z")

</div>

Hi All

First time poster

Quick question: what’s the recommended way to add a build/native/some\_pkg\_name.targets file to a NuGet package with CPack?

I can certainly use something like the following:  
install(FILES project\_name.targets DESTINATION build/native)  
but then the file will get added to all kinds of packages, aven when not relevant.

Thanks for any advice on the matter

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [November 11, 2020, 8:53pm UTC](https://discourse.cmake.org/t/cpack-g-nuget-how-does-one-generate-the-targets-file/1633/2 "2020-11-11T20:53:43Z")

</div>

Cc: @zaufi

---

<div class="post-metadata">

### Author: ![zaufi](https://discourse.cmake.org/user_avatar/discourse.cmake.org/zaufi/32/116_2.png) [@zaufi](https://discourse.cmake.org/u/zaufi)
#### Post date: [December 10, 2020, 9:31pm UTC](https://discourse.cmake.org/t/cpack-g-nuget-how-does-one-generate-the-targets-file/1633/3 "2020-12-10T21:31:20Z")

</div>

Hi @masariello,

You can use [CPACK\_INSTALL\_SCRIPTS](https://cmake.org/cmake/help/latest/module/CPack.html?highlight=cpack_install_scripts#variable:CPACK_INSTALL_SCRIPTS) to check the current generator and perform `install()` conditionally for the desired one.
