Skip to content

[P2] Part 10: provider snippets don't compile — missing Microsoft.Extensions.AI.OpenAI, undeclared config, RID requirement #577

Description

@jongalloway

Found during a full end-to-end attendee run of the workshop (2026-07-27).

Part 10 is documentation-only and its structure, cross-references and API shape all check out (see "Verified correct" below). But the code snippets don't compile as printed, and Part 10's whole argument is "swap the provider, keep the same interfaces" — so the snippets are the payload.

1. Microsoft.Extensions.AI.OpenAI is missing from the package list (Medium)

The Foundry Local section says:

dotnet add package Microsoft.AI.Foundry.Local   # or ...Local.WinML on Windows
dotnet add package OpenAI

Compiling the snippet verbatim with exactly those two packages fails:

error CS1061: 'ChatClient' does not contain a definition for 'AsIChatClient' and no accessible
extension method 'AsIChatClient' accepting a first argument of type 'ChatClient' could be found

AsIChatClient and AsIEmbeddingGenerator are extension methods from Microsoft.Extensions.AI.OpenAI, which the part never mentions. Verified: adding that package makes the snippet build clean.

This affects three places:

  • the universal pattern block (lines 60-69) — the snippet the entire part is built around
  • Provider 2: Foundry Local (lines 91-106)
  • Provider 3: Ollama (lines 126-134)

Suggested fix

Add to the package list in each section, or state it once up front:

dotnet add package Microsoft.Extensions.AI.OpenAI

...and add using Microsoft.Extensions.AI; to the snippets that reference IChatClient / IEmbeddingGenerator.

2. Microsoft.AI.Foundry.Local won't build without an explicit RuntimeIdentifier (Medium)

A fresh dotnet new console + dotnet add package Microsoft.AI.Foundry.Local (1.2.3) fails to build on .NET 10:

error NETSDK1047: Assets file 'obj/project.assets.json' doesn't have a target for 'net10.0/win-x64'.
Ensure that restore has run and that you have included 'net10.0' in the TargetFrameworks for your
project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers.

Adding this to the .csproj fixes it (build then succeeds, 0 warnings):

<RuntimeIdentifier>win-x64</RuntimeIdentifier>

The error message doesn't obviously point at the fix, so this is worth a one-line note in the Foundry Local section.

3. The snippet references an undeclared config variable (Low)

Line 104:

new OpenAIClientOptions { Endpoint = new Uri(config.Web.Urls + "/v1") }

Nothing declares config. Verified: error CS0103: The name 'config' does not exist in the current context.

The section is marked "(abbreviated - see docs link below)", which covers eliding steps — but a dangling identifier is a different thing, because the attendee can't guess what config is or where it came from. Either declare it or use a literal:

new OpenAIClientOptions { Endpoint = new Uri("http://127.0.0.1:PORT/v1") }

Verified correct ✅

  • The anchor link to Part 11's "Optional: using a managed vector store" resolves (Part 11 README line 128)
  • Issue Spike: verify Foundry Local embedding-model support for RAG #496 exists and is open, with the title the part implies
  • Both Microsoft.AI.Foundry.Local and Microsoft.AI.Foundry.Local.WinML exist on NuGet at 1.2.3
  • The alternative scaffold command works:
    dotnet new aichatweb --provider azureopenai --vector-store local --name ProviderTest --output ProviderTest
  • The FoundryLocalManager.InstanceGetCatalogAsyncGetModelAsyncDownloadAsyncLoadAsyncStartWebServiceAsync chain compiles against 1.2.3, so the API shape is current

Side note for #496

The Foundry Local SDK 1.2.3 ships a public Microsoft.AI.Foundry.Local.OpenAIEmbeddingClient type. That may be a useful starting point for that spike — the table in Part 10 currently marks Foundry Local embeddings as ⏳.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions