Skip to content

Commit

Permalink
Add .NET 9 support (#544)
Browse files Browse the repository at this point in the history
  • Loading branch information
RussKie authored Nov 2, 2023
1 parent 33a1d95 commit 90fdaa5
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 9 deletions.
5 changes: 3 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<Project>
<PropertyGroup>
<BaseArtifactsPath>$(MSBuildThisFileDirectory)artifacts</BaseArtifactsPath>
<DefaultItemExcludes>*log</DefaultItemExcludes>
Expand All @@ -9,7 +9,8 @@
<NoWarn>$(NoWarn);SA0001;SA1515;SA1005;SA1629;NETSDK1192</NoWarn>
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<ContinuousIntegrationBuild Condition="'$(TF_BUILD)' == 'true'">true</ContinuousIntegrationBuild>
<TargetDotNet8 Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</TargetDotNet8>
<NoWarn>$(NoWarn);NETSDK1213</NoWarn>
<TargetDotNet8 Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</TargetDotNet8>
<TargetDotNet9 Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</TargetDotNet9>
</PropertyGroup>
</Project>
8 changes: 8 additions & 0 deletions azure-pipelines-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ variables:
DotNet6Version: '6.x'
DotNet7Version: '7.x'
DotNet8Version: '8.x'
DotNet9Version: '9.x'
# Not using "--channel 9.0 --quality daily", see https://github.com/microsoft/slngen/issues/456
DotNet9InstallArgs: '-version 9.0.100-alpha.1.23528.2'
MSBuildArgs: '"/Property:Platform=$(BuildPlatform);Configuration=$(BuildConfiguration)" "/BinaryLogger:$(Build.SourcesDirectory)\$(ArtifactsDirectoryName)\msbuild.binlog"'
SignType: 'Test'

Expand Down Expand Up @@ -50,6 +53,11 @@ stages:
version: '$(DotNet8Version)'
includePreviewVersions: true

- script: |
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) $(DotNet9InstallArgs) -InstallDir D:\a\_work\_tool\dotnet"
dotnet --info
displayName: 'Install .NET $(DotNet9Version)'
- task: MicroBuildSigningPlugin@1
displayName: 'Install MicroBuild Signing Plugin'
inputs:
Expand Down
29 changes: 29 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ variables:
DotNet6Version: '6.x'
DotNet7Version: '7.x'
DotNet8Version: '8.x'
DotNet9Version: '9.x'
# Not using "--channel 9.0 --quality daily", see https://github.com/microsoft/slngen/issues/456
DotNet9InstallArgs: '-version 9.0.100-alpha.1.23528.2'
MSBuildArgs: '"/Property:Platform=$(BuildPlatform);Configuration=$(BuildConfiguration)"'
SignType: 'Test'

Expand Down Expand Up @@ -62,6 +65,24 @@ jobs:
version: '$(DotNet8Version)'
includePreviewVersions: true

- script: |
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) $(DotNet9InstallArgs) -InstallDir C:\hostedtoolcache\windows\dotnet"
dotnet --info
displayName: 'Install .NET $(DotNet9Version) (Windows)'
condition: eq(variables.osName, 'Windows')
- script: |
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin $(DotNet9InstallArgs) --install-dir /opt/hostedtoolcache/dotnet
dotnet --info
displayName: 'Install .NET $(DotNet9Version) (Linux)'
condition: eq(variables.osName, 'Linux')
- script: |
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin $(DotNet9InstallArgs) --install-dir /Users/runner/hostedtoolcache/dotnet
dotnet --info
displayName: 'Install .NET $(DotNet9Version) (MacOS)'
condition: eq(variables.osName, 'MacOS')
- task: VSBuild@1
displayName: 'Build (Visual Studio)'
inputs:
Expand Down Expand Up @@ -107,6 +128,14 @@ jobs:
testRunTitle: '$(osName) .NET 8.0'
condition: succeededOrFailed()

- task: DotNetCoreCLI@2
displayName: 'Run Unit Tests (.NET 9)'
inputs:
command: 'test'
arguments: '--no-restore --no-build --framework net9.0 /noautorsp $(MSBuildArgs) "/BinaryLogger:$(ArtifactsDirectoryName)/test-net9.0.binlog"'
testRunTitle: '$(osName) .NET 9.0'
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<RollForward>LatestMajor</RollForward>
<_GetChildProjectCopyToPublishDirectoryItems>false</_GetChildProjectCopyToPublishDirectoryItems>
<TargetDotNet8 Condition="'$(TargetDotNet8)' == '' And $([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '8.0'))">true</TargetDotNet8>
<TargetDotNet9 Condition="'$(TargetDotNet9)' == '' And $([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '9.0'))">true</TargetDotNet9>
</PropertyGroup>
<Import Project="..\Shared\Shared.props" />
<ItemGroup>
Expand Down Expand Up @@ -56,6 +57,15 @@
SkipGetTargetFrameworkProperties="true"
TargetFramework="net8.0"
Condition="'$(TargetDotNet8)' == 'true'" />
<ProjectReference Include="..\Microsoft.VisualStudio.SlnGen\Microsoft.VisualStudio.SlnGen.csproj"
SetTargetFramework="TargetFramework=net9.0"
IncludeAssets="None"
OutputItemType="SlnGenBuildOutput"
PrivateAssets="All"
ReferenceOutputAssembly="false"
SkipGetTargetFrameworkProperties="true"
TargetFramework="net9.0"
Condition="'$(TargetDotNet9)' == 'true'" />
</ItemGroup>
<Target Name="CopySlnGenToOutputDirectoryAndPackage"
AfterTargets="PrepareForRun"
Expand Down
6 changes: 4 additions & 2 deletions src/Microsoft.VisualStudio.SlnGen.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ public static int Main(string[] args)
break;

