create a nuget package with dll in c# and c++ - nuget

In my C# project I use purely C# dll, but for some functions it is possible to use only C++ libraries and dlls.
What I am trying to do is create a Nuget package consisting of C# dll and C++ dll.
Using Nuget Package Explorer and following the procedure for creating a Nuget package, I placed the C# dll in the "lib" folder and the C++ library in the "content" folder.
Created the Nuget package, I tried to import it into my project, but after building, in the output path there is only my dll in C#.
What should I do to be able to import the dll in cpp into the output of my project?

Related

NuGet: Do Not Set Assembly Reference

I have created a nuget package containing a DLL that I want to share with multiple applications. I want to add this package to applications without setting a reference to the DLL. I am using dependency injection to load this DLL or a test DLL at run-time.
By default, nuget automatically sets a reference to all DLLs contained lib during installation.
Is there any way to configure the nuget package to not set a reference to the DLL when it is installed into my project?
Explicit assembly references. Although if your dll is loaded entirely at runtime (using MEF or Assembly.Load or something similar), then the build system might not copy the dll to the project's output directory. Note these docs are only correct for packages.config projects. I have a PR to improve the docs to explain how to do the equivalent thing for PackageReference.

Create a NuGet package with only javascript files

I want to create a NuGet package that contains only javascript. I have no assembly that needs to be built and included.
So to do this I created an empty solution in vs, and created an empty project. In the project I created a Scripts directory with my javascript files. I have a package.nuspec and a packages.config
When I run "nuget pack" commandline I get an error:
C:\MyProject>nuget
pack
Attempting to build package from 'TestProject.csproj'.
MSBuild auto-detection: using msbuild version '16.1.76.45076' from
'C:\Program Files (x86)\Microsoft Visual
Studio\2019\Enterprise\MSBuild\Current\bin'.
Error NU5012: Unable to find 'C:\MyProject\TestProject.exe'. Make sure the project has been built.
C:\MyProject>
If I try to build the project in visual studio, I get an error...
Program does not contain a static 'Main' method suitable for an entry
point.
...which makes sense because I made this from an empty project.
I am not trying to deploy the assembly, just javascript, can I stop it from trying to build somehow?
Don't use a project. Have have your .nuspec and javascript files in the directory, then run nuget pack. If the nuspec doesn't contain a <files> section, then it will just copy the filesystem structure directly into the nupkg.
Having said that, new ASP.NET Core projects from Microsoft's templates no longer use front end resources (html, javascript, css) from NuGet packages, but rather use either LibMan or npm, to be more in-line with what the non-.NET front-end ecosystem uses. I suggest investigating those technologies and using them if possible.

Nuget - how to package a reference C library

I have a C# DLL that in turn calls a C library. How do I package these libraries in a NuGet package?
For example, I have two DLLs MyCSharp.dll and MyC.dll
How do I package both these DLLs so that when I add the NuGet package to a Windows Universal/UWP project, MyCSharp.dll is able to call MyC.dll successfully?
I tried adding copying the MyC.dll to the same folder as MyCSharp.dll during install time, but this doesn't help.
I was able to get this working by placing my MyC.dll & MyC.winmd libraries in the build folder of the NuGet package. See http://blogs.msdn.com/b/mim/archive/2013/09/02/packaging-a-windows-store-apps-component-with-nuget-part-2.aspx for very elaborate write up on packaging WinRT components with NuGet.

Native binaries in NuGet package installed into DNX project

I've created NuGet package containing native x86 binaries. Binaries are copying to bin directory by MSBuild script from this answer.
But this approach does not work with DNX projects (ASP.NET 5 web app for example), because MSBuild script is not installing. So I have FileNotFoundException.
How to make it alive?
Solution for me was to make runtimes\win\native directory in NuGet package structure, as described here: https://docs.nuget.org/Create/uwp-create
In runtime DNX adds this directory to PATH variable, so managed dll can load it.

nuget package inside

I understand how to build dll nuget package
I would like to build a JavaScript nuget package of my own. I would like to learn how jQuery nuget package being constructed/installed by nuget.
How do I know how jQuery (or similar nuget package) nuget package being constructed? Especially I would like to know how these *.js being copied/ installed to specific folder (scripts) of a ASP.net MVC project
Thanks
NuGet uses a convention-over-configuration approach. This is what makes it easy to inject some files (images, code, javascript, etc) into a specific folder of a target Visual Studio project.
You can simply open a .nupkg file with any zip-utility (e.g. 7zip) and extract the archive to see its contents.
A NuGet package can have 3 folders: lib, content & tools.
Anything in the content folder will be injected into the target project using the same relative path to the project root as to the content folder of the nuget package.
More info here: http://docs.nuget.org/docs/creating-packages/package-conventions
Also with respect to how jQuery or other similar Javascript libraries are packaged, here are some pointers.
The list of public jQuery/jQuery plugins that have been "NuGetified" can be see here http://nuget.org/packages?q=jquery The jQuery NuGet package page http://nuget.org/packages/jQuery has a note saying that it is maintained by the NuGet Community Packages project.
If you go to the CodePlex project at http://nugetpackages.codeplex.com/ and browse the source code, you'll find it contains a couple of sub projects. These are NuGet package projects for the respective open source (mainly Javascript) projects.
You will notice that they simply include the relevant pure Javascript packages, e.g. jquery-1.8.3.js, jquery-1.8.3.min.js, etc. in the Content/Scripts path.