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

Check to see if the .NET 6.0 SDK is Installed When Launching Stride #1809

Merged
merged 4 commits into from
Sep 23, 2023

Conversation

MeharDT
Copy link
Contributor

@MeharDT MeharDT commented Sep 20, 2023

PR Details

Stride 4.1 requires the .NET 6.0 SDK. The existing FindAndSetMSBuildVersion() method can be bypassed if an older version of the SDK is installed (i.e., 5.0) because the method is checking for .NET Core 3 or above.

After bypassing this prerequisite check, Stride will function normally until the user attempts to build their project.

Description

The x.Version.Major requirement was raised in Stride.Core.Assets\PackageSessionPublicHelper.cs, the check is performed when the user opens Stride 4.1.x. If the SDK is missing the user is prompted to install it, the detected SDK version is provided to help with troubleshooting.

Related Issue

Prompted by discussion in issue #1753

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

- Check to see if the required .NET SDK is installed for Stride 4.1, otherwise the engine can be launched with an incompatible SDK (i.e., .NET 5)
@Eideren
Copy link
Collaborator

Eideren commented Sep 21, 2023

Given the fact that we'll be upgrading to .Net 8 shortly, we'll have to remember to change this scope as well. How about we future proof it. Checking for an available SDK of the .net version the game studio is built in instead of net6 explicitly ?

@MeharDT
Copy link
Contributor Author

MeharDT commented Sep 21, 2023

That's a good idea! Is there a way to programmatically check which version of .net an application was built with?

@Eideren
Copy link
Collaborator

Eideren commented Sep 21, 2023

Well, I thought that your RuntimeInformation.FrameworkDescription did, but that seems to only report the version of the runtime, not SDK. So I'm not sure that this PR would even work if the user had an older SDK, or no SDK. Just having the runtime installed is enough to bypass the check afaict.

@MeharDT
Copy link
Contributor Author

MeharDT commented Sep 21, 2023

Hmm, the .NET SDK now includes the Runtime so that shouldn't be an issue moving forward, but I wasn't thinking of the Runtime as a standalone install. I guess we need some additional checks. 🤔

@MeharDT
Copy link
Contributor Author

MeharDT commented Sep 21, 2023

I was thinking FindAndSetMSBuildVersion() is deprecated now that only the .NET SDK is supported but we can simply raise x.Version.Major value here for a similar result,

? x.DiscoveryType == DiscoveryType.DotNetSdk && x.Version.Major >= 3

I'll update the PR if there are no objections, this method still relies on RuntimeInformation.FrameworkDescription so @Eideren's point is valid.

@Eideren
Copy link
Collaborator

Eideren commented Sep 22, 2023

So, checking that version against Environment.Version then ?

@MeharDT
Copy link
Contributor Author

MeharDT commented Sep 22, 2023

So, checking that version against Environment.Version then ?

From my tests so far I think we can leave it as is because x.Version.Major needs to be updated manually regardless. We also need an exact version match with whatever that version is.

- Reverted prior changes, raised version check number in FindAndSetMSBuildVersion
- Updated MSBuild exception message to provide additional info
@MeharDT
Copy link
Contributor Author

MeharDT commented Sep 23, 2023

Updated PR and post.

Now that the .NET SDK includes the Runtime I think this will still help many users avoid issues with out of date SDKs moving forward (and I assume x.Version.Major was meant to remain current anyway).

@@ -234,6 +234,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" +
"Detected SDK: " + RuntimeInformation.FrameworkDescription.ToString() + "\r\n\r\n" +
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still the runtime version though, not the sdk, right ? And I think it might be the runtime that the application is under, not the one installed. So if the gamestudio is self contained, which might be the case (?), this'll always report net6 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah you're right, good catch! I've removed that addition, the change in FindAndSetMSBuildVersion() still works as intended. You can test this by uninstalling the .NET 6 SDK and running a previously built version of this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gamestudio is self contained

I'm not sure that is the case. Looking at the contents of Stride.GameStudio NuGet package it is built as runtime dependent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gamestudio is self contained

I'm not sure that is the case. Looking at the contents of Stride.GameStudio NuGet package it is built as runtime dependent.

Hmm, when I tested before the final PR update the "Detected SDK" was still reporting .NET 6.0 despite the SDK/runtime being uninstalled. MSBuildLocator on the other hand did pick up that the SDK was missing.

@Eideren Eideren merged commit 8b76f2e into stride3d:master Sep 23, 2023
1 check passed
@Eideren
Copy link
Collaborator

Eideren commented Sep 23, 2023

Thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants