Skip to content

Conversation

evgTSV
Copy link
Contributor

@evgTSV evgTSV commented Oct 1, 2025

Closes #840

Unfortunately, I haven't found ready-made solutions that are compatible with netstandard 2.0 and SDK project.

It perfectly works with Linux systems (tested on WSL and github runners). But the LStat function return -1 on MacOS for dotnet file, for directories it works.

Here are logs for MacOS:

[stdout]: MSBuild version 17.14.21+8929ca9e3 for .NET
  11:25:43 [DBG]  [stdout]:   Determining projects to restore...
  11:25:43 [DBG]  [stdout]:   Restored /var/folders/q0/wmf37v850txck86cpnvwm_zw0000gn/T/otavwa4j.mhn/SimpleNetfxLibrary/SimpleNetfxLibrary.ceproj (in 2.06 sec).
  11:25:43 [DBG]  [stdout]:   Determining projects to restore...
  11:25:43 [DBG]  [stdout]:   All projects are up-to-date for restore.
  11:25:43 [DBG]  [stdout]: Loading file: /private/var/folders/q0/wmf37v850txck86cpnvwm_zw0000gn/T/otavwa4j.mhn/SimpleNetfxLibrary/dotnet
  11:25:43 [DBG]  [stdout]: LStat returned -1
  11:25:43 [DBG]  [stdout]: UnixFileInfo has thrown: lstat failed for /private/var/folders/q0/wmf37v850txck86cpnvwm_zw0000gn/T/otavwa4j.mhn/SimpleNetfxLibrary/dotnet with error 0
  11:25:43 [DBG]  [stdout]: Loading file: /Users/runner/.dotnet
  11:25:43 [DBG]  [stdout]: LStat returned 0
  11:25:43 [DBG]  [stdout]: File type: 16384
  11:25:43 [DBG]  [stdout]: File: OtherExecute, OtherRead, GroupExecute, GroupRead, UserExecute, UserWrite, UserRead (493) IsDir: True

@ForNeVeR ForNeVeR self-requested a review October 1, 2025 13:55
@ForNeVeR ForNeVeR self-assigned this Oct 1, 2025
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

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

Thanks! I believe this is a step in the right direction.


internal static class FileInterop
{
internal const string SystemNative = "libSystem.Native";
Copy link
Owner

Choose a reason for hiding this comment

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

I am concerned with the use of this library. As it looks to me, it's some undocumented implementation detail of the .NET runtime, right? Can we rely on libc instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course, but we need processing Stat call manually. In runtime source I've found how I need to impl this. I try to impl this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@evgTSV
Copy link
Contributor Author

evgTSV commented Oct 2, 2025

Okay, It sill dosen't work with MacOS. It works with only directories, on files it crashes. Maybe is error in the tests or in invalid path?

@evgTSV
Copy link
Contributor Author

evgTSV commented Oct 2, 2025

That is works with File.GetUnixFileMode()

@ForNeVeR ForNeVeR self-requested a review October 2, 2025 20:06
@evgTSV evgTSV force-pushed the unix-file branch 2 times, most recently from 3ab8ccb to db9393b Compare October 5, 2025 10:14
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@ForNeVeR ForNeVeR merged commit ea975cf into ForNeVeR:main Oct 9, 2025
8 checks passed
@evgTSV evgTSV deleted the unix-file branch October 10, 2025 05:29
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.

SDK: check for executable file on Unix

2 participants