从 dll 创建 nuget 包 [英] Create nuget package from dlls

查看:41
本文介绍了从 dll 创建 nuget 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个 NuGet 包,它添加多个 .dll 文件作为对我的项目的引用.

我有一个文件夹,里面有 10 个 .dlls 文件.

当我通过 nuget 安装它时,我希望将这些文件添加到项目的引用中.

解决方案

我想创建一个 nuget 包,它添加多个 .dll 作为对我的项目的引用.

我想给你两个解决方案来实现这一点:

首先,使用NuGet Package Explorer:

  1. 下载

    第二,正如 Lex Li 提到的,我们可以使用 .nuspec 来打包程序集:

    1. 下载 nuget.exe.

    2. 创建一个新项目.

    3. 打开一个cmd并切换到nuget.exe的路径

    4. 使用命令行:nuget spec "PathOfProjectTestDemo.csproj"

    5. 打开TestDemo.csproj.nuspec文件并修改它并将程序集添加为文件;下面是我的 .nuspec 文件:

      <?xml 版本=1.0"?><包装><元数据><id>TestDemo</id><版本>1.0.0</版本><作者>测试者</authors><owners>测试人员</owners><requireLicenseAcceptance>false</requireLicenseAcceptance><description>TestDemo</description><releaseNotes>在此版本的软件包中所做的更改摘要.</releaseNotes><版权>版权 2017</版权><标签>标签1标签2</标签></元数据><文件><file src="MultipleDll*.*"目标=lib
      et461";/></文件></包>

    6. 使用打包命令:nuget pack TestDemo.csproj.nuspec

    7. 通过 NuGet 包资源管理器打开 TestDemo 包.

    I want to create a NuGet package which adds multiple .dll files as references to my project.

    I have a folder with 10 .dlls files in it.

    When I install this via nuget, I want these files to be added to the project's references.

    解决方案

    I want to create a nuget package which adds multiple .dll as references to my project.

    I would like give you two solutions to achieve this:

    First, Use NuGet Package Explorer

    1. Download the NuGet Package Explorer.
    2. Open the NuGet Package Explorer, select the create a new package.
    3. Add a lib folder on the content tab, and add your dlls file
    4. Save the package and install it to the project, check if it add references.

    Second, Just as Lex Li mention, We could use .nuspec to pack up the assemblies:

    1. Download the nuget.exe.

    2. Create a new project.

    3. Open a cmd and switch path to nuget.exe

    4. Use command line: nuget spec "PathOfProjectTestDemo.csproj"

    5. Open the TestDemo.csproj.nuspec file and modify it and add the assemblies as file; below is my .nuspec file:

      <?xml version="1.0"?>
      <package>
        <metadata>
          <id>TestDemo</id>
          <version>1.0.0</version>
          <authors>Tester</authors>
          <owners>Tester</owners>
          <requireLicenseAcceptance>false</requireLicenseAcceptance>
          <description>TestDemo</description>
          <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
          <copyright>Copyright 2017</copyright>
          <tags>Tag1 Tag2</tags>
        </metadata>
        <files>
          <file src="MultipleDll*.*" target="lib
      et461" />
        </files>
      </package>
      

    6. Use pack command: nuget pack TestDemo.csproj.nuspec

    7. Open the TestDemo package by NuGet Package Explorer.

    这篇关于从 dll 创建 nuget 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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