forked from microsoft/onnxruntime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMicrosoft.ML.OnnxRuntime.csproj
241 lines (205 loc) · 12.2 KB
/
Microsoft.ML.OnnxRuntime.csproj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<Project Sdk="Microsoft.NET.Sdk">
<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>
<!-- Build host -->
<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 for MAUI builds 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.
-->
<IsWindowsTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">true</IsWindowsTarget>
<IsAndroidTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">true</IsAndroidTarget>
<IsIOSTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">true</IsIOSTarget>
<IsMacCatalystTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">true</IsMacCatalystTarget>
<OnnxRuntimeRoot>$(ProjectDir)..\..\..</OnnxRuntimeRoot>
<!-- 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>
</PropertyGroup>
<!-- package info -->
<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>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<!-- sourcelink flags -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\OnnxRuntime.snk</AssemblyOriginatorKeyFile>
<AllowedOutputExtensionsInPackageBuildOutputFolder>
$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb
</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<PropertyGroup>
<Platforms>AnyCPU;x86</Platforms>
<LangVersion>default</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<TargetArchitecture Condition=" '$(TargetArchitecture)' == '' ">x64</TargetArchitecture>
<EnableDefaultItems>false</EnableDefaultItems>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<DebugType>portable</DebugType>
<Configurations>Debug;Release;RelWithDebInfo</Configurations>
</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 are used when creating the managed package using the Pack target.
-->
<PropertyGroup Condition="'$(IsWindowsBuild)'=='true'">
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)</NativeBuildOutputDir>
</PropertyGroup>
<PropertyGroup Condition="'$(IsLinuxBuild)'=='true'">
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)</NativeBuildOutputDir>
</PropertyGroup>
<!--
Properties that depend on the target framework.
-->
<PropertyGroup Condition="'$(IsIOSTarget)'=='true' OR '$(IsMacCatalystTarget)'=='true' OR '$(IsAndroidTarget)'=='true'">
<OrtConstants>$(OrtConstants);__MOBILE__</OrtConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsAndroidTarget)'=='true'">
<OrtConstants>$(OrtConstants);__ANDROID__</OrtConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(IsIOSTarget)'=='true' OR '$(IsMacCatalystTarget)'=='true'">
<OrtConstants>$(OrtConstants);__IOS__</OrtConstants>
</PropertyGroup>
<!-- CoreML is valid on iOS, Mac Catalyst and macOS -->
<PropertyGroup Condition="'$(IsIOSTarget)'=='true' OR '$(IsMacCatalystTarget)'=='true' OR '$(IsMacOSBuild)'=='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>
<!--
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 Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">
<PackageReference Include="System.Numerics.Tensors" Version="9.0.0" />
</ItemGroup>
<!-- 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="IsWindowsBuild='$(IsWindowsBuild)' IsLinuxBuild='$(IsLinuxBuild)' IsMacOSBuild='$(IsMacOSBuild)'" />
<Message Text="IsWindowsTarget='$(IsWindowsTarget)' IsAndroidTarget='$(IsAndroidTarget)' IsIOSTarget='$(IsIOSTarget)' IsMacCatalystTarget='$(IsMacCatalystTarget)'" />
<Message Text="OrtConstants='$(OrtConstants)' " />
<Message Text="TargetFrameworks='$(TargetFrameworks)' " />
</Target>
<!--
Setup the Pack target related info to create the Microsoft.ML.OnnxRuntime.Managed package
-->
<Target Name="RenameFilesToPack" BeforeTargets="Pack">
<!-- We (painfully) have to rename files if the extensions differs due to nuget implementation details. -->
<ItemGroup>
<SourceFilesToRename Include="
$(OnnxRuntimeRoot)\LICENSE;
$(OnnxRuntimeRoot)\csharp\src\Microsoft.ML.OnnxRuntime\targets\netstandard\targets.xml" />
<DestFilesToRename Include=
"$(NativeBuildOutputDir)\LICENSE.txt;
$(NativeBuildOutputDir)\$(PackageId).targets" />
</ItemGroup>
<!-- rename the files and output to the native build output dir so we keep the source tree clean -->
<Copy SourceFiles="@(SourceFilesToRename)" DestinationFiles="@(DestFilesToRename)"/>
</Target>
<ItemGroup>
<None Include="$(OnnxRuntimeRoot)\ThirdPartyNotices.txt"
PackagePath="ThirdPartyNotices.txt" Pack="true" Visible="false"/>
<None Include="$(OnnxRuntimeRoot)\docs\Privacy.md"
PackagePath="Privacy.md" Pack="true" Visible="false"/>
<None Include="$(OnnxRuntimeRoot)\ORT_icon_for_light_bg.png"
PackagePath="ORT_icon_for_light_bg.png" Pack="true" Visible="false"/>
<None Include="$(OnnxRuntimeRoot)\tools\nuget\nupkg.README.md"
PackagePath="README.md" Pack="true" Visible="false"/>
<None Include="$(NativeBuildOutputDir)\LICENSE.txt"
PackagePath="" Pack="true" Visible="false"/>
<None Include="$(NativeBuildOutputDir)\$(PackageId).targets"
PackagePath="build\netstandard2.0\$(PackageId).targets" Pack="true" Visible="false"/>
</ItemGroup>
<Target Name="CopyPackage" AfterTargets="Pack">
<Copy SourceFiles="$(OutputPath)\$(PackageId).$(PackageVersion).nupkg"
DestinationFolder="$(NativeBuildOutputDir)" />
</Target>
</Project>