Skip to content

Commit

Permalink
Catalyst nuget package .NET changes only (#20424)
Browse files Browse the repository at this point in the history
### Description
<!-- Describe your changes. -->

#20418

Add back Catalyst changes only for now.

### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->

Co-authored-by: rachguo <[email protected]>
  • Loading branch information
YUNQIUGUO and rachguo authored Apr 29, 2024
1 parent 99b0e19 commit 8c31f27
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<PropertyGroup Condition="('$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime' OR
'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Azure') AND
'$(IncludeMobileTargets)' == 'true'">
<MobileTargets>$(MobileTargets);net6.0-android;net6.0-ios</MobileTargets>
<MobileTargets>$(MobileTargets);net6.0-android;net6.0-ios;net6.0-maccatalyst</MobileTargets>
</PropertyGroup>

<PropertyGroup Condition="'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Training' AND
Expand Down Expand Up @@ -121,9 +121,9 @@
<IsAndroidTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' OR
$(TargetFramework.StartsWith('monoandroid'))">true</IsAndroidTarget>
<IsIOSTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' OR
$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' OR
$(TargetFramework.StartsWith('xamarinios'))">true</IsIOSTarget>
<IsMacTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos' OR
$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">true</IsMacTarget>
<IsMacTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos'">true</IsMacTarget>
</PropertyGroup>

<!-- Enable training APIs for the build. The native package must be
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Notes for maccatalyst .NET targets:

We only add a blank file for the target framework folder here and thus will be including blank TFM under build/ and buildTransitive/ in the Nuget package. The reason is for Mac Catalyst platform, it directly will resolve the xcframework from the runtimes/native/ios folder based on this [RuntimeidentifierGraph](https://github.com/dotnet/sdk/blob/main/src/Layout/redist/PortableRuntimeIdentifierGraph.json#L300-L304)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ stages:
inputs:
targetType: 'inline'
script: |
dotnet workload install android ios
dotnet workload install android ios maccatalyst
workingDirectory: '$(Build.SourcesDirectory)\csharp'

- task: MSBuild@1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ stages:
inputs:
targetType: 'inline'
script: |
dotnet workload install android ios
dotnet workload install android ios maccatalyst
workingDirectory: '$(Build.SourcesDirectory)\csharp'

- task: MSBuild@1
Expand Down
28 changes: 28 additions & 0 deletions tools/nuget/generate_nuspec_for_native_nuget.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,10 @@ def generate_dependencies(xml_text, package_name, version):
xml_text.append('<group targetFramework="net6.0-macos12.3">')
xml_text.append('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
xml_text.append("</group>")
# Support net6.0-maccatalyst
xml_text.append('<group targetFramework="net6.0-maccatalyst14.0">')
xml_text.append('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
xml_text.append("</group>")
# Support Native C++
if include_dml:
xml_text.append('<group targetFramework="native">')
Expand Down Expand Up @@ -989,6 +993,20 @@ def generate_files(line_list, args):
args.package_name + ".targets",
)

net6_maccatalyst_source_targets = os.path.join(
args.sources_path,
"csharp",
"src",
"Microsoft.ML.OnnxRuntime",
"targets",
"net6.0-maccatalyst",
"_._",
)

net6_maccatalyst_target_targets = os.path.join(
args.sources_path, "csharp", "src", "Microsoft.ML.OnnxRuntime", "targets", "net6.0-maccatalyst", "_._"
)

net6_macos_source_targets = os.path.join(
args.sources_path, "csharp", "src", "Microsoft.ML.OnnxRuntime", "targets", "net6.0-macos", "targets.xml"
)
Expand All @@ -1006,6 +1024,7 @@ def generate_files(line_list, args):
os.system(copy_command + " " + xamarinios_source_targets + " " + xamarinios_target_targets)
os.system(copy_command + " " + net6_android_source_targets + " " + net6_android_target_targets)
os.system(copy_command + " " + net6_ios_source_targets + " " + net6_ios_target_targets)
os.system(copy_command + " " + net6_maccatalyst_source_targets + " " + net6_maccatalyst_target_targets)
os.system(copy_command + " " + net6_macos_source_targets + " " + net6_macos_target_targets)

files_list.append("<file src=" + '"' + monoandroid_target_targets + '" target="build\\monoandroid11.0" />')
Expand All @@ -1029,6 +1048,15 @@ def generate_files(line_list, args):
files_list.append(
"<file src=" + '"' + net6_ios_target_targets + '" target="buildTransitive\\net6.0-ios15.4" />'
)
files_list.append(
"<file src=" + '"' + net6_maccatalyst_target_targets + '" target="build\\net6.0-maccatalyst14.0" />'
)
files_list.append(
"<file src="
+ '"'
+ net6_maccatalyst_target_targets
+ '" target="buildTransitive\\net6.0-maccatalyst14.0" />'
)

files_list.append("<file src=" + '"' + net6_macos_target_targets + '" target="build\\net6.0-macos12.3" />')
files_list.append(
Expand Down

0 comments on commit 8c31f27

Please sign in to comment.