Skip to content

Commit e7e1a9b

Browse files
authored
Drop support for .NET 9 (#355)
1 parent 19e6688 commit e7e1a9b

32 files changed

Lines changed: 105 additions & 572 deletions

‎.github/workflows/CI.yml‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,18 @@ env:
1717
BuildPlatform: 'Any CPU'
1818
ContinuousIntegrationBuild: 'true'
1919
DotNet8Version: '8.x'
20-
DotNet9Version: '9.x'
2120
DotNet10Version: '10.x'
2221

2322
jobs:
2423
BuildAndTest:
2524
strategy:
2625
matrix:
27-
os: [windows-latest, ubuntu-latest, macos-latest]
26+
os: [windows-2025, windows-2025-vs2026, ubuntu-latest, macos-latest]
2827
include:
29-
- os: windows-latest
30-
name: Windows
28+
- os: windows-2025
29+
name: Windows VS2022
30+
- os: windows-2025-vs2026
31+
name: Windows VS2026
3132
- os: ubuntu-latest
3233
name: Linux
3334
- os: macos-latest
@@ -43,26 +44,22 @@ jobs:
4344
with:
4445
fetch-depth: 0
4546

46-
- name: Install .NET ${{ env.DotNet8Version }}, ${{ env.DotNet9Version }}, and ${{ env.DotNet10Version }}
47+
- name: Install .NET ${{ env.DotNet8Version }} and ${{ env.DotNet10Version }}
4748
uses: actions/setup-dotnet@v5
4849
with:
4950
dotnet-version: |
5051
${{ env.DotNet8Version }}
51-
${{ env.DotNet9Version }}
5252
${{ env.DotNet10Version }}
5353
5454
- name: Build Solution
5555
run: dotnet build "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/build.binlog"
5656

5757
- name: Run Unit Tests (.NET Framework)
58-
if: ${{ matrix.name == 'Windows' }}
58+
if: ${{ matrix.name == 'Windows VS2022' || matrix.name == 'Windows VS2026' }}
5959
run: dotnet test --no-restore --no-build --framework net472 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-net472.binlog"
6060

6161
- name: Run Unit Tests (.NET 8)
6262
run: dotnet test --no-restore --no-build --framework net8.0 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-net8.0.binlog"
63-
64-
- name: Run Unit Tests (.NET 9)
65-
run: dotnet test --no-restore --no-build --framework net9.0 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-net9.0.binlog"
6663

6764
- name: Run Unit Tests (.NET 10)
6865
run: dotnet test --no-restore --no-build --framework net10.0 "/Property:Platform=${{ env.BuildPlatform }};Configuration=${{ env.BuildConfiguration }}" "/BinaryLogger:${{ env.ArtifactsDirectoryName }}/test-net10.0.binlog"

‎Directory.Packages.props‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,32 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
5-
<MicrosoftBuildPackageVersion>18.0.2</MicrosoftBuildPackageVersion>
5+
<MicrosoftBuildPackageVersion>18.6.3</MicrosoftBuildPackageVersion>
66
<MicrosoftBuildPackageVersion Condition="'$(TargetFramework)' == 'net8.0'">17.11.48</MicrosoftBuildPackageVersion>
7-
<MicrosoftBuildPackageVersion Condition="'$(TargetFramework)' == 'net9.0'">17.14.28</MicrosoftBuildPackageVersion>
7+
<MicrosoftCodeAnalysisCSharpVersion>5.3.0</MicrosoftCodeAnalysisCSharpVersion>
8+
<MicrosoftCodeAnalysisCSharpVersion Condition="'$(TargetFramework)' == 'net8.0'">4.13.0</MicrosoftCodeAnalysisCSharpVersion>
9+
<SystemCodeDomVersion>10.0.8</SystemCodeDomVersion>
10+
<SystemCodeDomVersion Condition="'$(TargetFramework)' == 'net8.0'">8.0.0</SystemCodeDomVersion>
811
</PropertyGroup>
912
<ItemGroup>
1013
<PackageVersion Include="AssemblyShader" Version="1.1.3" />
1114
<PackageVersion Include="Microsoft.Build" Version="$(MicrosoftBuildPackageVersion)" />
1215
<PackageVersion Include="Microsoft.Build.Utilities.Core" Version="$(MicrosoftBuildPackageVersion)" />
13-
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
16+
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpVersion)" />
1417
<PackageVersion Include="Microsoft.CodeAnalysis.PublicApiAnalyzers" Version="4.14.0" />
1518
<PackageVersion Include="Microsoft.IO.Redist" Version="6.1.3" />
16-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
19+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
1720
<PackageVersion Include="Microsoft.VisualStudio.Setup.Configuration.Interop" Version="3.14.2075" />
1821
<PackageVersion Include="Microsoft.VisualStudio.SolutionPersistence" Version="1.0.52" />
1922
<PackageVersion Include="Shouldly" Version="4.3.0" />
2023
<PackageVersion Include="System.IO.Compression" Version="4.3.0" />
21-
<PackageVersion Include="xunit" Version="2.9.3" />
24+
<PackageVersion Include="System.CodeDom" Version="$(SystemCodeDomVersion)" />
25+
<PackageVersion Include="xunit.v3" Version="3.2.2" />
2226
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
2327
</ItemGroup>
2428
<ItemGroup>
2529
<GlobalPackageReference Include="Microsoft.Build.Artifacts" Version="6.1.63" />
26-
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
30+
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.300" />
2731
<GlobalPackageReference Include="Nerdbank.GitVersioning" Version="3.9.50" />
2832
<GlobalPackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556" />
2933
<Compile Include="..\Shared\GlobalSuppressions.cs" />

