-
-
Notifications
You must be signed in to change notification settings - Fork 1
Friendly error when non-matching SDK is used #101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Since we are building with latest&greatest .NET to get the extension class syntax, consumers need to use a matching SDK in order for that to work. Provide a compile-time error instead of the inscrutable alternative (unsupported language feature or what-not). This will turn off itself when we ship with a stable SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements a compile-time check to ensure consumers use a matching SDK version when the package is built with a preview .NET SDK. The change prevents cryptic compilation errors by providing a clear error message when an incompatible SDK is detected.
Key changes:
- Adds MSBuild targets to validate SDK version compatibility at build time
- Dynamically updates SDK version information during package creation
- Provides user-friendly error messaging for SDK mismatches
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/AI/Devlooped.Extensions.AI.targets | Adds build-time validation target with SDK version check and error message |
| src/AI/AI.csproj | Implements dynamic update of SDK version properties during packaging |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| <BuiltSdkPreviewVersion>10.0.100-preview.7.25380.108</BuiltSdkPreviewVersion> | ||
| </PropertyGroup> | ||
| <Target Name="EnsureSamePreviewSdkVersion" BeforeTargets="Build" Condition="'$(BuiltWithSdkPreview)' == 'true'"> | ||
| <Error Condition="'$(_NETCoreSdkIsPreview)' == 'false' or '$(NETCoreSdkVersion)' != '$(BuiltSdkPreviewVersion)'" Text="This version was built with a preview SDK and requires a matching one. Please install SDK version $(BuiltSdkPreviewVersion) or update to a newer package version." /> |
Copilot
AI
Aug 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The condition logic could be clearer by separating the two error cases. Consider using separate Error elements for when SDK is not preview vs when versions don't match, as these are different problems requiring different solutions.
| <Error Condition="'$(_NETCoreSdkIsPreview)' == 'false' or '$(NETCoreSdkVersion)' != '$(BuiltSdkPreviewVersion)'" Text="This version was built with a preview SDK and requires a matching one. Please install SDK version $(BuiltSdkPreviewVersion) or update to a newer package version." /> | |
| <Error Condition="'$(_NETCoreSdkIsPreview)' == 'false'" Text="This version was built with a preview SDK. Please use a preview .NET SDK (version $(BuiltSdkPreviewVersion) or newer)." /> | |
| <Error Condition="'$(_NETCoreSdkIsPreview)' == 'true' and '$(NETCoreSdkVersion)' != '$(BuiltSdkPreviewVersion)'" Text="This version was built with .NET SDK version $(BuiltSdkPreviewVersion). Please install and use this SDK version, or update to a newer package version." /> |
🧪 Details on Ubuntu 24.04.2 LTSfrom dotnet-retest v0.7.2 on .NET 9.0.8 with 💜 by @devlooped |
Since we are building with latest&greatest .NET to get the extension class syntax, consumers need to use a matching SDK in order for that to work.
Provide a compile-time error instead of the inscrutable alternative (unsupported language feature or what-not).
This will turn off itself when we ship with a stable SDK.