从dll创建nuget包 [英] Create nuget package from dlls
问题描述
我想创建一个NuGet程序包,该程序包将多个.dll文件添加为对我的项目的引用.
I want to create a NuGet package which adds multiple .dll files as references to my project.
我有一个包含10个.dlls文件的文件夹.
I have a folder with 10 .dlls files in it.
通过nuget安装此文件时,我希望将这些文件添加到项目的引用中.
When I install this via nuget, I want these files to be added to the project's references.
推荐答案
我想创建一个nuget程序包,该程序包将多个.dll添加为对我的项目的引用.
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:
首先,使用 NuGet包资源管理器:
- 下载 NuGet包资源管理器.
- 打开NuGet程序包资源管理器,选择创建一个新程序包.
- 在内容"选项卡上添加一个lib文件夹,然后添加您的dlls文件
- 保存该软件包并将其安装到项目中,检查是否添加了引用.
- Download the NuGet Package Explorer.
- Open the NuGet Package Explorer, select the create a new package.
- Add a lib folder on the content tab, and add your dlls file
- Save the package and install it to the project, check if it add references.
第二,正如Lex Li所说,我们可以使用.nuspec打包程序集:
Second, Just as Lex Li mention, We could use .nuspec to pack up the assemblies:
-
下载 nuget.exe .
创建一个新项目.
打开一个cmd并将路径切换到nuget.exe
Open a cmd and switch path to nuget.exe
使用命令行:nuget spec "PathOfProject\TestDemo.csproj"
打开TestDemo.csproj.nuspec
文件并进行修改,然后将程序集添加为文件;以下是我的.nuspec文件:
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\net461" />
</files>
</package>
使用打包命令:nuget pack TestDemo.csproj.nuspec
通过NuGet软件包资源管理器打开TestDemo软件包.
Open the TestDemo package by NuGet Package Explorer.
希望这可以为您提供帮助.
Hope this can help you.
这篇关于从dll创建nuget包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!