jonnii
jonnii

Reputation: 28332

Adding scripts to a solution folder in visual studio with Nuget

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.

Upvotes: 3

Views: 3348

Answers (2)

Jay Walker
Jay Walker

Reputation: 4713

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.

Upvotes: 1

Danny Tuppeny
Danny Tuppeny

Reputation: 42403

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

Upvotes: 1

Related Questions