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.
You can configure Visual Studio to automatically generate the NuGet package when you build the project. In Solution Explorer, right-click the project and choose Properties. In the Package tab, select Generate NuGet package on build.
When you add features to your project via a nuget package, you're just adding files to your project. It can be javascript files (like jQuery), DLLs that your project references (like Newtonsoft JSON), or a whole bunch of things (like Entity Framework or Owin/SignalR) -- anything really.
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:
Second, Just as Lex Li mention, We could use .nuspec to pack up the assemblies:
Download the nuget.exe.
Create a new project.
Open a cmd and switch path to nuget.exe
Use command line: nuget spec "PathOfProject\TestDemo.csproj"
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>
Use pack command: nuget pack TestDemo.csproj.nuspec
Open the TestDemo package by NuGet Package Explorer.
I think the best way to create NuGet packages is use nuget.exe
.
In the command prompt, enter
nuget spec
You will now have a .nuspec
file. Open it in an editor and add Id, author, etc.
The most important part is the files
tag after closed metadata tag.
You can define all dlls here like this:
<files> <file src="bin\Release\YourDll.dll" target="lib"></file> </files>
Finally, you can create .nupkg
file with this command:
nuget pack 'Your_nuspec_file_name'
This video on How to Create Nuget Packages has a very useful and clear tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With