forked from microsoft/onnxruntime
/
Microsoft.ML.OnnxRuntime.csproj
370 lines (324 loc) · 18.7 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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
<Project Sdk="MSBuild.Sdk.Extras/3.0.22">
<PropertyGroup>
<!--- packaging properties -->
<OrtPackageId Condition="'$(OrtPackageId)' == ''">Microsoft.ML.OnnxRuntime</OrtPackageId>
</PropertyGroup>
<!--
Temporary setup until official Visual Studio 2022 release supports .net6, as the CIs require the official release.
We will be able to build all targets with VS once that happens.
Until then, we need to build the pre-.net6 targets with VS and the .net6 targets with dotnet.
The pre-.net6 Xamarin targets are optional and only included if the machine has the required workloads.
We have 3 scenarios
1) Build pre-net6 targets with VS - SelectedTargets=PreNet6
2) Build net6 targets - SelectedTargets=Net6
3) Run 'Pack' target to create nuget package from combination of 1 and 2 - SelectedTargets=All
Default is PreNet6 so that existing projects and CI builds will do the same thing unless explicitly updated.
-->
<PropertyGroup>
<SelectedTargets>PreNet6</SelectedTargets>
<BaseTargets>netstandard2.0;netcoreapp3.1;net6.0</BaseTargets>
</PropertyGroup>
<!-- only set the Xamarin mobile targets if we're building an ORT package,
and only if the mobile workloads are installed -->
<PropertyGroup Condition="('$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime' OR
'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Gpu') AND
Exists('$(MSBuildExtensionsPath)\Xamarin\Android') AND
Exists('$(MSBuildExtensionsPath)\Xamarin\iOS')">
<XamarinTargets>xamarinios10;monoandroid11.0</XamarinTargets>
</PropertyGroup>
<PropertyGroup Condition="('$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Training') AND
Exists('$(MSBuildExtensionsPath)\Xamarin\Android')">
<XamarinTargetsForTraining>monoandroid11.0</XamarinTargetsForTraining>
</PropertyGroup>
<!-- only set the .net6 targets if we're building an ORT package.
we can add .net6 support to other packages later as needed -->
<PropertyGroup Condition="('$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime' OR
'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Azure' OR
'$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Gpu')">
<Net6Targets>net6.0;net6.0-android;net6.0-ios;net6.0-macos</Net6Targets>
</PropertyGroup>
<PropertyGroup Condition="('$(OrtPackageId)' == 'Microsoft.ML.OnnxRuntime.Training')">
<Net6TargetsForTrainingPackage>net6.0;net6.0-android</Net6TargetsForTrainingPackage>
</PropertyGroup>
<PropertyGroup Condition="'$(SelectedTargets)'=='PreNet6'">
<TargetFrameworks>$(BaseTargets);$(XamarinTargets);$(XamarinTargetsForTraining)</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(SelectedTargets)'=='Net6'">
<TargetFrameworks>$(Net6Targets);$(Net6TargetsForTrainingPackage)</TargetFrameworks>
</PropertyGroup>
<!-- nuget package creation -->
<PropertyGroup Condition="'$(SelectedTargets)'=='All'">
<TargetFrameworks>$(BaseTargets);$(XamarinTargets);$(XamarinTargetsForTraining);$(Net6Targets);$(Net6TargetsForTrainingPackage)</TargetFrameworks>
</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>
<RootNamespace>Microsoft.ML.OnnxRuntime</RootNamespace>
<AssemblyName>Microsoft.ML.OnnxRuntime</AssemblyName>
<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>
<!--- 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 -->
<PackageId>Microsoft.ML.OnnxRuntime.Managed</PackageId>
<Authors>Microsoft</Authors>
<PackageVersion Condition=" '$(PackageVersion)' == '' And '$(Configuration)' == 'Debug' ">1.0.0</PackageVersion>
<PackageVersion Condition=" '$(PackageVersion)' == '' ">0.0.0</PackageVersion>
<Version>$(PackageVersion)</Version>
<Description>This package contains ONNX Runtime for .Net platforms</Description>
<PackageTags>ONNX;ONNX Runtime;Machine Learning</PackageTags>
<PackageProjectUrl>https://github.com/Microsoft/onnxruntime</PackageProjectUrl>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<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>
<!-- 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>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<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.
-->
<IsXamarinTarget Condition="$(TargetFramework.StartsWith('xamarinios')) OR
$(TargetFramework.StartsWith('monoandroid'))">true</IsXamarinTarget>
<IsAndroidTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android' OR
$(TargetFramework.StartsWith('monoandroid'))">true</IsAndroidTarget>
<IsIOSTarget Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' OR
$(TargetFramework.StartsWith('xamarinios'))">true</IsIOSTarget>
<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
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 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 net6.0
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 Condition="'$(IsXamarinTarget)'=='true'">
<OrtConstants>$(OrtConstants);__XAMARIN__</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="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)' IsXamarinTarget='$(IsXamarinTarget)'" />
<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>
<ItemGroup>
<Compile Include="**\*.shared.cs" Link="%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('netstandard'))">
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<Compile Include="**\*.netstandard.cs" Link="platform\netstandard\%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('net')) AND !$(TargetFramework.StartsWith('netstandard')) ">
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
<Compile Include="**\*.net.cs" Link="platform\net\%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('monoandroid'))">
<Compile Include="**\*.android.cs" Link="platform\android\%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup Condition="$(TargetFramework.StartsWith('xamarinios')) ">
<Compile Include="**\*.ios.cs" Link="platform\ios\%(Filename)%(Extension)" />
</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>