‎MSBuildProjectCreator.sln‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.2.32516.85
3+
# Visual Studio Version 18
4+
VisualStudioVersion = 18.5.11523.13 main
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.Utilities.ProjectCreation", "src\Microsoft.Build.Utilities.ProjectCreation\Microsoft.Build.Utilities.ProjectCreation.csproj", "{0CCB62BE-922F-480F-B8EA-823CB8A9CBDC}"
77
EndProject
@@ -22,7 +22,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{8339FD67
2222
NuGet.config = NuGet.config
2323
README.md = README.md
2424
version.json = version.json
25-
xunit.runner.json = xunit.runner.json
2625
EndProjectSection
2726
EndProject
2827
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{3F239E9A-CEB8-410A-BA63-4F860B9566E6}"

‎src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/BuildTests.cs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,12 @@ public void CanRestoreAndBuild()
188188
[Fact]
189189
public void CanRestoreAndBuildMultipleTimes()
190190
{
191-
ProjectCreator projectCreator = ProjectCreator.Templates.SdkCsproj(
192-
path: GetTempFileName(".csproj"),
193-
targetFramework: TargetFramework)
191+
ProjectCreator projectCreator = ProjectCreator.Create(
192+
path: GetTempFileName(".csproj"))
193+
.Target("Restore")
194+
.TaskMessage("Restoring...", MessageImportance.High)
195+
.Target("Build")
196+
.TaskMessage("Building...", MessageImportance.High)
194197
.Save()
195198
.TryBuild(restore: true, "Build", out bool result, out BuildOutput buildOutput);
196199

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFrameworks>net472;net8.0;net9.0;net10.0</TargetFrameworks>
3+
<TargetFrameworks>net472;net8.0;net10.0</TargetFrameworks>
4+
<OutputType>Exe</OutputType>
45
<IsPackable>false</IsPackable>
56
</PropertyGroup>
67
<Import Project="..\Microsoft.Build.Utilities.ProjectCreation\build\MSBuild.ProjectCreation.props" Condition="'$(TargetFramework)' == 'net472'" />
7-
<ItemGroup>
8-
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
9-
</ItemGroup>
108
<ItemGroup>
119
<PackageReference Include="AssemblyShader" />
1210
<PackageReference Include="Microsoft.NET.Test.Sdk" ShadeDependencies="NuGet.Frameworks" />
1311
<PackageReference Include="Shouldly" />
14-
<PackageReference Include="System.CodeDom" VersionOverride="9.0.0" Condition="'$(TargetFramework)' == 'net9.0'" ExcludeAssets="All" />
15-
<PackageReference Include="System.CodeDom" VersionOverride="10.0.0" Condition="'$(TargetFramework)' == 'net10.0'" ExcludeAssets="All" />
16-
<PackageReference Include="xunit" />
12+
<PackageReference Include="System.CodeDom" Condition="'$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net10.0'" ExcludeAssets="Runtime" />
13+
<PackageReference Include="xunit.v3" />
1714
<PackageReference Include="xunit.runner.visualstudio" />
1815
</ItemGroup>
1916
<ItemGroup>
@@ -22,4 +19,10 @@
2219
<ItemGroup>
2320
<ProjectReference Include="..\Microsoft.Build.Utilities.ProjectCreation\Microsoft.Build.Utilities.ProjectCreation.csproj" />
2421
</ItemGroup>
22+
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
23+
<PackageReference Include="System.Text.Json" VersionOverride="10.0.3" />
24+
<PackageReference Include="System.Text.Encodings.Web" VersionOverride="10.0.3" />
25+
26+
<SuggestedBindingRedirects Include="System.Text.Encodings.Web, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" MaxVersion="10.0.0.3" />
27+
</ItemGroup>
2528
</Project>

‎src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/SdkCsprojTests.cs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ namespace Microsoft.Build.Utilities.ProjectCreation.UnitTests
1010
public class SdkCsprojTests : TestBase
1111
{
1212
[Fact]
13-
public void CanBuild()
13+
public void CanRestoreAndBuild()
1414
{
1515
ProjectCreator.Templates.SdkCsproj(
16-
targetFramework: TargetFramework,
17-
path: GetTempFileName(".csproj"))
18-
.Save()
19-
.TryBuild(restore: true, "Build", out bool result, out BuildOutput buildOutput);
16+
targetFramework: TargetFramework,
17+
path: GetTempFileName(".csproj"))
18+
.Save()
19+
.TryBuild(restore: true, "Build", out bool result, out BuildOutput buildOutput);
2020

2121
result.ShouldBeTrue(buildOutput.GetConsoleLog());
2222
}

‎src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/TestBase.cs‎

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,17 @@ protected TestBase()
1515
WriteGlobalJson();
1616
}
1717

18-
public string DotNetSdkVersion
19-
{
20-
get =>
21-
#if NET8_0 || NETFRAMEWORK
22-
"8.0.100";
23-
#elif NET9_0 || NETFRAMEWORK
24-
"9.0.100";
25-
#elif NET10_0 || NETFRAMEWORK
26-
"10.0.100";
27-
#else
28-
#error Unknown target framework!
29-
#endif
30-
}
31-
3218
public string TargetFramework
3319
{
3420
get =>
3521
#if NET8_0
3622
"net8.0";
37-
#elif NET9_0
38-
"net9.0";
3923
#elif NET10_0
4024
"net10.0";
4125
#elif NETFRAMEWORK
4226
"net472";
4327
#else
44-
#error Unknown target framework!
28+
#error Unknown target framework!
4529
#endif
4630
}
4731

@@ -85,10 +69,29 @@ private void WriteGlobalJson()
8569
Path.Combine(TestRootPath, "global.json"),
8670
$@"{{
8771
""sdk"": {{
88-
""version"": ""{DotNetSdkVersion}"",
72+
""version"": ""{GetDotNetSdkVersionString()}"",
8973
""rollForward"": ""latestMinor""
9074
}}
9175
}}");
76+
string GetDotNetSdkVersionString()
77+
{
78+
#if NET8_0
79+
return "8.0.100";
80+
#elif NET10_0
81+
return "10.0.100";
82+
#elif NETFRAMEWORK
83+
System.Diagnostics.FileVersionInfo fileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(MSBuildAssemblyResolver.MSBuildExePath);
84+
85+
return fileVersionInfo.FileMajorPart switch
86+
{
87+
17 => "8.0.100",
88+
18 => "10.0.100",
89+
_ => throw new InvalidOperationException($"Unexpected MSBuild version: {fileVersionInfo.FileMajorPart}"),
90+
};
91+
#else
92+
#error Unknown target framework!
93+
#endif
94+
}
9295
}
9396
}
9497
}

