如何将Node和/或Ruby作为NuGet包的一部分包含在内?

时间:2014-02-16 23:58:03

标签: ruby windows node.js visual-studio nuget

用例

假设我想将Ruby Gem或Node.JS NPM包转换为NuGet包,我不希望包(和构建环境)的使用者必须安装Node.JS或Ruby,我该怎么做?

特别是

如何获取/制作可以在包文件夹中复制并从中调用的Node.JS / Ruby的可移植/ x-copy可部署版本?

我知道这是可行的

Web Essentials Visual Studio扩展,以及一些NuGet包,如node-jshint似乎这样做,但我无法准确说明我需要采取哪些步骤。

任何想法/指南?

1 个答案:

答案 0 :(得分:0)

node-jshint包不是一个很好的例子,因为它的结构有点偏,所以它没有获得所有这些好处,但是要将外部工具集成到包中需要做三件事经理控制台:

  • 将相关工具添加到NuGet包的tools文件夹中。因此,用户需要的node.exe和其他脚本不被视为库或内容。如何使工具可以进行bin可部署将取决于堆栈到堆栈,但这里是blog post going into details for Ruby但它基本上是download and unpack the 7zip archive from rubyinstaller.org ...

  • 一个名为tools\init.ps1的脚本 - 它在其他Powershell脚本之前运行,并且只要在VS中打开解决方案。它需要在标题处使用此行,因为约定(有关这些脚本的更多详细信息here

param($installPath, $toolsPath, $package, $project)

  • 用户可以运行的功能。这是一个简单的例子:

    param($installPath, $toolsPath, $package, $project)
    
    function Enable-DoSomething {
        [CmdletBinding()]
        param (
           [Parameter(Position=0, ValueFromPipeLine=$true)]
           [string] $ProjectName
        )
    
        # do something cool here like invoke node.exe from under the tools dir 
        Write-Host "Hello $ProjectName from $toolsPath"
    }
    
    Export-ModuleMember Enable-DoSomething
    

Export-ModuleMember方法使用户可以使用 - 默认情况下,功能不可见......