Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: .NET 6 reference missed #2330

Merged
merged 4 commits into from
Jun 18, 2024
Merged
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
10 changes: 8 additions & 2 deletions sources/assets/Stride.Core.Assets/PackageSessionPublicHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ namespace Stride.Core.Assets
/// </summary>
public static class PackageSessionPublicHelper
{

/// <summary>
/// The current major .NET version that Stride will use.
/// </summary>
public static int NetMajorVersion => Environment.Version.Major;

private static readonly string[] s_msBuildAssemblies =
{
"Microsoft.Build",
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion sources/editor/Stride.GameStudio/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<IDialogService>().MessageBoxAsync(message, Core.Presentation.Services.MessageBoxButton.OK, Core.Presentation.Services.MessageBoxImage.Error);
app.Shutdown();
Expand Down