Skip to content

Commit

Permalink
Target .NET 10 (#631)
Browse files Browse the repository at this point in the history
* Target .NET 10

* fixup! Target .NET 10

* fixup! Target .NET 10

* fixup! Target .NET 10

* fixup! Target .NET 10

* Try adding dotnet10 feed

* More changes

* Update version.json

* Fix dotnet-install args

* Fix tests now that MSBuild has multiple solution parsers

* Fix tabs

* Fix tests

* fixup! Target .NET 10

---------

Co-authored-by: Jeff Kluge <[email protected]>
Co-authored-by: Meera Ruxmohan <[email protected]>
  • Loading branch information
3 people authored Nov 19, 2024
1 parent 3be83b0 commit be73770
Show file tree
Hide file tree
Showing 13 changed files with 138 additions and 47 deletions.
4 changes: 2 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 @@ -11,7 +11,7 @@
<SuppressNETCoreSdkPreviewMessage>true</SuppressNETCoreSdkPreviewMessage>
<ContinuousIntegrationBuild Condition="'$(TF_BUILD)' == 'true'">true</ContinuousIntegrationBuild>
<NoWarn>$(NoWarn);NETSDK1213</NoWarn>
<TargetDotNet9 Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</TargetDotNet9>
<TargetDotNet10 Condition="'$(ContinuousIntegrationBuild)' == 'true'">true</TargetDotNet10>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<UseArtifactsOutput>false</UseArtifactsOutput>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<MicrosoftBuildPackageVersion>17.11.4</MicrosoftBuildPackageVersion>
<MicrosoftBuildPackageVersion Condition="'$(TargetFramework)' == 'net461'">17.11.4</MicrosoftBuildPackageVersion>
<MicrosoftBuildPackageVersion>17.12.6</MicrosoftBuildPackageVersion>
<MicrosoftBuildPackageVersion Condition="'$(TargetFramework)' == 'net8.0'">17.11.4</MicrosoftBuildPackageVersion>
<SystemConfigurationConfigurationManagerPackageVersion>9.0.0</SystemConfigurationConfigurationManagerPackageVersion>
<MicrosoftExtensionsFileSystemGlobbingPackageVersion>8.0.0</MicrosoftExtensionsFileSystemGlobbingPackageVersion>
<MicrosoftExtensionsFileSystemGlobbingPackageVersion Condition="'$(TargetFramework)' == 'net472'">6.0.0</MicrosoftExtensionsFileSystemGlobbingPackageVersion>
Expand Down
16 changes: 15 additions & 1 deletion NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@
</activePackageSource>
<packageSources>
<clear />
<add key="NuGet.org" value="https://api.nuget.org/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="dotnet10" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json" />
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
</packageSources>
<packageSourceMapping>
<packageSource key="nuget.org">
<package pattern="Microsoft.*" />
<package pattern="*" />
</packageSource>
<packageSource key="dotnet10">
<package pattern="Microsoft.*" />
</packageSource>
<packageSource key="dotnet-tools">
<package pattern="Microsoft.*" />
</packageSource>
</packageSourceMapping>
</configuration>
8 changes: 8 additions & 0 deletions azure-pipelines-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ variables:
BuildPlatform: 'Any CPU'
MSBuildArgs: '"/Property:Platform=$(BuildPlatform);Configuration=$(BuildConfiguration)" "/BinaryLogger:$(Build.SourcesDirectory)\$(ArtifactsDirectory)\msbuild.binlog"'
SignType: 'Real'
# Not using "--channel 10.0 --quality daily", see https://github.com/microsoft/slngen/issues/456
DotNet10InstallArgs: '-version 10.0.100-alpha.1.24564.1'

trigger:
batch: true
branches:
Expand Down Expand Up @@ -65,6 +68,11 @@ extends:
displayName: 'Install .NET 9.x'
inputs:
version: '9.x'
- script: |
powershell -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -UseBasicParsing 'https://dot.net/v1/dotnet-install.ps1'))) $(DotNet10InstallArgs) -InstallDir D:\a\_work\_tool\dotnet"
dotnet --info
displayName: 'Install .NET 10.x'
- task: VSBuild@1
displayName: 'Build Solution'
inputs:
Expand Down
28 changes: 28 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ variables:
BuildPlatform: 'Any CPU'
MSBuildArgs: '"/Property:Platform=$(BuildPlatform);Configuration=$(BuildConfiguration)"'
SignType: 'Test'
# Not using "--channel 10.0 --quality daily", see https://github.com/microsoft/slngen/issues/456
DotNet10InstallArgs: '-version 10.0.100-alpha.1.24564.1'

