Revert "Nuget .NET changes for Mac Catalyst (#19923)" (#20418)

This reverts commit f396748ed6.

### Description
<!-- Describe your changes. -->



### 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. -->
This commit is contained in:
Yi Zhang 2024-04-23 15:08:12 +08:00 committed by GitHub
parent e6a677f6b7
commit 7ebc653f04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 75 additions and 113 deletions

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

View file

@ -14,7 +14,7 @@
"disableDefaultFilter": false,
"properties": {
"AllowUnsafeBlocks": true,
"TargetFramework" : "net7.0",
"TargetFramework" : "net6.0",
"Nullable" : "enable",
"LangVersion": "8.0",
"EnableTrainingApis": "true"

View file

@ -101,8 +101,8 @@ For example, to build a CUDA GPU package, just run:
--cudnn_home=/usr \
--build_nuget \
--msbuild_extra_options \
/p:SelectedTargets=Net7 \
/p:Net6Targets=net7.0 \
/p:SelectedTargets=Net6 \
/p:Net6Targets=net6.0 \
/p:TargetFrameworks=netstandard2.0 \
/p:IsLinuxBuild=true
```

View file

@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- note net7.0-maccatalyst is not supported currently. requires a new native build to be added. -->
<TargetFrameworks>net7.0-android;net7.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- note net6.0-maccatalyst is not supported currently. requires a new native build to be added. -->
<TargetFrameworks>net6.0-android;net6.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>Microsoft.ML.OnnxRuntime.InferenceSample.Maui</RootNamespace>
<UseMaui>true</UseMaui>
@ -36,7 +36,7 @@
</PropertyGroup>
<ItemGroup>
<!-- NOTE:
<!-- NOTE:
You need to manually put builds from other platforms such as Android in the correct place for this to work for cross-platform
builds such as running in the Android simulator.
The 'correct' place is defined by the OnnxRuntimeBuildDirectory property in Microsoft.ML.OnnxRuntime.csproj

View file

@ -6,7 +6,7 @@
<PropertyGroup>
<IncludeMobileTargets>true</IncludeMobileTargets>
<BaseTargets>netstandard2.0;netcoreapp3.1;net7.0</BaseTargets>
<BaseTargets>netstandard2.0;netcoreapp3.1;net6.0</BaseTargets>
<MobileTargets></MobileTargets>
</PropertyGroup>
@ -39,12 +39,12 @@
<PropertyGroup Condition="('$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime' OR
'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Azure') AND
'$(IncludeMobileTargets)' == 'true'">
<MobileTargets>$(MobileTargets);net7.0-android;net7.0-ios;net7.0-maccatalyst</MobileTargets>
<MobileTargets>$(MobileTargets);net6.0-android;net6.0-ios</MobileTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Training' AND
'$(IncludeMobileTargets)' == 'true'">
<MobileTargets>$(MobileTargets);net7.0-android</MobileTargets>
<MobileTargets>$(MobileTargets);net6.0-android</MobileTargets>
</PropertyGroup>
<PropertyGroup>
@ -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'">true</IsMacTarget>
<IsMacTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos' OR
$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">true</IsMacTarget>
</PropertyGroup>
<!-- Enable training APIs for the build. The native package must be
@ -175,7 +175,7 @@
</PropertyGroup>
<!-- CoreML may be valid for one of these targets as they support macOS. we do a runtime check that the OS is
macOS before attempting to enable CoreML. This includes netcoreapp3.1 and net7.0
macOS before attempting to enable CoreML. This includes netcoreapp3.1 and net6.0
NOTE: $(TargetFrameworkIdentitier) may not be set yet, so we need to call GetTargetFrameworkIdentifier
-->
<PropertyGroup Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)'))=='.NETCoreApp' AND

View file

@ -1,3 +0,0 @@
### 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)

View file

@ -15,7 +15,7 @@
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\OnnxRuntime.snk</AssemblyOriginatorKeyFile>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinuxBuild)'=='true'">

View file

@ -2,8 +2,8 @@
<PropertyGroup>
<!-- netstandard2.0 is required by xamarin and used by most platforms.
net7.0 is required for linux. -->
<TargetFrameworks>netstandard2.0;net7.0</TargetFrameworks>
net6.0 is required for linux. -->
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<OnnxRuntimeCsharpRoot>$(ProjectDir)..\..</OnnxRuntimeCsharpRoot>
<Platforms>AnyCPU</Platforms>

View file

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<OnnxRuntimeCsharpRoot>$(ProjectDir)..\..</OnnxRuntimeCsharpRoot>
<Platforms>AnyCPU;x86</Platforms>

View file

@ -594,8 +594,8 @@ stages:
- job:
workspace:
clean: all
# we need to use the 2022 pool to create the nuget package with both pre-net7+Xamarin and net7 targets.
# VS2019 has no support for net7 and we need to use msbuild (from the VS install) to do the packing
# we need to use the 2022 pool to create the nuget package with both pre-net6+Xamarin and net6 targets.
# VS2019 has no support for net6 and we need to use msbuild (from the VS install) to do the packing
pool: 'Onnxruntime-Win-CPU-2022'
variables:
breakCodesignValidationInjection: ${{ parameters.DoEsrp }}
@ -675,7 +675,7 @@ stages:
inputs:
targetType: 'inline'
script: |
dotnet workload install android ios maccatalyst
dotnet workload install android ios
workingDirectory: '$(Build.SourcesDirectory)\csharp'
- task: MSBuild@1
@ -811,8 +811,8 @@ stages:
- job:
workspace:
clean: all
# we need to use the 2022 pool to create the nuget package with both pre-net7+Xamarin and net7 targets.
# VS2019 has no support for net7 and we need to use msbuild (from the VS install) to do the packing
# we need to use the 2022 pool to create the nuget package with both pre-net6+Xamarin and net6 targets.
# VS2019 has no support for net6 and we need to use msbuild (from the VS install) to do the packing
pool: 'Onnxruntime-Win-CPU-2022'
variables:
breakCodesignValidationInjection: ${{ parameters.DoEsrp }}
@ -876,20 +876,20 @@ stages:
versionSpec: 6.2.1
- task: PowerShell@2
displayName: Build .NET 7 targets using dotnet
displayName: Build .NET 6 targets using dotnet
inputs:
targetType: 'inline'
# we don't specify 'Any CPU' as the platform here because if we do it gets added to the output path
# e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\Any CPU\RelWithDebInfo\net7.0-ios\
# which is inconsistent with the msbuild output path for the pre-.net7 targets
# e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\Any CPU\RelWithDebInfo\net6.0-ios\
# which is inconsistent with the msbuild output path for the pre-.net6 targets
# e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\RelWithDebInfo\monoandroid11.0
# and makes it harder to do the packing
#
# 'Any CPU' is the default (first 'mixed' platform specified in the csproj) so this should be fine.
script: |
dotnet build .\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj `
-p:SelectedTargets=Net7 `
/p:Net7Targets=net7.0 `
-p:SelectedTargets=Net6 `
/p:Net6Targets=net6.0 `
-p:Configuration=RelWithDebInfo `
-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)" `
-p:OrtPackageId="Microsoft.ML.OnnxRuntime.ROCm" `
@ -898,22 +898,22 @@ stages:
workingDirectory: '$(Build.SourcesDirectory)\csharp'
- task: MSBuild@1
displayName: 'Restore NuGet Packages and create project.assets.json for pre-.net7 targets'
displayName: 'Restore NuGet Packages and create project.assets.json for pre-.net6 targets'
inputs:
solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln'
platform: 'Any CPU'
configuration: RelWithDebInfo
msbuildArguments: '-t:restore -p:SelectedTargets=PreNet7 -p:OrtPackageId="Microsoft.ML.OnnxRuntime.ROCm"'
msbuildArguments: '-t:restore -p:SelectedTargets=PreNet6 -p:OrtPackageId="Microsoft.ML.OnnxRuntime.ROCm"'
workingDirectory: '$(Build.SourcesDirectory)\csharp'
- task: MSBuild@1
displayName: 'Build C# for pre-.net7 targets'
displayName: 'Build C# for pre-.net6 targets'
inputs:
solution: '$(Build.SourcesDirectory)\csharp\OnnxRuntime.CSharp.sln'
configuration: RelWithDebInfo
platform: 'Any CPU'
msbuildArguments: >
-p:SelectedTargets=PreNet7
-p:SelectedTargets=PreNet6
-p:OnnxRuntimeBuildDirectory="$(Build.BinariesDirectory)"
-p:OrtPackageId="Microsoft.ML.OnnxRuntime.ROCm"
-p:IsReleaseBuild=${{ parameters.IsReleaseBuild }}

View file

@ -262,7 +262,7 @@ stages:
pushd /onnxruntime_src/csharp; \
dotnet restore /onnxruntime_src/csharp/OnnxRuntime.DesktopOnly.CSharp.sln; \
dotnet build /onnxruntime_src/csharp/OnnxRuntime.DesktopOnly.CSharp.sln -c Release; \
dotnet test /onnxruntime_src/csharp/OnnxRuntime.DesktopOnly.CSharp.sln -c Release -f net7.0 --no-build -l \"console;verbosity=normal\"; \
dotnet test /onnxruntime_src/csharp/OnnxRuntime.DesktopOnly.CSharp.sln -c Release -f net6.0 --no-build -l \"console;verbosity=normal\"; \
popd
"
displayName: 'Dotnet build C# sln and Test'

View file

@ -98,12 +98,12 @@ stages:
workingDirectory: '$(Build.SourcesDirectory)\csharp'
- task: PowerShell@2
displayName: Build .NET 7 targets using dotnet
displayName: Build .NET 6 targets using dotnet
inputs:
targetType: 'inline'
# we don't specify 'Any CPU' as the platform here because if we do it gets added to the output path
# e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\Any CPU\RelWithDebInfo\net7.0-ios\
# which is inconsistent with the msbuild output path for the pre-.net7 targets
# e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\Any CPU\RelWithDebInfo\net6.0-ios\
# which is inconsistent with the msbuild output path for the pre-.net6 targets
# e.g. csharp\src\Microsoft.ML.OnnxRuntime\bin\RelWithDebInfo\monoandroid11.0
# and makes it harder to do the packing
#

View file

@ -409,7 +409,7 @@ stages:
inputs:
targetType: 'inline'
script: |
dotnet workload install android ios maccatalyst
dotnet workload install android ios
workingDirectory: '$(Build.SourcesDirectory)\csharp'
- task: MSBuild@1

View file

@ -96,13 +96,6 @@ jobs:
WithCache: ${{parameters.WITH_CACHE}}
Today: $(Today)
- task: UseDotNet@2
inputs:
version: '7.x'
${{ if eq(parameters.isX86, true) }}:
env:
PROCESSOR_ARCHITECTURE: 'x86'
- task: NodeTool@0
inputs:
versionSpec: '18.x'
@ -247,4 +240,4 @@ jobs:
condition: and(failed(), eq(variables['DocUpdateNeeded'], 'true'))
inputs:
pathtoPublish: '$(Build.SourcesDirectory)/docs/ContribOperators.md'
artifactName: 'ContribOperators.md'
artifactName: 'ContribOperators.md'

View file

@ -4,7 +4,7 @@ set -e -x
if [ -f /etc/redhat-release ]; then
# If you found the following command went successfully but dotnet command still reports no sdk was found, most likely
# it was because the dotnet packages were installed from more than one dnf repos.
dnf install -y dotnet-sdk-7.0 dotnet-runtime-7.0
dnf install -y dotnet-sdk-6.0 dotnet-runtime-6.0
elif [ -f /etc/os-release ]; then
# Get Ubuntu version
declare repo_version
@ -16,7 +16,7 @@ elif [ -f /etc/os-release ]; then
# Clean up
rm packages-microsoft-prod.deb
# Update packages
apt-get update && apt-get install -y dotnet-sdk-7.0
apt-get update && apt-get install -y dotnet-sdk-6.0
else
echo "Unsupported OS"
exit 1

View file

@ -268,20 +268,16 @@ def generate_dependencies(xml_text, package_name, version):
xml_text.append('<group targetFramework="xamarinios10">')
xml_text.append('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
xml_text.append("</group>")
# Support net7.0-android
xml_text.append('<group targetFramework="net7.0-android31.0">')
# Support net6.0-android
xml_text.append('<group targetFramework="net6.0-android31.0">')
xml_text.append('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
xml_text.append("</group>")
# Support net7.0-ios
xml_text.append('<group targetFramework="net7.0-ios15.4">')
# Support net6.0-ios
xml_text.append('<group targetFramework="net6.0-ios15.4">')
xml_text.append('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
xml_text.append("</group>")
# Support net7.0-macos
xml_text.append('<group targetFramework="net7.0-macos12.3">')
xml_text.append('<dependency id="Microsoft.ML.OnnxRuntime.Managed"' + ' version="' + version + '"/>')
xml_text.append("</group>")
# Support net7.0-maccatalyst
xml_text.append('<group targetFramework="net7.0-maccatalyst14.0">')
# Support net6.0-macos
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 Native C++
@ -961,70 +957,56 @@ def generate_files(line_list, args):
args.package_name + ".targets",
)
net7_android_source_targets = os.path.join(
net6_android_source_targets = os.path.join(
args.sources_path,
"csharp",
"src",
"Microsoft.ML.OnnxRuntime",
"targets",
"net7.0-android",
"net6.0-android",
"targets.xml",
)
net7_android_target_targets = os.path.join(
net6_android_target_targets = os.path.join(
args.sources_path,
"csharp",
"src",
"Microsoft.ML.OnnxRuntime",
"targets",
"net7.0-android",
"net6.0-android",
args.package_name + ".targets",
)
net7_ios_source_targets = os.path.join(
args.sources_path, "csharp", "src", "Microsoft.ML.OnnxRuntime", "targets", "net7.0-ios", "targets.xml"
net6_ios_source_targets = os.path.join(
args.sources_path, "csharp", "src", "Microsoft.ML.OnnxRuntime", "targets", "net6.0-ios", "targets.xml"
)
net7_ios_target_targets = os.path.join(
net6_ios_target_targets = os.path.join(
args.sources_path,
"csharp",
"src",
"Microsoft.ML.OnnxRuntime",
"targets",
"net7.0-ios",
"net6.0-ios",
args.package_name + ".targets",
)
net7_maccatalyst_source_targets = os.path.join(
net6_macos_source_targets = os.path.join(
args.sources_path, "csharp", "src", "Microsoft.ML.OnnxRuntime", "targets", "net6.0-macos", "targets.xml"
)
net6_macos_target_targets = os.path.join(
args.sources_path,
"csharp",
"src",
"Microsoft.ML.OnnxRuntime",
"targets",
"net7.0-maccatalyst",
"_._",
)
net7_maccatalyst_target_targets = os.path.join(
args.sources_path, "csharp", "src", "Microsoft.ML.OnnxRuntime", "targets", "net7.0-maccatalyst", "_._"
)
net7_macos_source_targets = os.path.join(
args.sources_path, "csharp", "src", "Microsoft.ML.OnnxRuntime", "targets", "net7.0-macos", "targets.xml"
)
net7_macos_target_targets = os.path.join(
args.sources_path,
"csharp",
"src",
"Microsoft.ML.OnnxRuntime",
"targets",
"net7.0-macos",
"net6.0-macos",
args.package_name + ".targets",
)
os.system(copy_command + " " + monoandroid_source_targets + " " + monoandroid_target_targets)
os.system(copy_command + " " + xamarinios_source_targets + " " + xamarinios_target_targets)
os.system(copy_command + " " + net7_android_source_targets + " " + net7_android_target_targets)
os.system(copy_command + " " + net7_ios_source_targets + " " + net7_ios_target_targets)
os.system(copy_command + " " + net7_maccatalyst_source_targets + " " + net7_maccatalyst_target_targets)
os.system(copy_command + " " + net7_macos_source_targets + " " + net7_macos_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_macos_source_targets + " " + net6_macos_target_targets)
files_list.append("<file src=" + '"' + monoandroid_target_targets + '" target="build\\monoandroid11.0" />')
files_list.append(
@ -1037,30 +1019,20 @@ def generate_files(line_list, args):
)
files_list.append(
"<file src=" + '"' + net7_android_target_targets + '" target="build\\net7.0-android31.0" />'
"<file src=" + '"' + net6_android_target_targets + '" target="build\\net6.0-android31.0" />'
)
files_list.append(
"<file src=" + '"' + net7_android_target_targets + '" target="buildTransitive\\net7.0-android31.0" />'
"<file src=" + '"' + net6_android_target_targets + '" target="buildTransitive\\net6.0-android31.0" />'
)
files_list.append("<file src=" + '"' + net7_ios_target_targets + '" target="build\\net7.0-ios15.4" />')
files_list.append("<file src=" + '"' + net6_ios_target_targets + '" target="build\\net6.0-ios15.4" />')
files_list.append(
"<file src=" + '"' + net7_ios_target_targets + '" target="buildTransitive\\net7.0-ios15.4" />'
"<file src=" + '"' + net6_ios_target_targets + '" target="buildTransitive\\net6.0-ios15.4" />'
)
files_list.append("<file src=" + '"' + net6_macos_target_targets + '" target="build\\net6.0-macos12.3" />')
files_list.append(
"<file src=" + '"' + net7_maccatalyst_target_targets + '" target="build\\net7.0-maccatalyst14.0" />'
)
files_list.append(
"<file src="
+ '"'
+ net7_maccatalyst_target_targets
+ '" target="buildTransitive\\net7.0-maccatalyst14.0" />'
)
files_list.append("<file src=" + '"' + net7_macos_target_targets + '" target="build\\net7.0-macos12.3" />')
files_list.append(
"<file src=" + '"' + net7_macos_target_targets + '" target="buildTransitive\\net7.0-macos12.3" />'
"<file src=" + '"' + net6_macos_target_targets + '" target="buildTransitive\\net6.0-macos12.3" />'
)
# Process Training specific targets and props
@ -1084,27 +1056,27 @@ def generate_files(line_list, args):
args.package_name + ".targets",
)
net7_android_source_targets = os.path.join(
net6_android_source_targets = os.path.join(
args.sources_path,
"csharp",
"src",
"Microsoft.ML.OnnxRuntime",
"targets",
"net7.0-android",
"net6.0-android",
"targets.xml",
)
net7_android_target_targets = os.path.join(
net6_android_target_targets = os.path.join(
args.sources_path,
"csharp",
"src",
"Microsoft.ML.OnnxRuntime",
"targets",
"net7.0-android",
"net6.0-android",
args.package_name + ".targets",
)
os.system(copy_command + " " + monoandroid_source_targets + " " + monoandroid_target_targets)
os.system(copy_command + " " + net7_android_source_targets + " " + net7_android_target_targets)
os.system(copy_command + " " + net6_android_source_targets + " " + net6_android_target_targets)
files_list.append("<file src=" + '"' + monoandroid_target_targets + '" target="build\\monoandroid11.0" />')
files_list.append(
@ -1112,10 +1084,10 @@ def generate_files(line_list, args):
)
files_list.append(
"<file src=" + '"' + net7_android_target_targets + '" target="build\\net7.0-android31.0" />'
"<file src=" + '"' + net6_android_target_targets + '" target="build\\net6.0-android31.0" />'
)
files_list.append(
"<file src=" + '"' + net7_android_target_targets + '" target="buildTransitive\\net7.0-android31.0" />'
"<file src=" + '"' + net6_android_target_targets + '" target="buildTransitive\\net6.0-android31.0" />'
)
# README