Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dotnet-svcutil/lib/src/Shared/MSBuildProj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public static async Task<MSBuildProj> ParseAsync(string projectText, string proj
}
else
{
msbuildProj._targetFramework = string.Concat("net", TargetFrameworkHelper.s_currentSupportedVersions.First());
msbuildProj._targetFramework = string.Concat("net", TargetFrameworkHelper.MinSupportedDotNetVersion);
}

msbuildProj._targetFrameworks.Add(msbuildProj._targetFramework);
Expand Down
38 changes: 25 additions & 13 deletions src/dotnet-svcutil/lib/src/Shared/TargetFrameworkHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.Tools.ServiceModel.Svcutil
{
internal class TargetFrameworkHelper
{
internal static readonly List<string> s_currentSupportedVersions = new List<string>() { "8.0", "9.0", "10.0" };
internal const string MinSupportedDotNetVersion = "8.0";
public static Version MinSupportedNetFxVersionForDotNet { get; } = new Version("4.5");
public static Version MinSupportedNetStandardVersion { get; } = new Version("1.3");
public static Version MinSupportedNetCoreAppVersion { get; } = new Version("1.0");
Expand All @@ -27,10 +27,15 @@ internal class TargetFrameworkHelper
ProjectDependency.FromPackage("System.ServiceModel.Security", "4.10.*"),
ProjectDependency.FromPackage("System.ServiceModel.Federation", "4.10.*")
} },
{"Current", new List<ProjectDependency> {
{"Net8", new List<ProjectDependency> {
ProjectDependency.FromPackage("System.ServiceModel.Http", "8.*"),
ProjectDependency.FromPackage("System.ServiceModel.NetTcp", "8.*"),
ProjectDependency.FromPackage("System.ServiceModel.Primitives", "8.*")
} },
{"Net10", new List<ProjectDependency> {
ProjectDependency.FromPackage("System.ServiceModel.Http", "10.*"),
ProjectDependency.FromPackage("System.ServiceModel.NetTcp", "10.*"),
ProjectDependency.FromPackage("System.ServiceModel.Primitives", "10.*")
} }
};

Expand Down Expand Up @@ -62,20 +67,27 @@ public static IEnumerable<ProjectDependency> GetWcfProjectReferences(IEnumerable
return FullFrameworkReferences;
}

// Determine the lowest .NET Core version in the target frameworks
// Determine the lowest .NET (Core) version in the target frameworks (netstandard is excluded by GetLowestNetCoreVersion).
// Selection uses a >= threshold (not a closed list) so that future .NET versions (net11.0, net12.0, ...) automatically
// pick the highest currently-supported bucket instead of silently dropping to the Legacy 4.10.* set.
Version netCoreVersion = GetLowestNetCoreVersion(targetFrameworks);

// Return the appropriate WCF reference based on the target framework version
// Behavior table based on framework combinations:
// netstandard2.0 : add WCF reference 4.10.*
// netstandard2.0;net8.0: add WCF reference 8.*
// netstandard2.0;net6.0: add WCF reference 4.10.*
// net6.0;net8.0 : add WCF reference 4.10.*
if (netCoreVersion != null && s_currentSupportedVersions.Contains(netCoreVersion.ToString()))
// Mapping (lowest DNX TFM wins):
// >= net10.0 -> Net10 (10.*)
// >= net8.0 -> Net8 (8.*)
// otherwise -> Legacy (4.10.*) -- includes netstandard-only, net6.0/7.0, and mixed older+newer DNX combos.
if (netCoreVersion != null)
{
return NetCoreVersionReferenceTable["Current"];
if (netCoreVersion >= new Version(10, 0))
{
return NetCoreVersionReferenceTable["Net10"];
}
if (netCoreVersion >= new Version(8, 0))
{
return NetCoreVersionReferenceTable["Net8"];
}
}
// Otherwise, return the legacy WCF reference

return NetCoreVersionReferenceTable["Legacy"];
}

Expand Down Expand Up @@ -152,7 +164,7 @@ public static bool IsEndofLifeFramework(string fullFrameworkName)
// Return true if .NET version is less than the lowest supported Version
return frameworkInfo.IsDnx
&& !frameworkInfo.Name.Equals(FrameworkInfo.Netstandard, StringComparison.OrdinalIgnoreCase)
&& frameworkInfo.Version < new Version(s_currentSupportedVersions.First());
&& frameworkInfo.Version < new Version(MinSupportedDotNetVersion);
}

// Return false if parsing fails or no conditions matched
Expand Down
Loading