Skip to content

Fix error message for non-Windows OS #12046

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

abulyaev
Copy link

Fixes #6647

Context

We shouldn't show error about Developer Pack on non-Windows OSes. This message is reasonable for Windows scenarios, but since there are no .NET Framework Developer or Targeting Packs for Linux or macOS, we shouldn't mention them in that circumstance.

Error message:
error MSB3644: The reference assemblies for .NETFramework,Version=v4.8 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks

Changes Made

Check added to determine if the OS is Windows

Testing

Tests passed

Notes

I assumed we also shouldn't show GetReferenceAssemblyPaths.OutOfDateSDK error if it's not Windows but I can change that if its not true

@@ -248,7 +249,7 @@ private IList<String> GetPaths(string rootPath, string targetFrameworkFallbackSe
{
// No reference assembly paths could be found, log an error so an invalid build will not be produced.
// 1/26/16: Note this was changed from a warning to an error (see GitHub #173).
if (pathsToReturn.Count == 0)
if (pathsToReturn.Count == 0 && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (pathsToReturn.Count == 0 && RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
if (pathsToReturn.Count == 0 && NativeMethodsShared.IsWindows)

Copy link
Author

Choose a reason for hiding this comment

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

Thank you, I wasn't sure if I should use RuntimeInformation and that's definitely look better

@abulyaev abulyaev force-pushed the fix-non-windows-os-error-msg branch from c0de58b to e1af409 Compare June 20, 2025 08:40
@@ -248,7 +248,7 @@ private IList<String> GetPaths(string rootPath, string targetFrameworkFallbackSe
{
// No reference assembly paths could be found, log an error so an invalid build will not be produced.
// 1/26/16: Note this was changed from a warning to an error (see GitHub #173).
if (pathsToReturn.Count == 0)
if (pathsToReturn.Count == 0 && NativeMethodsShared.IsWindows)
Copy link
Member

Choose a reason for hiding this comment

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

I'd still like to return an error in the non-Windows case. It just shouldn't reference installing Windows-only targeting packs.

@@ -248,7 +248,7 @@ private IList<String> GetPaths(string rootPath, string targetFrameworkFallbackSe
{
// No reference assembly paths could be found, log an error so an invalid build will not be produced.
// 1/26/16: Note this was changed from a warning to an error (see GitHub #173).
if (pathsToReturn.Count == 0)
if (pathsToReturn.Count == 0 && NativeMethodsShared.IsWindows)
Copy link
Member

Choose a reason for hiding this comment

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

Is the right condition here IsWindows, or #if NET? Does the find-targeting-packs code work on Windows/net9?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't mention installing Developer Pack on non-Windows OSes (MSB3644)
3 participants