From 17c8e28f4ac2eb4949e67d84c89a7358af418a87 Mon Sep 17 00:00:00 2001 From: Martin Carton Date: Wed, 22 Jan 2025 20:37:53 +0100 Subject: [PATCH] Fix UsingTask order for VS 17.12 (#647) As per https://learn.microsoft.com/en-us/visualstudio/msbuild/usingtask-element-msbuild?view=vs-2022: > Unlike properties and items, the first `UsingTask` element that applies to a > `TaskName` will be used; to override tasks you must define a new `UsingTask` > before the existing one, or specify `Override="true"` in the new `UsingTask`. Therefore when using Visual Studio 17.12 .NET 8 was picked instead of .NET 9, as the task/condition for .NET 8 also matched and came first. This was broken in a69773aa152954f2484b588cd9de3d8deced463c, before that, the conditions had upper bounds. --- .../Microsoft.VisualStudio.SlnGen.targets | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.VisualStudio.SlnGen/Microsoft.VisualStudio.SlnGen.targets b/src/Microsoft.VisualStudio.SlnGen/Microsoft.VisualStudio.SlnGen.targets index f1fe2d2..707e036 100644 --- a/src/Microsoft.VisualStudio.SlnGen/Microsoft.VisualStudio.SlnGen.targets +++ b/src/Microsoft.VisualStudio.SlnGen/Microsoft.VisualStudio.SlnGen.targets @@ -11,17 +11,18 @@ AssemblyFile="$([MSBuild]::ValueOrDefault('$(SlnGenAssemblyFile)', '$(MSBuildThisFileDirectory)..\tools\net472\slngen.exe'))" Condition="'$(MSBuildRuntimeType)' == 'Full' And '$(MSBuildToolsVersion)' == 'Current'" /> + + AssemblyFile="$([MSBuild]::ValueOrDefault('$(SlnGenAssemblyFile)', '$(MSBuildThisFileDirectory)..\tools\net10.0\slngen.dll'))" + Condition="'$(MSBuildRuntimeType)' == 'Core' And '$([MSBuild]::VersionGreaterThanOrEquals($(MSBuildVersion), 17.13))' == 'true'" /> + AssemblyFile="$([MSBuild]::ValueOrDefault('$(SlnGenAssemblyFile)', '$(MSBuildThisFileDirectory)..\tools\net8.0\slngen.dll'))" + Condition="'$(MSBuildRuntimeType)' == 'Core' And '$([MSBuild]::VersionGreaterThanOrEquals($(MSBuildVersion), 17.8))' == 'true'" />