Repository navigation
Improve empty TargetFramework diagnostic with dedicated NETSDK1241 - #54335
Conversation
TargetFramework is empty
|
@copilot This PR still reuses an existing error code. What you should do instead is update the string to be the last one in the Strings.resx file and be one higher than the last one in the list. Then update the comment that's at the end of that file which is there to guard against duplicating error codes from code flow. Please make this change and update the copilot instructions to mention how we handle netsdk error codes in that file. |
Co-authored-by: marcpopMSFT <[email protected]>
Updated in commit 65aa650. The empty |
TargetFramework is emptyTargetFramework diagnostic with dedicated NETSDK1238
|
@copilot resolve the merge conflicts with main and rebuild to regenerate the xlf files. |
Co-authored-by: marcpopMSFT <[email protected]>
Resolved by merging |
TargetFramework diagnostic with dedicated NETSDK1238TargetFramework diagnostic with dedicated NETSDK1241
|
Tested and confirm it works with both empty TF and TFs and correctly doesn't flag with a valid TFs but no TF. |
There was a problem hiding this comment.
Pull request overview
This PR improves SDK diagnostics for projects where TargetFramework is present but empty by introducing a dedicated NETSDK1241 message instead of reporting the value as an unrecognized TFM.
Changes:
- Splits unsupported TargetFramework handling into empty, invalid single-TFM, and semicolon-delimited cases.
- Adds the new
TargetFrameworkEmptyresource and regenerated localization entries. - Updates test expectations and Copilot guidance for NETSDK diagnostic additions.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
.github/copilot-instructions.md |
Documents workflow for adding new NETSDK error messages. |
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.TargetFrameworkInference.targets |
Emits TargetFrameworkEmpty for empty TargetFramework. |
src/Tasks/Common/Resources/Strings.resx |
Adds NETSDK1241 resource and updates guard comment. |
src/Tasks/Common/Resources/xlf/Strings.cs.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.de.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.es.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.fr.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.it.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.ja.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.ko.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.pl.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.ru.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.tr.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf |
Adds localized placeholder entry for TargetFrameworkEmpty. |
test/Microsoft.NET.Build.Tests/GivenThatWeWantToBuildALibrary.cs |
Updates empty TargetFramework test expectation. |
ellahathaway
left a comment
There was a problem hiding this comment.
Reviewed the diff (targets logic, Strings.resx, XLF updates, and the test change) and I don’t see any correctness or regression issues. The empty TargetFramework path now gets a dedicated NETSDK1241 diagnostic while preserving behavior for non-empty invalid and semicolon-delimited cases. Approved.
When
TargetFrameworkis present but empty, SDK evaluation currently reports it as an unrecognized TFM (''), which is misleading and often followed by secondary infrastructure errors. This change distinguishes the empty-value case from genuinely invalid TFMs while preserving existing behavior for non-empty invalid inputs.Target framework inference diagnostics
Microsoft.NET.TargetFrameworkInference.targets, split_CheckForUnsupportedTargetFrameworkinto:$(TargetFramework)→ dedicated error resourceNew resource message (new error code)
TargetFrameworkEmptyinStrings.resxas the last entry:NETSDK1241: The TargetFramework property is empty. Specify a value for the TargetFramework property in your project file.NETSDK1013for non-empty unrecognized TFMs.Strings.resx guard update
Strings.resxtoTargetFrameworkEmptyto preserve duplicate-code protection for parallel PRs.Focused test expectation update
GivenThatWeWantToBuildALibrary.It_fails_gracefully_if_targetframework_is_emptyto assert the new empty-property message.Copilot instructions update
.github/copilot-instructions.mdto document NETSDK diagnostic-code workflow forStrings.resx:Merge + localization regeneration
mainand resolvedStrings.resxconflict by preserving newly added diagnostics frommainand assigning the next available code toTargetFrameworkEmpty.src/Tasks/Common/Resources/xlf/Strings.*.xlfto match the updated resource text/code.