Declaring dependencies
nuget { dependencies { } } declares which NuGet packages your Kotlin/Native module resolves. Declaring a dependency always restores it and its transitive packages through dotnet restore, the same way a plain <PackageReference> would. Add a bind { } block to also generate Kotlin stubs for it, scoped to the namespaces you name.
The bridgeable types in the MimeMapping namespace bind under the mimemapping package, so MimeUtility.GetMimeMapping(...) is callable as mimemapping.MimeUtility.getMimeMapping(...); see Static classes and methods and The bridgeable subset.
Choosing namespaces
includeNamespaces(), excludeNamespaces(), and alias() scope and rename what a bind { } block generates:
No
includeNamespaces()call means every public namespace in the package is a candidate.includeNamespaces()narrows candidates to the named namespaces and their sub-namespaces;excludeNamespaces()then removes from that set and always wins on a conflict.A namespace outside the final set gets no Kotlin at all: no stub, no import, nothing to call.
alias(csharpNamespace, kotlinPackage)overridespackageNamefor that one namespace. A namespace without a matchingalias()falls back topackageName, or, if that's unset too, to the package id lowercased with-replaced by_.alias()matches one namespace exactly, unlike the filters: an included sub-namespace needs its ownalias()line or it usespackageName. Several namespaces may alias to one package.A second
bind { }block merges into the first (lists and aliases accumulate,packageNameis last-wins), so groups of namespaces get their own packages through aliases:
See The nuget {} DSL for every bind { } property, its default, and whether it's required.
Shared feeds
Declare feeds once at the nuget {} level and every dependency restores against them. Entries are feed URLs or directories of .nupkg files; relative directories resolve against the project directory. Repeated calls append.
The restore feeds are nuget.org, then the shared list, then each dependency's own
source, with duplicates dropped.The feeds are a union. A per-dependency remote
sourceadds a feed rather than replacing the list, and no feed is preferred for an id: if two remote feeds serve the same id and version, which one wins is unspecified.A directory entry behaves like a local
source: same-version rebuilds are picked up, restore moves tobuild/nuget-interop/packages, and the build fails if a package that a local feed holds at that exact id and version was restored from anywhere else. A local feed holding only other versions of an id is ignored.A
.nupkgfile, afile://URL and a directory that does not exist fail the build. For a single package, setsourceon its dependency.Declaring nothing leaves restore to your own NuGet.Config.
Binding a locally built package
Set source to a directory of .nupkg files or to one .nupkg file to bind a package you built yourself. Relative paths resolve against the project directory.
A directory source needs a
version; without one, restore fails withNU1015.A
.nupkgfile source takes its id and version from the package. Theversionmay be omitted; a differentversionor id fails the build.file://URLs are rejected; use a plain path.
Rebuilding the package under the same version is picked up on the next build: a project with a local source restores into build/nuget-interop/packages, and the plugin refreshes the local packages there before each restore. If the restored package is not the one from your source (for example nuget.org serves the same id and version), the build fails naming the dependency and the path instead of binding the wrong assembly.
A bound package restored from a local source is pinned at its version when you packNuget, so a consumer needs a feed that serves it.
The path is read as plain text, so a task that builds the .nupkg in the same Gradle build is not run for you; add a dependsOn from nugetRestore if you need that.