3

I want to use nuget to distribute a set of shared build scripts for our projects, the way I envision it working is as follows:

  1. User runs install-package build.support
  2. Package is downloaded
  3. Build scripts appear in a solution folder in the solution along with a default 'top level' build script you can edit for your needs.

Now maybe nuget isn't the right tool for this and I should just be branching the build scripts directory into my project from somewhere else in the tree, but what I really want is a solution level package not a project level package. Is this possible out of the box?

One option is to use powershell to copy the files into the right place from a tools directory in the nuget package, but again, this feels like a hack.

jonnii
  • 28,019
  • 8
  • 80
  • 108
  • 2
    Why is it a hack? The entire reason for ps1 files are for things like this. – davidfowl May 07 '11 at 02:11
  • Not a hack per-se, but it means that you need to manage copying the files somewhere in the build directory yourself, and if users have made changes to the files you'll need to notify them or deal with overwriting them, which is something nuget will handle for you (as you know). – jonnii May 08 '11 at 00:03

2 Answers2

1

Yes, you can do this by placing your code in the init.ps1 file. install.ps1 only executes with project-level packages. Because the code will be in init.ps1, it will run every time the solution loads - not just at install. so you will need to safeguard against re-execution. See this post for a code example - You'll just need to add a step to copy from the tools folder to the solution folder.

Community
  • 1
  • 1
Jay Walker
  • 4,654
  • 5
  • 47
  • 53
1

This isn't possible without a "hack" such as your powershell scripts, as libraries are "installed" into packages, not solutions.

I don't think is an unreasonable request - I'd suggest posting it in the official NuGet discussion forums to see if others agree: http://nuget.codeplex.com/discussions

Danny Tuppeny
  • 40,147
  • 24
  • 151
  • 275