Gradle tasks
All tasks the plugin registers live in the nuget task group. There are two independent registration paths: publishing (publish {}, requires Kotlin Multiplatform) and consuming (dependencies {}). A project can use either, both, or neither.
Publishing (Kotlin → C#)
Registered when nuget { publish { } } is set and the Kotlin Multiplatform plugin is applied.
Task | Description | Depends on |
|---|---|---|
| Packages the Kotlin/Native shared library as a NuGet package | the shared-lib link tasks, |
| Reports declarations the forward bridge could not generate |
|
| Compiles the generated C# bindings with dotnet before packNuget stages them |
|
packNuget writes the staged package to build/nuget/{packageId}.{version}/ and the zipped .nupkg to build/nuget/{packageId}.{version}.nupkg. When the project also binds a dependency, it merges the reverse-direction C# shims from nugetGenerateShims into the same contentFiles/cs/any/ folder and pins each bound dependency at its exact resolved version in the .nuspec <dependencies> block.
nugetReportDiagnostics re-emits every skipped-declaration message as a Gradle warning on each packNuget run, so a skipped declaration stays visible even once its generating KSP task is UP-TO-DATE. See Forward overview.
nugetCompileInterop
Before packNuget stages the package, nugetCompileInterop builds every file it would stage (the KSP-generated Interop.cs, plus any reverse-direction shims) against an exact-version PackageReference for each bound dependency, in an isolated build environment that ignores any global.json, Directory.Build.props/targets, Directory.Packages.props, or NuGet.config elsewhere in the repo. If a generated file does not compile, packNuget fails with the compiler's own output, for example:
When dotnet is not found on PATH (or is on PATH but can't run), the task logs a warning and skips the check, so publishing a Kotlin/Native library still needs no .NET SDK. See Prerequisites.
Registered only when nuget { publish { snapshot = true } } is set:
Task | Description | Writes |
|---|---|---|
| Mints a unique snapshot version for this build |
|
| Writes the MSBuild props file pinning the current snapshot version |
|
Both are never up to date, since a snapshot build's whole point is a fresh timestamp every run. See The nuget {} DSL for snapshot/versionPropsFile.
KSP's own kspKotlin{Target} task (registered by the Kotlin Gradle plugin, not this plugin) generates Interop.cs and the Kotlin bridge wrappers. packNuget depends on it but does not register it.
Consuming (C# → Kotlin)
Registered as soon as nuget { dependencies { } } declares at least one dependency, independent of publish {}, and even of Kotlin Multiplatform being applied.
Task | Description | Depends on | Writes |
|---|---|---|---|
| Generates the synthetic interop.csproj for NuGet dependency resolution | (none) |
|
| Runs dotnet restore to download declared NuGet packages |
|
|
| IDE-sync umbrella task: resolve NuGet dependencies |
| (none, umbrella task) |
The following three are registered only when at least one dependency declares a bind { } block:
Task | Description | Depends on | Writes |
|---|---|---|---|
| Extracts the public API surface of bound NuGet packages into reverse-ir.json |
|
|
| Generates Kotlin stubs and the C# registration contract from reverse-ir.json |
|
|
| Generates C#-side [UnmanagedCallersOnly] thunks and startup registration shims from reverse-ir.json |
|
|
nugetGenerateBindings's output directory is added as a Kotlin source directory on nativeMain (and, per native target, mingwMain or posixMain), and every kspKotlin{Target} task depends on it, so KSP sees the reverse-generated stubs before it runs. nugetGenerateShims's C# output is what packNuget merges in when a project both publishes and binds a dependency.
See the nuget {} DSL reference for the publish {} and dependencies { bind { } } blocks that drive this wiring.