feat(agents): validate .NET runtime vs TargetFramework after init#8222
Conversation
…ework mismatch Add a non-blocking validation framework that runs after init completes. The first validator checks that the selected .NET runtime version is compatible with the .csproj TargetFramework, printing a clear error message with fix instructions when a mismatch is detected. Closes Azure#8202
b9efd83 to
5011eaf
Compare
There was a problem hiding this comment.
Pull request overview
Adds a non-blocking, advisory post-azd ai agent init validation that compares the selected .NET runtime (dotnet_N) against the TargetFramework in the project's .csproj. If the target framework is higher than the selected runtime (a known cause of confusing remote-build failures), a red ERROR with fix instructions is printed; matching configurations print a green OK; Python and missing-.csproj cases are skipped. The validator is wired into both the template-based init flow and the from-code init flow, and never alters or blocks init.
Changes:
- New
init_validate.gowithvalidatePostInitframework andvalidateDotnetRuntimeVsCsprojcheck, including a simple<TargetFramework>netX.Y</TargetFramework>regex parser. - New
init_validate_test.gocovering match, mismatch, higher-runtime, no-csproj, unreadable-dir, Python-skip, andnilcode-config cases. init.goandinit_from_code.goinvokevalidatePostInitafter their respective init flows complete.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_validate.go | New validation framework + .NET runtime vs TargetFramework check. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_validate_test.go | Unit tests for the new validator and its scenarios. |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init.go | Calls validatePostInit after template init completes (guarded by ContainerAgent assertion). |
| cli/azd/extensions/azure.ai.agents/internal/cmd/init_from_code.go | Calls validatePostInit after from-code init completes. |
jongio
left a comment
There was a problem hiding this comment.
Clean addition - advisory only, nil-safe, can't break existing flows. Two items below worth a look.
- Relax TargetFramework regex to handle platform suffixes (e.g. net8.0-windows) - Assert stdout output in mismatch/match tests (ERROR/OK substrings) - Add test case for platform-suffixed TFM
|
/check-enforcer override |
|
I'd like @therealjohn to take a look at this. On the surface I'm ok with it, but I'm a little concerned with the idea of adding warnings/error messages just before we say "everything is good you're done". |
Summary
validatePostInit) that runs afterazd ai agent initcompletesTargetFrameworkprints a clear ERROR (red) with fix instructions if target > runtime (which will fail at build/deploy time)init.go) and from-code flow (init_from_code.go)Changes
init_validate.goinit_validate_test.goinit.govalidatePostInitafter template init completesinit_from_code.govalidatePostInitafter from-code init completesCloses #8202
E2E Test Results (Manual Interactive Testing)
All tests run interactively using only
azd ai agent init+azd deploy(no file modifications).7/7 passed PR feature (runtime validation) works correctly, no regressions in init/deploy/invoke flows.