mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-25 19:48:11 +00:00
### Description <!-- Describe your changes. --> Update various test projects to .net8 from EOL frameworks. Replace the Xamarin based Android and iOS test projects with a MAUI based project that uses .net 8. Add new CoreML flags to C# bindings ### 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. --> Remove usage of EOL frameworks.
333 lines
16 KiB
XML
333 lines
16 KiB
XML
<Project Sdk="MSBuild.Sdk.Extras/3.0.22">
|
|
<PropertyGroup>
|
|
<!--- packaging properties -->
|
|
<OrtPackageId Condition="'$(OrtPackageId)' == ''">Microsoft.ML.OnnxRuntime</OrtPackageId>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<IncludeMobileTargets>true</IncludeMobileTargets>
|
|
<BaseTargets>netstandard2.0;net8.0</BaseTargets>
|
|
<MobileTargets></MobileTargets>
|
|
</PropertyGroup>
|
|
|
|
<!-- special case the DesktopOnly solution -->
|
|
<PropertyGroup Condition="'$(SolutionName)' == 'OnnxRuntime.DesktopOnly.CSharp'">
|
|
<IncludeMobileTargets>false</IncludeMobileTargets>
|
|
</PropertyGroup>
|
|
|
|
<!-- add MAUI targets if building ORT package -->
|
|
<PropertyGroup Condition="('$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime' OR
|
|
'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Azure') AND
|
|
'$(IncludeMobileTargets)' == 'true'">
|
|
<MobileTargets>net8.0-android;net8.0-ios;net8.0-maccatalyst</MobileTargets>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Training' AND
|
|
'$(IncludeMobileTargets)' == 'true'">
|
|
<MobileTargets>net8.0-android</MobileTargets>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<TargetFrameworks>$(BaseTargets);$(MobileTargets)</TargetFrameworks>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<RootNamespace>Microsoft.ML.OnnxRuntime</RootNamespace>
|
|
<AssemblyName>Microsoft.ML.OnnxRuntime</AssemblyName>
|
|
|
|
<!-- Ignore any passed in value unless this is a release build. -->
|
|
<PackageVersion Condition="'$(IsReleaseBuild)' != 'true'"></PackageVersion>
|
|
<PackageVersion Condition="'$(PackageVersion)' == '' And '$(Configuration)' == 'Debug'">1.0.0</PackageVersion>
|
|
<PackageVersion Condition="'$(PackageVersion)' == '' ">0.0.0</PackageVersion>
|
|
|
|
<!-- Set the attributes for the managed dll -->
|
|
<!-- https://learn.microsoft.com/en-us/dotnet/standard/assembly/set-attributes-project-file -->
|
|
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
|
|
<AssemblyTitle>Microsoft.ML.OnnxRuntime C# Bindings</AssemblyTitle>
|
|
<Company>Microsoft</Company>
|
|
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
|
|
<Description>This package contains ONNX Runtime for .Net platforms</Description>
|
|
|
|
<!-- NOTE: this is also used as the default for AssemblyVersion and FileVersion -->
|
|
<Version>$(PackageVersion)</Version>
|
|
|
|
<!-- Set the attributes for a nuget package -->
|
|
<!--- The package name is always hardcoded as the package created by this project only contains managed assemblies -->
|
|
<!--- The parameter OrtPackageId is only used for some conditional logic below -->
|
|
<Authors>Microsoft</Authors>
|
|
<PackageId>Microsoft.ML.OnnxRuntime.Managed</PackageId>
|
|
<PackageTags>ONNX;ONNX Runtime;Machine Learning</PackageTags>
|
|
<PackageProjectUrl>https://github.com/Microsoft/onnxruntime</PackageProjectUrl>
|
|
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
|
|
<PackageIcon>ORT_icon_for_light_bg.png</PackageIcon>
|
|
<PackageReleaseNotes>
|
|
Release Def:
|
|
Branch: $(BUILD_SOURCEBRANCH)
|
|
Commit: $(BUILD_SOURCEVERSION)
|
|
Build: https://aiinfra.visualstudio.com/Lotus/_build/results?buildId=$(BUILD_BUILDID)
|
|
</PackageReleaseNotes>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<Platforms>AnyCPU;x86</Platforms>
|
|
<LangVersion>default</LangVersion>
|
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
|
<SignAssembly>true</SignAssembly>
|
|
<AssemblyOriginatorKeyFile>..\..\OnnxRuntime.snk</AssemblyOriginatorKeyFile>
|
|
|
|
<!--internal build related properties-->
|
|
<OnnxRuntimeRoot>$(ProjectDir)..\..\..</OnnxRuntimeRoot>
|
|
<OnnxRuntimeCsharpRoot>$(OnnxRuntimeRoot)\csharp</OnnxRuntimeCsharpRoot>
|
|
<TargetArchitecture Condition=" '$(TargetArchitecture)' == '' ">x64</TargetArchitecture>
|
|
|
|
<EnableDefaultItems>false</EnableDefaultItems>
|
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
|
<DebugType>portable</DebugType>
|
|
|
|
<!-- Controls whether C# Bindings for Training are included in the Managed Nuget Package.
|
|
Bindings for training are included by default. If user tries to call training apis when the native package installed
|
|
on their device is not built for training, an exception will be thrown with the following message -
|
|
"Training is disabled in the current build. Please build onnxruntime from source with the build flags
|
|
enable_training_apis. "-->
|
|
<EnableTrainingApis Condition="'$(EnableTrainingApis)' == ''">true</EnableTrainingApis>
|
|
|
|
<!-- sourcelink flags -->
|
|
<PublishRepositoryUrl>true</PublishRepositoryUrl>
|
|
|
|
<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
|
|
<!--EmbedUntrackedSources>true</EmbedUntrackedSources-->
|
|
|
|
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
|
|
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
|
<Configurations>Debug;Release;RelWithDebInfo</Configurations>
|
|
|
|
<IsLinuxBuild Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))' == 'true'">true</IsLinuxBuild>
|
|
<IsWindowsBuild Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindowsBuild>
|
|
<IsMacOSBuild Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true'">true</IsMacOSBuild>
|
|
|
|
<!-- $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) gives better results than
|
|
$(TargetPlatformIdentifier). See https://github.com/dotnet/msbuild/issues/7359
|
|
Note there are slight differences in casing (e.g. macos vs macOS), so if we ever
|
|
change to use $(TargetPlatformIdentifier) we need to adjust for that.
|
|
-->
|
|
<IsAndroidTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">true</IsAndroidTarget>
|
|
<IsIOSTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' OR
|
|
$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">true</IsIOSTarget>
|
|
<IsMacTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos'">true</IsMacTarget>
|
|
</PropertyGroup>
|
|
|
|
<!-- Enable training APIs for the build. The native package must be
|
|
a training build with build flag 'enable_training_apis'.
|
|
-->
|
|
<PropertyGroup Condition="'$(EnableTrainingApis)'=='true'">
|
|
<OrtConstants>$(OrtConstants);__ENABLE_TRAINING_APIS__</OrtConstants>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
Properties that depend on the system we're building on.
|
|
-->
|
|
<PropertyGroup Condition="'$(IsLinuxBuild)'=='true'">
|
|
<!--internal build related properties for Linux -->
|
|
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\Linux</OnnxRuntimeBuildDirectory>
|
|
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)</NativeBuildOutputDir>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(IsWindowsBuild)'=='true'">
|
|
<!--internal build related properties for Windows -->
|
|
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\Windows</OnnxRuntimeBuildDirectory>
|
|
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)</NativeBuildOutputDir>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(IsMacOSBuild)'=='true'">
|
|
<!--internal build related properties for OSX -->
|
|
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\MacOS</OnnxRuntimeBuildDirectory>
|
|
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)</NativeBuildOutputDir>
|
|
</PropertyGroup>
|
|
|
|
<!--
|
|
Properties that depend on the target framework.
|
|
-->
|
|
<PropertyGroup Condition="'$(IsIOSTarget)'=='true' OR '$(IsAndroidTarget)'=='true'">
|
|
<OrtConstants>$(OrtConstants);__MOBILE__</OrtConstants>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(IsAndroidTarget)'=='true'">
|
|
<OrtConstants>$(OrtConstants);__ANDROID__</OrtConstants>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup Condition="'$(IsIOSTarget)'=='true'">
|
|
<OrtConstants>$(OrtConstants);__IOS__</OrtConstants>
|
|
</PropertyGroup>
|
|
|
|
<!-- CoreML is definitely valid on iOS and macOS -->
|
|
<PropertyGroup Condition="'$(IsIOSTarget)'=='true' OR '$(IsMacTarget)'=='true'">
|
|
<OrtConstants>$(OrtConstants);__ENABLE_COREML__</OrtConstants>
|
|
</PropertyGroup>
|
|
|
|
<!-- CoreML is valid for a macOS .net app. Enable in case GetTargetPlatformIdentifier was not set.
|
|
TargetFrameworkIdentifier of .netX is '.NETCoreApp'
|
|
We do a runtime check that the OS is macOS before attempting to enable CoreML.
|
|
NOTE: $(TargetFrameworkIdentitier) may not be set yet, so we need to call GetTargetFrameworkIdentifier
|
|
-->
|
|
<PropertyGroup Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)'))=='.NETCoreApp' AND
|
|
$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))==''">
|
|
<OrtConstants>$(OrtConstants);__ENABLE_COREML__</OrtConstants>
|
|
</PropertyGroup>
|
|
|
|
<PropertyGroup>
|
|
<DefineConstants>$(DefineConstants);$(OrtConstants)</DefineConstants>
|
|
</PropertyGroup>
|
|
|
|
<!-- debug output - makes finding/fixing any issues with the the conditions easy. -->
|
|
<Target Name="DumpValues" BeforeTargets="PreBuildEvent">
|
|
<Message Text="SolutionName='$(SolutionName)'" />
|
|
<Message Text="TargetPlatform='$(TargetPlatform)' TargetPlatformIdentifier='$(TargetPlatformIdentifier)' " />
|
|
<Message Text="TargetFramework='$(TargetFramework)' TargetFrameworkIdentifier='$(TargetFrameworkIdentifier)' " />
|
|
<Message Text="[MSBuild]::GetTargetPlatformIdentifier(TargetFramework)='$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))' " />
|
|
<Message Text="[MSBuild]::GetTargetFrameworkIdentifier(TargetFramework)='$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)'))' " />
|
|
<Message Text="IsMacTarget='$(IsMacTarget)' IsIOSTarget='$(IsIOSTarget)' IsAndroidTarget='$(IsAndroidTarget)'" />
|
|
<Message Text="OrtConstants='$(OrtConstants)' " />
|
|
<Message Text="TargetFrameworks='$(TargetFrameworks)' " />
|
|
</Target>
|
|
|
|
<ItemGroup>
|
|
<None Include="$(OnnxRuntimeCsharpRoot)\..\include\onnxruntime\core\session\onnxruntime_*.h"
|
|
PackagePath="\build\native\include"
|
|
Pack="false"
|
|
CopyToOutputDirectory="Never"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(OnnxRuntimeCsharpRoot)\..\include\onnxruntime\core\providers\cpu\cpu_provider_factory.h"
|
|
PackagePath="\build\native\include"
|
|
Pack="false"
|
|
CopyToOutputDirectory="Never"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(OnnxRuntimeCsharpRoot)\..\include\onnxruntime\core\providers\dml\dml_provider_factory.h"
|
|
Condition="'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.DirectML'"
|
|
PackagePath="\build\native\include"
|
|
Pack="false"
|
|
CopyToOutputDirectory="Never"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(OnnxRuntimeCsharpRoot)\..\orttraining\orttraining\training_api\include\onnxruntime_training*.h"
|
|
Condition="'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Training'"
|
|
PackagePath="\build\native\include"
|
|
Pack="false"
|
|
CopyToOutputDirectory="Never"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(NativeBuildOutputDir)\libonnxruntime.so"
|
|
Condition="Exists('$(NativeBuildOutputDir)\libonnxruntime.so')"
|
|
PackagePath="\runtimes\linux-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
CopyToOutputDirectory="Never"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(NativeBuildOutputDir)\onnxruntime.lib"
|
|
Condition="Exists('$(NativeBuildOutputDir)\onnxruntime.lib')"
|
|
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
CopyToOutputDirectory="Never"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(NativeBuildOutputDir)\onnxruntime.dll"
|
|
Condition="Exists('$(NativeBuildOutputDir)\onnxruntime.dll')"
|
|
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
CopyToOutputDirectory="PreserveNewest"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(NativeBuildOutputDir)\onnxruntime.pdb"
|
|
Condition="Exists('$(NativeBuildOutputDir)\onnxruntime.pdb')"
|
|
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
CopyToOutputDirectory="PreserveNewest"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(NativeBuildOutputDir)\dnnl.dll"
|
|
Condition="Exists('$(NativeBuildOutputDir)\dnnl.dll')"
|
|
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
CopyToOutputDirectory="PreserveNewest"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(NativeBuildOutputDir)\mklml.dll"
|
|
Condition="Exists('$(NativeBuildOutputDir)\mklml.dll')"
|
|
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
CopyToOutputDirectory="PreserveNewest"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(NativeBuildOutputDir)\libiomp5md.dll"
|
|
Condition="Exists('$(NativeBuildOutputDir)\libiomp5md.dll')"
|
|
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
CopyToOutputDirectory="PreserveNewest"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(NativeBuildOutputDir)\tvm.dll"
|
|
Condition="Exists('$(NativeBuildOutputDir)\tvm.dll')"
|
|
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
CopyToOutputDirectory="PreserveNewest"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(OnnxRuntimeCsharpRoot)\..\LICENSE.txt;$(OnnxRuntimeCsharpRoot)\..\ThirdPartyNotices.txt;$(OnnxRuntimeCsharpRoot)\..\ORT_icon_for_light_bg.png;$(OnnxRuntimeCsharpRoot)\..\docs\Privacy.md"
|
|
PackagePath="\"
|
|
Pack="true"
|
|
Visible="false"
|
|
/>
|
|
<None Include="targets\netstandard\$(PackageId).targets"
|
|
PackagePath="build\netstandard2.0\$(PackageId).targets"
|
|
Pack="true"
|
|
Visible="false"
|
|
/>
|
|
|
|
<!-- Some tools to be packaged in nightly build only, should not be released -->
|
|
<!-- These are copied to the runtimes folder for convenience of loading with the dlls -->
|
|
<None Include="$(NativeBuildOutputDir)\onnxruntime_perf_test.exe"
|
|
Condition="('$(IsReleaseBuild)' != 'true') And ($(TargetArchitecture)=='x64') And Exists('$(NativeBuildOutputDir)\onnxruntime_perf_test.exe')"
|
|
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
Visible="false"
|
|
/>
|
|
<None Include="$(NativeBuildOutputDir)\onnx_test_runner.exe"
|
|
Condition="('$(IsReleaseBuild)' != 'true') And ($(TargetArchitecture)=='x64') And Exists('$(NativeBuildOutputDir)\onnx_test_runner.exe')"
|
|
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
|
|
Pack="false"
|
|
Visible="false"
|
|
/>
|
|
</ItemGroup>
|
|
|
|
<!--
|
|
We used to have platform specific files named *.<platform>.cs (e.g. 1.11 release) but don't anymore,
|
|
so the 'shared' is now meaningless.
|
|
-->
|
|
<ItemGroup>
|
|
<Compile Include="**\*.shared.cs" Link="%(Filename)%(Extension)" />
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<PackageReference Include="System.Memory" Version="4.5.5" />
|
|
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
|
|
</ItemGroup>
|
|
|
|
<ItemGroup>
|
|
<LicenseFile Include="$(OnnxRuntimeCsharpRoot)\..\LICENSE" Visible="false" />
|
|
<TargetsFile Include="$(OnnxRuntimeCsharpRoot)\src\Microsoft.ML.OnnxRuntime\targets\netstandard\targets.xml" Visible="false" />
|
|
</ItemGroup>
|
|
|
|
<Target Name="CopyMiscFiles" BeforeTargets="PreBuildEvent">
|
|
<Copy SourceFiles="@(LicenseFile)" DestinationFiles="@(LicenseFile->'$(OnnxRuntimeCsharpRoot)\..\%(Filename).txt')" />
|
|
<Copy SourceFiles="@(TargetsFile)" DestinationFiles="@(TargetsFile->'$(OnnxRuntimeCsharpRoot)\src\Microsoft.ML.OnnxRuntime\targets\netstandard\$(PackageId).targets')" />
|
|
</Target>
|
|
|
|
<Target Name="CopyPackage" AfterTargets="Pack">
|
|
<Copy
|
|
SourceFiles="$(OutputPath)\$(PackageId).$(PackageVersion).nupkg"
|
|
DestinationFolder="$(NativeBuildOutputDir)"
|
|
/>
|
|
</Target>
|
|
|
|
</Project>
|