如何在Inno Setup安装程序中捆绑来自NuGet软件包的仅运行时依赖项? [英] How to bundle run-time-only dependencies from NuGet packages in Inno Setup installer?

查看:243
本文介绍了如何在Inno Setup安装程序中捆绑来自NuGet软件包的仅运行时依赖项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为具有几个运行时dll依赖项的程序创建安装程序.这些依赖项可以作为NuGet包使用.我想知道是否可以以某种方式指定Inno Setup的NuGet程序包列表,以便它将下载程序包并将相应的dll捆绑在我的安装程序中?

I'm creating an installer for a program that has a couple of run-time dll dependencies. These dependencies are available as NuGet packages. I was wondering if I could somehow specify the list of NuGet packages to Inno Setup, such that it will download the packages and bundles the corresponding dll's in my installer?

如果不可能,从安装程序中的NuGet软件包中捆绑仅运行时dll的预期方法是什么?

If that is not possible, what is the intended way to bundle such run-time only dll's from a NuGet package in an installer?

推荐答案

您可以使用 Inno Setup预处理器运行 nuget.exe 下载一个打包并根据下载的内容生成[Files]节条目.

You can use Inno Setup preprocessor to run nuget.exe to download a package and generate [Files] section entries based on the downloaded contents.

例如,以下内容定义了NuGetPackage预处理程序宏,该宏可收集下载程序包的lib\net45文件夹中的所有文件:

For example the following defines NuGetPackage preprocessor macro that collects all files in lib\net45 folder of the downloaded package:

#pragma parseroption -p-

#define ProcessFile(Source, FindResult, FindHandle) \
    FindResult \
        ? \
            Local[0] = FindGetFileName(FindHandle), \
            Local[1] = Source + "\\" + Local[0], \
            "Source: \"" + Local[1] + "\"; DestDir: \"{app}\"\n" + \
                ProcessFile(Source, FindNext(FindHandle), FindHandle) \
        : \
            ""

#define NuGetPackage(Name) \
    Exec("nuget.exe", "install " + Name, SourcePath, , SW_HIDE), \
    Local[0] = FindFirst(AddBackslash(SourcePath) + Name + "*", faDirectory), \
    Local[0] \
        ? \
            Local[1] = FindGetFileName(Local[0]), \
            Local[2] = AddBackslash(SourcePath) + Local[1], \
            Local[3] = Local[2] + "\\lib\\net45", \
            Local[4] = FindFirst(Local[3] + "\\*", 0), \
            ProcessFile(Local[3], Local[4], Local[4]), \
        : \
            ""

#pragma parseroption -p+

您可以像这样使用它:

[Files]
#emit NuGetPackage("NUnit")
#emit NuGetPackage("EntityFramework")

获得:

[Files]
Source: "C:\source\path\NUnit.3.8.1\lib\net45\nunit.framework.dll"; DestDir: "{app}"
Source: "C:\source\path\NUnit.3.8.1\lib\net45\nunit.framework.xml"; DestDir: "{app}"
Source: "C:\source\path\EntityFramework.6.1.3\lib\net45\EntityFramework.dll"; DestDir: "{app}"
Source: "C:\source\path\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll"; DestDir: "{app}"
Source: "C:\source\path\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.xml"; DestDir: "{app}"
Source: "C:\source\path\EntityFramework.6.1.3\lib\net45\EntityFramework.xml"; DestDir: "{app}"

这篇关于如何在Inno Setup安装程序中捆绑来自NuGet软件包的仅运行时依赖项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