diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs index 90f03bed81..a437da0414 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Discover/SdkProjectDiscoveryTests.cs @@ -479,6 +479,51 @@ await TestDiscoverAsync( ); } + [Fact] + public async Task DependenciesCanBeDiscoveredWithWindowsSpecificTfm() + { + await TestDiscoverAsync( + packages: + [ + MockNuGetPackage.CreateSimplePackage("Some.Dependency", "1.2.3", "netstandard2.0"), + ], + startingDirectory: "src", + projectPath: "src/library.csproj", + files: + [ + ("src/library.csproj", """ + + + net9.0-windows + + + + + + """) + ], + expectedProjects: + [ + new() + { + FilePath = "library.csproj", + Dependencies = + [ + new("Some.Dependency", "1.2.3", DependencyType.PackageReference, TargetFrameworks: ["net9.0-windows"], IsDirect: true), + ], + ImportedFiles = [], + Properties = + [ + new("TargetFramework", "net9.0-windows", "src/library.csproj"), + ], + TargetFrameworks = ["net9.0-windows"], + ReferencedProjectPaths = [], + AdditionalFiles = [], + }, + ] + ); + } + private static async Task TestDiscoverAsync(string startingDirectory, string projectPath, TestFile[] files, ImmutableArray expectedProjects, MockNuGetPackage[]? packages = null) { using var testDirectory = await TemporaryDirectory.CreateWithContentsAsync(files); diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs index cc261755fc..3d2d5a0859 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core.Test/Utilities/MSBuildHelperTests.cs @@ -606,6 +606,18 @@ public static IEnumerable GetTargetFrameworkValuesFromProjectData() new[] { "net8.0-windows7.0" } ]; + yield return + [ + """ + + + net9.0-windows + + + """, + new[] { "net9.0-windows" } + ]; + // legacy projects yield return [ diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.props b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.props index cec5322a18..decaca93d1 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.props +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.props @@ -1,8 +1,16 @@ + + <_DefaultTargetPlatformVersion Condition="'$(_DefaultTargetPlatformVersion)' == ''">0.0 true true - 1.0 + $(_DefaultTargetPlatformVersion) \ No newline at end of file diff --git a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.targets b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.targets index 65ba7d4bbd..10237b0e63 100644 --- a/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.targets +++ b/nuget/helpers/lib/NuGetUpdater/NuGetUpdater.Core/DependencyDiscovery.targets @@ -1,4 +1,9 @@ + + + <_DefaultTargetPlatformVersion>1.0 + +