Skip to content

Emit more descriptive error when running .NET Framework exe on non-Windows - #54581

Merged
akoeplinger merged 1 commit into
dotnet:mainfrom
akoeplinger:fix-netfx-run-on-unix
Jul 7, 2026
Merged

akoeplinger merged 1 commit into
dotnet:mainfrom
akoeplinger:fix-netfx-run-on-unix

Conversation

@akoeplinger

Copy link
Copy Markdown
Member

Adresses feedback from #51953 (comment)

Copilot AI review requested due to automatic review settings June 3, 2026 19:27
@github-actions github-actions Bot added the sdk-diagnostic-docs-needed Indicates that a PR introduces new diagnostic codes, which must be documented over at dotnet/docs label Jun 3, 2026
@github-actions

github-actions Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

📋 SDK Diagnostic Documentation Reminder

This PR introduces 1 new SDK diagnostic code:

  • NETSDK1243

Action Required

Please ensure that documentation for this diagnostic is added or updated in the dotnet/docs repository at:

Each diagnostic should have:

  • A clear description of the error/warning
  • Possible causes
  • Recommended solutions
  • Code examples where applicable

Thank you for helping keep our documentation up to date! 🙏

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a clearer, localized SDK error for dotnet run when attempting to run a .NET Framework executable on non-Windows platforms (where the SDK does not provide a default RunCommand), aligning with the scenario discussed in #51953.

Changes:

  • Introduces a new MSBuild validation target that emits NETSDK1241 for unsupported .NETFramework run scenarios on non-Windows when RunCommand isn’t set.
  • Adds the new RunCommandRequiresWindowsForNetFramework resource string (with localized XLF entries).
  • Adds a non-Windows-only regression test validating that dotnet run surfaces NETSDK1241.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/Microsoft.NET.Build.Tests/GivenThatWeWantToRunADesktopExeOnNonWindows.cs Adds coverage ensuring dotnet run fails with NETSDK1241 for net472 executables on non-Windows.
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets Adds _CheckRunCommandSupported target to emit the new descriptive error after ComputeRunArguments.
src/Tasks/Common/Resources/Strings.resx Adds the RunCommandRequiresWindowsForNetFramework (NETSDK1241) error message and updates the “latest message added” marker.
src/Tasks/Common/Resources/xlf/Strings.cs.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.de.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.es.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.fr.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.it.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.ja.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.ko.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.pl.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.pt-BR.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.ru.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.tr.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.zh-Hans.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.
src/Tasks/Common/Resources/xlf/Strings.zh-Hant.xlf Adds localization entry for RunCommandRequiresWindowsForNetFramework.

@akoeplinger
akoeplinger requested a review from Youssef1313 June 13, 2026 18:45
@akoeplinger
akoeplinger force-pushed the fix-netfx-run-on-unix branch from 26b19bb to c962d14 Compare July 3, 2026 10:32

@Youssef1313 Youssef1313 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@akoeplinger
akoeplinger merged commit 21d8c70 into dotnet:main Jul 7, 2026
25 checks passed
@akoeplinger
akoeplinger deleted the fix-netfx-run-on-unix branch July 7, 2026 15:55
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Infrastructure sdk-diagnostic-docs-needed Indicates that a PR introduces new diagnostic codes, which must be documented over at dotnet/docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants