-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[release/10.0] Allow tools to run on projects targeting multiple frameworks #37301
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
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 fixes an issue where the dotnet ef tool fails for projects targeting multiple target frameworks (multi-TFM). The fix passes framework, configuration, and runtime parameters to Project.FromFile() for both the main project and startup project, and adds a helpful error message when multi-TFM projects are detected without a specified framework.
Key changes:
- Modified
RootCommand.csto pass framework/configuration/runtime parameters to both project and startup project initialization - Added
HasMultipleTargetFrameworks()helper method to detect multi-TFM scenarios and provide a clear error message - Added
MultipleTargetFrameworksresource string for the new error message
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/dotnet-ef/RootCommand.cs | Updated to pass framework/configuration/runtime parameters to Project.FromFile() for the main project, matching the existing startup project initialization |
| src/dotnet-ef/Properties/Resources.resx | Added new error message resource for multi-TFM scenario |
| src/dotnet-ef/Properties/Resources.Designer.cs | Generated code for new resource string and minor documentation improvement for NativeAotDescription |
| src/dotnet-ef/Project.cs | Added HasMultipleTargetFrameworks() method to detect multi-TFM projects and improved error handling with specific message |
Files not reviewed (1)
- src/dotnet-ef/Properties/Resources.Designer.cs: Language not supported
Co-authored-by: Copilot <[email protected]>
|
Hello, Looking at your commit, I see that you are suggesting that an additional option Could you please confirm how to fix this issue ? |
|
@rfrerebe-stx It will work after this change is merged, see the fix in https://github.com/dotnet/efcore/pull/37301/files#diff-ef9188d23e289a8c4dbaa9d76aea973b8a91110fb3e21e4816953338e28ebf2f |
|
cc @artl93 - With cutoff date tomorrow, please review so this can proceed to tactics today |
|
@AndriySvyryd - can you clarify how the tooling change will impact CI/CD? It sounds like we're still forcing the user to make a choice. Is this the fix we'd want in the fullness of time? |
|
@artl93 This will be documented as a breaking change. I do think this is the right behavior going forward, as previously there have been reports of tools running successfully locally but failing in CI/CD because of the implicitly chosen TFM. |
artl93
left a comment
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.
Approving, though the breaking change doc would be great to see.
Fixes #37230
Description
For EF 10 we started relying on the
ResolvePackageAssetsMSBuild task to get more accurate information about the project dependencies. However, this task is not available if the project is targeting multiple TFMs. The solution is to allow users to select which framework should be used.This will be documented as a breaking change: dotnet/EntityFramework.Docs#5200
Customer impact
For apps targeting multiple TFMs the ef tool will throw an exception when any command is invoked. The workaround to change the project to target a single TFM temporarily. However, this isn't possible in CI/CD scenarios.
How found
Multiple customer reports on EF 10.
Regression
Yes, from EF 9
Testing
Tested manually.
Risk
Low. Targeted fix that only affects design-time tools.