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:
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.
https://i.stack.imgur.com/wl1tm.png
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:
https://i.stack.imgur.com/mSUnx.png
I think the best way to create NuGet packages is use nuget.exe
.
First, download and install nuget.exe (https://www.nuget.org/downloads) Then go to your project folder, press shift + right click to display command prompt 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:
This video on How to Create Nuget Packages has a very useful and clear tutorial.
If you want to do it through Visual Studio or dotnet, then you can edit your csproj file, add an ItemGroup to include the dlls as below: This will pack the other dlls along with your current project dll in the nuget package.
<ItemGroup>
<Content Include="<path to other dll>">
<Pack>true</Pack>
<PackagePath>lib\$(TargetFramework)</PackagePath>
</Content>
</ItemGroup>
Success story sharing