Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 2, 2025

External MSBuild SDKs (e.g., Microsoft.Build.Sql) that don't define NETCoreAppMaximumVersion were encountering confusing error messages about unsupported target framework versions, masking the actual error (missing SDK dependencies).

Changes

  • Added condition '$(NETCoreAppMaximumVersion)' != '' to the PropertyGroup setting UnsupportedTargetFrameworkVersion in Microsoft.NET.SupportedTargetFrameworks.props

This allows external SDKs to fail with their actual error message (e.g., missing NuGet.Build.Tasks.Pack) rather than triggering version compatibility checks intended only for .NET SDK projects.

<PropertyGroup Condition="'$(NETCoreAppMaximumVersion)' != ''">
    <UnsupportedTargetFrameworkVersion>$([MSBuild]::Add($(NETCoreAppMaximumVersion), 1)).0</UnsupportedTargetFrameworkVersion>
    <MinimumVisualStudioVersionForUnsupportedTargetFrameworkVersion>17.16</MinimumVisualStudioVersionForUnsupportedTargetFrameworkVersion>
</PropertyGroup>

Fixes #45009

Original prompt

This section details on the original issue you should resolve

<issue_title>Confusing error when non .NET sdk has no compatible targets</issue_title>
<issue_description>### Describe the bug
This bug occurred in one of our workflows when the runner updated to .NET 10. See Exceptions for the error message.
The "bug" being that this message is very vague and doesn't point toward the actual cause of the problem. My assumption is that this error is thrown because the Sql package doesn't relate to NETCoreAppMaximumVersion (but I'm not sure).
When I commented out the UnsupportedTargetFrameworkVersion attribute in the Microsoft.NET.SupportedTargetFrameworks.props file. It gave me an error that made much more sense and made it very easy to understand what actually was the problem and I could update the sql SDK:

C:\Users\User\.nuget\packages\microsoft.build.sql\1.0.0-rc1\Sdk\Sdk.targets(60,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\10.0.100\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets" was not found. Confirm that the expression in the Import declaration "$(MSBuildSdksPath)/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets", which evaluated to "C:\Program Files\dotnet\sdk\10.0.100\Sdks/NuGet.Build.Tasks.Pack/build/NuGet.Build.Tasks.Pack.targets", is correct, and that the file exists on disk.

So I'm wondering if it was taken into account that there can also be different SDK packages than just base .NET sdks?

To Reproduce

Create a Database project that has an tag with Microsoft.Build.Sql that does not support .NET 10 (for example <Sdk Name="Microsoft.Build.Sql" Version="1.0.0-rc1" />)

Exceptions (if any)

C:\Program Files\dotnet\sdk\10.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.SupportedTargetFrameworks.props(36,9): error MSB4186: Invalid static method invocation syntax: "[MSBuild]::Add($(NETCoreAppMaximumVersion), 1)". Method '[MSBuild]::Add' not found. Static method invocation should be of the form: $([FullTypeName]::Method()), e.g. $([System.IO.Path]::Combine(a, b)). Check that all parameters are defined, are of the correct type, and are specified in the right order.

Further technical details

details of dotnet --info

.NET SDK: Version: 10.0.100 Commit: b0f34d51fc Workload version: 10.0.100-manifests.355811b7 MSBuild version: 18.0.2+b0f34d51f

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100\

.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.

Host:
Version: 10.0.0
Architecture: x64
Commit: b0f34d51fc

.NET SDKs installed:
9.0.307 [C:\Program Files\dotnet\sdk]
10.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 8.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version - .NET 10.0.100

<agent_instructions>Only set UnsupportedTargetFrameworkVersion if NETCoreAppMaximumVersion exists. That should avoid the unhelpful error message in this case.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@baronfel Do you have a sample reproduction or binlog that shows the context in more detail? You're pointing at a specific property usage, but I don't have enough of a sense of the surrounding context to understand if this is a bug against the .NET SDK or against the external Microsoft.Build.Sql MSBuild SDK.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…ion exists

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix vague error message for non .NET SDK targets Only set UnsupportedTargetFrameworkVersion when NETCoreAppMaximumVersion exists Dec 2, 2025
Copilot AI requested a review from marcpopMSFT December 2, 2025 01:14
Copilot finished work on behalf of marcpopMSFT December 2, 2025 01:14
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.

Confusing error when non .NET sdk has no compatible targets

2 participants