‎src/Microsoft.Build.Utilities.ProjectCreation.UnitTests/xunit.runner.json‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎src/Microsoft.Build.Utilities.ProjectCreation/BuildEventArgsCollection.cs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public abstract class BuildEventArgsCollection : IDisposable
4444
private string? _lastConsoleOutput = null;
4545

4646
/// <summary>
47-
/// Stores the <see cref="LoggerVerbosity" /> of the last console output.
47+
/// Stores the parameters used to generate the last console output for cache invalidation.
4848
/// </summary>
49-
private LoggerVerbosity _lastVerbosity = LoggerVerbosity.Normal;
49+
private (LoggerVerbosity Verbosity, bool ShowSummary, bool PerformanceSummary, bool ErrorsOnly, bool WarningsOnly, bool ShowItemAndPropertyList, bool ShowCommandLine, bool ShowTimestamp, bool ShowEventId) _lastConsoleLogParameters;
5050

5151
/// <summary>
5252
/// Initializes a new instance of the <see cref="BuildEventArgsCollection" /> class.
@@ -120,12 +120,14 @@ public virtual void Dispose()
120120
/// <returns>The build output in the format of a console log.</returns>
121121
public string GetConsoleLog(LoggerVerbosity verbosity = LoggerVerbosity.Normal, bool showSummary = true, bool performanceSummary = false, bool errorsOnly = false, bool warningsOnly = false, bool showItemAndPropertyList = true, bool showCommandLine = false, bool showTimestamp = false, bool showEventId = false)
122122
{
123-
if (_lastConsoleOutput != null && verbosity == _lastVerbosity)
123+
var currentParameters = (verbosity, showSummary, performanceSummary, errorsOnly, warningsOnly, showItemAndPropertyList, showCommandLine, showTimestamp, showEventId);
124+
125+
if (_lastConsoleOutput != null && currentParameters == _lastConsoleLogParameters)
124126
{
125127
return _lastConsoleOutput;
126128
}
127129

128-
_lastVerbosity = verbosity;
130+
_lastConsoleLogParameters = currentParameters;
129131

130132
_lastConsoleOutput = ConsoleLoggerStringBuilder.GetConsoleLogAsString(AllEvents, verbosity, showSummary, performanceSummary, errorsOnly, warningsOnly, showItemAndPropertyList, showCommandLine, showTimestamp, showEventId);
131133

‎src/Microsoft.Build.Utilities.ProjectCreation/BuildHost.cs‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -165,17 +165,7 @@ private static bool BuildProjectFromFullPath(
165165
throw buildResult.Exception;
166166
}
167167

168-
if (targetOutputs != null)
169-
{
170-
foreach (KeyValuePair<string, TargetResult> targetResult in buildResult.ResultsByTarget)
171-
{
172-
targetOutputs[targetResult.Key] = targetResult.Value;
173-
}
174-
}
175-
else
176-
{
177-
targetOutputs = buildResult.ResultsByTarget;
178-
}
168+
targetOutputs = buildResult.ResultsByTarget;
179169

180170
return buildResult.OverallResult == BuildResultCode.Success;
181171

0 commit comments

Comments
 (0)