Skip to content

Treat OpenHarmony as Unix-like in MSBuild - #15342

Merged
JanProvaznik merged 2 commits into
dotnet:mainfrom
springmin:pr/msbuild-openharmony-unixlike
Oct 26, 2026
Merged

JanProvaznik merged 2 commits into
dotnet:mainfrom
springmin:pr/msbuild-openharmony-unixlike

Conversation

@springmin

@springmin springmin commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

MSBuild's NativeMethodsShared.IsUnixLike only checks Linux, macOS, BSD, and
Haiku. On OpenHarmony, RuntimeInformation.IsOSPlatform(OSPlatform.Linux) is
false (OSPlatformName is OPENHARMONY), so Exec writes Windows-style
.exec.cmd scripts and the NativeAOT linker probe fails with "linker not
found" even though clang++ is on PATH.

Add an IsOpenHarmony check using OSPlatform.Create("OPENHARMONY") to the
Unix-like set.

This is the correct layer: dotnet/runtime#136211 was closed because
OperatingSystem.IsOSPlatform(OSPlatform.Linux) should not return true for
OpenHarmony (Android follows the same rule).

Test

  • CI: 14 passed, 0 failed, 7 skipped.

  • No unit test: IsUnixLike is a platform predicate, and the existing
    NativeMethodsShared tests only run on Linux and Windows.

  • Device (OpenHarmony 7.0.0.111, arm64): with this MSBuild build,
    dotnet publish -r openharmony-arm64 -p:PublishAot=true completes, and the
    produced NativeAOT executable runs on the device (rc=0):

    RuntimeIdentifier: openharmony-arm64
    OSDescription: HarmonyOS HongMeng Kernel 1.13.0 ...
    IsOSPlatform(Linux): True
    IsOSPlatform(OpenHarmony): True
    
  • The current runtime reports both Linux and OPENHARMONY, so it already
    takes the Unix path through IsLinux; the new predicate covers runtimes
    that report only OPENHARMONY.

Note

This PR was drafted with AI assistance (agent tooling) under the author's direction.

NativeMethodsShared.IsUnixLike only checks Linux/macOS/BSD/Haiku. On OpenHarmony OSPlatformName is OPENHARMONY, so Exec writes Windows-style .exec.cmd scripts and the NativeAOT linker probe fails. Add IsOpenHarmony via OSPlatform.Create("OPENHARMONY").
@springmin
springmin marked this pull request as ready for review October 22, 2026 15:01
@JanProvaznik

Copy link
Copy Markdown
Member

note: msbuild is not supported on OpenHarmony, but I see no reason not to make the community build work here

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.

2 participants