Configuration options

The SharpDocsOptions class, bound from the SharpDocs section of IConfiguration.


AddSharpDocs() binds the SharpDocs section of IConfiguration to SharpDocsOptions. You can pass a custom section name:

builder.Services.AddSharpDocs(builder.Configuration, sectionName: "Docs");

Properties

DocsRoot (string)

Path to the folder containing the root sharpdocs.json and (in single-project mode) the markdown tree. Relative paths resolve against IHostEnvironment.ContentRootPath; absolute paths are used as-is.

Default: "docs".

"DocsRoot": "site"

At startup, ProjectRegistry throws DirectoryNotFoundException if the resolved path doesn't exist, or FileNotFoundException if it lacks sharpdocs.json. These two failures are always fatal; per-project failures inside a multi-project setup are degraded, not fatal.

ArtifactsRoot (string)

Path to the folder containing *.nupkg files for the feed in single-project mode. Same resolution rules as DocsRoot.

Default: "artifacts".

If this folder is missing, the feed logs a warning and serves an empty result for local data — it does not throw.

In multi-project mode this option is ignored. Each project declares its own artifacts folder inside its sharpdocs.json ("artifacts": "...", default ./artifacts relative to the project).

Upstreams (array of { Url, MaxTake? })

Upstream NuGet v3 service-index URLs. Each upstream is resolved once at startup; its endpoints (flatcontainer, registration, search, autocomplete) are discovered from the service index and cached for the process lifetime.

Configured from JSON:

"Upstreams": [
  { "Url": "https://api.nuget.org/v3/index.json", "MaxTake": 50 }
]

Or fluently after AddSharpDocs():

builder.Services.AddSharpDocs(builder.Configuration)
    .AddUpstream("https://api.nuget.org/v3/index.json", maxTake: 50);

Both sources union. Duplicates (case-insensitive) are ignored. MaxTake caps how many results a given upstream contributes to a search/autocomplete fan-out. Default: empty.

UpstreamTimeoutSeconds (int)

Per-upstream HTTP timeout for metadata calls (version lists, registration, search, autocomplete). Nupkg and nuspec downloads use a longer/unbounded read timeout because payloads can be large. Default: 10.

Links rendered in the site header, to the right of the title. Useful for pointing at /packages, an external blog, or a status page.

"NavLinks": [
  { "Label": "Packages", "Href": "/packages" },
  { "Label": "NuGet Feed", "Href": "/v3/index.json" },
  { "Label": "Blog", "Href": "https://example.com/blog" }
]

Default: empty.

Full example

{
  "SharpDocs": {
    "DocsRoot": "../../site",
    "ArtifactsRoot": "../../artifacts",
    "Upstreams": [
      { "Url": "https://api.nuget.org/v3/index.json", "MaxTake": 50 }
    ],
    "UpstreamTimeoutSeconds": 10,
    "NavLinks": [
      { "Label": "Packages", "Href": "/packages" },
      { "Label": "NuGet Feed", "Href": "/v3/index.json" }
    ]
  }
}