使用 Nuget 将脚本添加到 Visual Studio 中的解决方案文件夹
我想使用 nuget 为我们的项目分发一组共享构建脚本,我设想它的工作方式如下:
- 用户运行 install-package build.support
- 下载包
- 构建脚本出现在解决方案的解决方案文件夹中您可以根据需要编辑默认的“顶级”构建脚本。
现在也许 nuget 不是合适的工具,我应该只是从树中的其他位置将构建脚本目录分支到我的项目中,但我真正想要的是解决方案级别包而不是项目级包。这可以开箱即用吗?
一种选择是使用 powershell 将文件从 nuget 包中的工具目录复制到正确的位置,但同样,这感觉像是一种 hack。
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:
- User runs install-package build.support
- Package is downloaded
- 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果没有诸如 powershell 脚本之类的“黑客”,这是不可能的,因为库被“安装”到包中,而不是解决方案中。
我不认为这是一个不合理的请求 - 我建议将其发布在官方 NuGet 讨论论坛中,看看其他人是否同意: http://nuget.codeplex.com/discussions
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
是的,您可以通过将代码放入 init.ps1 文件中来完成此操作。 install.ps1 仅与项目级包一起执行。由于代码位于 init.ps1 中,因此每次加载解决方案时都会运行 - 而不仅仅是在安装时运行。所以你需要防止重新执行。
请参阅此帖子获取代码示例 - 您只需需要添加一个步骤,从工具文件夹复制到解决方案文件夹。
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.