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: PublishSingleFile Launch Crash #2225

Merged
merged 1 commit into from
Apr 23, 2024

Conversation

MeharDT
Copy link
Contributor

@MeharDT MeharDT commented Apr 9, 2024

PR Details

Stride applications built for Windows will crash when PublishSingleFile is set to true.

Description

When a Stride application is launched, Assembly.Location is used to find the executable directory and create cache folders. This returns a null value when PublishSingleFile is true. It is instead recommended to use AppContext.BaseDirectory to check for the executable directory.

Additional Info: https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/warnings/il3000

Related Issue

#2204

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.
  • I have built and run the editor to try this change out.

- Fix for Windows executable launch crash when game is published with PublishSingleFile set to true
@Doprez
Copy link
Contributor

Doprez commented Apr 9, 2024

Might be able to also close #1947 with this fix.

@MeharDT
Copy link
Contributor Author

MeharDT commented Apr 9, 2024

Might be able to also close #1947 with this fix.

That's a good idea, inline with that the docs should also be updated at some point to include PublishSingleFile instructions.

https://doc.stride3d.net/latest/en/manual/files-and-folders/distribute-a-game.html

@Kryptos-FR Kryptos-FR self-requested a review April 11, 2024 07:55
@@ -186,6 +186,8 @@ private static string GetApplicationBinaryDirectory()
{
#if STRIDE_PLATFORM_ANDROID
return GetApplicationExecutableDirectory();
#elif STRIDE_PLATFORM_DESKTOP
return Path.GetDirectoryName(AppContext.BaseDirectory);
Copy link
Member

Choose a reason for hiding this comment

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

Is this a correct path if not published as single file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe so. My tests included both single file and non single file published builds, all launched without issue.

@Eideren Eideren changed the title Fix for PublishSingleFile Launch Crash fix: PublishSingleFile Launch Crash Apr 23, 2024
@Eideren Eideren merged commit f101389 into stride3d:master Apr 23, 2024
13 checks passed
@Eideren
Copy link
Collaborator

Eideren commented Apr 23, 2024

Thanks !

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

Successfully merging this pull request may close these issues.

4 participants