diff --git a/sources/assets/Stride.Core.Assets/PackageSessionPublicHelper.cs b/sources/assets/Stride.Core.Assets/PackageSessionPublicHelper.cs index 26990490ec..8b8bff382f 100644 --- a/sources/assets/Stride.Core.Assets/PackageSessionPublicHelper.cs +++ b/sources/assets/Stride.Core.Assets/PackageSessionPublicHelper.cs @@ -16,6 +16,12 @@ namespace Stride.Core.Assets /// public static class PackageSessionPublicHelper { + + /// + /// The current major .NET version that Stride will use. + /// + public static int NetMajorVersion => Environment.Version.Major; + private static readonly string[] s_msBuildAssemblies = { "Microsoft.Build", @@ -38,13 +44,13 @@ public static void FindAndSetMSBuildVersion() // Detect either .NET Core SDK or Visual Studio depending on current runtime var isNETCore = !RuntimeInformation.FrameworkDescription.StartsWith(".NET Framework", StringComparison.Ordinal); MSBuildInstance = MSBuildLocator.QueryVisualStudioInstances().FirstOrDefault(x => isNETCore - ? x.DiscoveryType == DiscoveryType.DotNetSdk && x.Version.Major == 8 + ? x.DiscoveryType == DiscoveryType.DotNetSdk && x.Version.Major == NetMajorVersion : (x.DiscoveryType == DiscoveryType.VisualStudioSetup || x.DiscoveryType == DiscoveryType.DeveloperConsole) && x.Version.Major >= 16); if (MSBuildInstance == null) { throw new InvalidOperationException("Could not find a MSBuild installation (expected 16.0 or later) " + - "Please ensure you have the .NET 8 SDK installed from Microsoft's website"); + $"Please ensure you have the .NET {NetMajorVersion} SDK installed from Microsoft's website"); } // Make sure it is not already loaded (otherwise MSBuildLocator.RegisterDefaults() throws an exception) diff --git a/sources/editor/Stride.GameStudio/Program.cs b/sources/editor/Stride.GameStudio/Program.cs index dcf28c06e5..6f82d46547 100644 --- a/sources/editor/Stride.GameStudio/Program.cs +++ b/sources/editor/Stride.GameStudio/Program.cs @@ -224,7 +224,7 @@ private static async void Startup(UFile initialSessionPath) { var message = "Could not find a compatible version of MSBuild.\r\n\r\n" + "Check that you have a valid installation with the required workloads, or go to [www.visualstudio.com/downloads](https://www.visualstudio.com/downloads) to install a new one.\r\n" + - "Also make sure you have the latest [.NET 6 SDK](https://dotnet.microsoft.com/) \r\n\r\n" + + $"Also make sure you have the latest [.NET {PackageSessionPublicHelper.NetMajorVersion} SDK](https://dotnet.microsoft.com/) \r\n\r\n" + e; await serviceProvider.Get().MessageBoxAsync(message, Core.Presentation.Services.MessageBoxButton.OK, Core.Presentation.Services.MessageBoxImage.Error); app.Shutdown();