case "8":
// TEMP: hack until .NET 8 is shipped and/or .NET 9 SDK is coherent
case "9":
framework = "net8.0";
break;

case "9":
framework = "net9.0";
break;

default:
Utility.WriteError(Error, "SlnGen does not currently support the .NET SDK {0} defined by in global.json. Please update to the latest version and if you still get this error message, file an issue at https://github.com/microsoft/slngen/issues/new so it can be added.", developmentEnvironment.DotNetSdkVersion);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetDotNet8 Condition="'$(TargetDotNet8)' == '' And $([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '8.0'))">true</TargetDotNet8>
<TargetDotNet9 Condition="'$(TargetDotNet9)' == '' And $([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '9.0'))">true</TargetDotNet9>
<TargetFrameworks>net472;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetDotNet8)' == 'true'">$(TargetFrameworks);net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetDotNet9)' == 'true'">$(TargetFrameworks);net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);SA1600</NoWarn>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.VisualStudio.SlnGen.UnitTests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public abstract class TestBase : MSBuildTestBase
"7.0.0";
#elif NET8_0
"8.0.0";
#elif NET9_0
"9.0.0";
#else
Unknown target framework
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetDotNet8 Condition="'$(TargetDotNet8)' == '' And $([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '8.0'))">true</TargetDotNet8>
<TargetDotNet9 Condition="'$(TargetDotNet9)' == '' And $([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '9.0'))">true</TargetDotNet9>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;net472;net6.0;net7.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetDotNet8)' == 'true'">$(TargetFrameworks);net8.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetDotNet9)' == 'true'">$(TargetFrameworks);net9.0</TargetFrameworks>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.config</AllowedOutputExtensionsInPackageBuildOutputFolder>
<IncludeReferenceCopyLocalPathsInBuildOutputInPackage>true</IncludeReferenceCopyLocalPathsInBuildOutputInPackage>
<IsTool>true</IsTool>
Expand Down Expand Up @@ -31,7 +33,7 @@
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net46\MSBuild.exe" Private="false" Condition="'$(TargetFramework)' == 'net461'" />
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net472\MSBuild.exe" Private="false" Condition="'$(TargetFramework)' == 'net472'" />
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net6.0\MSBuild.dll" Private="false" Condition="'$(TargetFramework)' == 'net6.0'" />
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net7.0\MSBuild.dll" Private="false" Condition="'$(TargetFramework)' == 'net7.0' Or '$(TargetFramework)' == 'net8.0'" />
<Reference Include="$(PkgMicrosoft_Build_Runtime)\contentFiles\any\net7.0\MSBuild.dll" Private="false" Condition="'$(TargetFramework)' == 'net7.0' Or '$(TargetFramework)' == 'net8.0' Or '$(TargetFramework)' == 'net9.0'" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" Condition="'$(TargetFramework)' == 'net461' Or '$(TargetFramework)' == 'net472'" />
Expand All @@ -40,7 +42,7 @@
<!--
By default, this application will use the same runtime as whatever version it was built against. In reality, this application
should run against any version of the runtime with the same major version. This logic gets the major, minor, and build version
and sets RuntimeFramework.Version to the major.minor.build-any so at runtime it will work against any version of the runtime with
and sets RuntimeFramework.Version to the major.minor.build-alpha so at runtime it will work against any version of the runtime with
the same major version.
-->
<Target Name="SetRuntimeFramework" BeforeTargets="GenerateBuildRuntimeConfigurationFiles">
Expand All @@ -49,7 +51,7 @@
<_PreviousRuntimeFramework>%(RuntimeFramework.Version)</_PreviousRuntimeFramework>
</PropertyGroup>
<ItemGroup>
<RuntimeFramework Update="@(RuntimeFramework)" Version="$(_MajorMinorBuildRuntimeFramework)-any" />
<RuntimeFramework Update="@(RuntimeFramework)" Version="$(_MajorMinorBuildRuntimeFramework)-alpha" />
</ItemGroup>
</Target>
<Target Name="RestoreRuntimeFramework" AfterTargets="GenerateBuildRuntimeConfigurationFiles">
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "11.0",
"version": "11.1",
"assemblyVersion": "3.0",
"buildNumberOffset": -1,
"publicReleaseRefSpec": [
Expand Down

0 comments on commit 90fdaa5

Please sign in to comment.