trigger:
batch: 'true'
Expand Down Expand Up @@ -53,6 +55,24 @@ jobs:
inputs:
version: '9.x'

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

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

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifacts'
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
ReferenceOutputAssembly="false"
SkipGetTargetFrameworkProperties="true"
TargetFramework="net9.0" />
<ProjectReference Include="..\Microsoft.VisualStudio.SlnGen\Microsoft.VisualStudio.SlnGen.csproj"
SetTargetFramework="TargetFramework=net10.0"
IncludeAssets="None"
OutputItemType="SlnGenBuildOutput"
PrivateAssets="All"
ReferenceOutputAssembly="false"
SkipGetTargetFrameworkProperties="true"
TargetFramework="net10.0"
Condition="'$(TargetDotNet10)' == 'true'" />
</ItemGroup>
<Target Name="CopySlnGenToOutputDirectoryAndPackage"
AfterTargets="PrepareForRun"
Expand Down
29 changes: 13 additions & 16 deletions src/Microsoft.VisualStudio.SlnGen.Tool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ private enum ExitCode
UnsupportedNETSdk = 2,
UnknownNETSdk = 3,
SlnGenNotFound = 4,
UnsupportedMSBuild = 5,
UnhandledException = -1,
}

Expand Down Expand Up @@ -81,17 +82,11 @@ public static int Main(string[] args)
{
case "3":
case "5":
Utility.WriteError(Error, "The currently configured .NET SDK {0} is not supported, SlnGen requires .NET SDK 5 or greater.", developmentEnvironment.DotNetSdkVersion);

return (int)ExitCode.UnsupportedNETSdk;

case "6":
framework = "net6.0";
break;

case "7":
framework = "net7.0";
break;
Utility.WriteError(Error, "The currently configured .NET SDK {0} is not supported, SlnGen requires .NET SDK 8 or greater.", developmentEnvironment.DotNetSdkVersion);

return (int)ExitCode.UnsupportedNETSdk;

case "8":
framework = "net8.0";
Expand All @@ -101,6 +96,10 @@ public static int Main(string[] args)
framework = "net9.0";
break;

case "10":
framework = "net10.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 All @@ -111,16 +110,14 @@ public static int Main(string[] args)
{
FileVersionInfo msBuildVersionInfo = FileVersionInfo.GetVersionInfo(developmentEnvironment.MSBuildExe.FullName);

switch (msBuildVersionInfo.FileMajorPart)
if (msBuildVersionInfo.FileMajorPart < 17)
{
case 15:
framework = "net461";
break;
Utility.WriteError(Error, "The currently configured MSBuild {0} is not supported, SlnGen requires MSBuild 17.0 or greater.", msBuildVersionInfo.FileMajorPart);

default:
framework = "net472";
break;
return (int)ExitCode.UnsupportedMSBuild;
}

framework = "net472";
}

FileInfo slnGenFileInfo = new FileInfo(Path.Combine(thisAssemblyFileInfo.DirectoryName!, "..", thisAssemblyFileInfo.DirectoryName!.EndsWith("any") ? ".." : string.Empty, "slngen", framework, useDotnet ? "slngen.dll" : "slngen.exe"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetDotNet10)' == 'true'">$(TargetFrameworks);net10.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<NoWarn>$(NoWarn);SA1600</NoWarn>
</PropertyGroup>
Expand Down
Loading

0 comments on commit be73770

Please sign in to comment.