4

We use Visual Studio to write and maintain native Windows apps. We are looking into using NuGet to handle our dependencies, which consist of native static libs.

After some research, I've managed to use NuGet, package.config and the CoApp PowerShell scripts to create and consume NuGet packages with native libs in them. The issue we're facing right now is that we need to have Snapshot support.

The rollover PreRelease mechanism (with * for version rollover) that NuGet 3 and onwards supports looks great, however, it seems to only work with project.json and not with package.config. Project.json, however, doesn't seem to work with native packages, as they don't get installed in the local solution folder so the build can't find the headers and libs.

The question boils down to:

  • Is there a way to use project.json and NuGet 3 with native static libs?
  • If not, then, what alternatives are out there to support this use case? (The use case being build-time dependency distribution for native, unmanaged Windows static libraries).

EDIT:

At the end, we decided to use Maven for dependency management since NuGet doesn't seem to support our use case. I filed an issue about two weeks ago but it hasn't received any response. However, if we had decided to force NuGet into our use case, the solution proposed by Wendy would probably be the way to go, so I'm accepting it.

dhcarmona
  • 402
  • 2
  • 10
  • 29

1 Answers1

1

There are two ways could add content files into project that uses project.json file. One is "contentFiles" node and another is "files" node in nuspec file. Detailed steps please refer to:

http://blog.nuget.org/20160126/nuget-contentFiles-demystified.html

But please note, these ways only support UWP and Portable class libraries.

This feature is only for packages that will be installed to projects that are managed using a project.json file. Currently only two projects types are managed by a project.json.

1.UWP apps

2.Portable class libraries

The contentFiles option is not available for other project types

If you are using .NET Core application or other type project that use project.json, the content files in nuget package is not supported added into project at present.

Weiwei
  • 3,674
  • 1
  • 10
  • 13
  • Thanks for the answer. This sounds promising. Unfortunately, the use of the CoApp tools allows us to abstract away the issue of using different binaries for different configurations, and this would actually complicate it. But it might be useful nonetheless. Also, this would leave us with the task of setting the include and linker locations manually, which is done automatically by a CoApp generated package via the .targets files. – dhcarmona Nov 16 '16 at 14:24
  • I found the static libraries are not added into the project that uses project.json file directly, but they are listed in project.lock.json file. You could search them in this file. – Weiwei Nov 17 '16 at 02:04
  • According to the reply from yishaigalatzer in this issue, it only supported in project.json at current version: https://github.com/NuGet/Home/issues/1891 But following thread provide an Alternative Approach: http://stackoverflow.com/questions/26835197/nuget-cache-and-versioning-issues – Weiwei Nov 22 '16 at 04:42