Skip to content

Commit 06e0f7e

Browse files
authored
Minor changes to support inclusion of x86 bits in the Nuget packaging pipeline (#916)
* initial commit * More changes * More changes * Adding stuff back to the targets xml * More changes v3 * More changes v4 * More changes v5 * More changes v6 * More changes v7 * More changes v9 * Disable CSharp tests for now * More changes * Revert file to same status * Update props file for x86 * Change to usage of TargetArchitecture instead of PlatformTarget * Update targets.xml * Minor formatting nit fix * Update based on PR comments
1 parent 7a42ffd commit 06e0f7e

File tree

5 files changed

+48
-15
lines changed

5 files changed

+48
-15
lines changed

csharp/src/Microsoft.ML.OnnxRuntime/Microsoft.ML.OnnxRuntime.csproj

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<OnnxRuntimeCsharpRoot>..\..</OnnxRuntimeCsharpRoot>
1313
<OnnxRuntimeBuildDirectory Condition="'$(OnnxRuntimeBuildDirectory)'==''">$(OnnxRuntimeCsharpRoot)\..\build\Windows</OnnxRuntimeBuildDirectory>
1414
<NativeBuildOutputDir>$(OnnxRuntimeBuildDirectory)\$(Configuration)\$(Configuration)</NativeBuildOutputDir>
15-
15+
<TargetArchitecture Condition=" '$(TargetArchitecture)' == '' ">x64</TargetArchitecture>
16+
1617
<!--- packaging properties -->
1718
<PackageId>Microsoft.ML.OnnxRuntime</PackageId>
1819
<Authors>Microsoft</Authors>
@@ -40,41 +41,41 @@
4041
Visible="false"
4142
/>
4243
<None Include="$(NativeBuildOutputDir)\onnxruntime.lib"
43-
PackagePath="\runtimes\win-x64\native"
44+
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
4445
Pack="true"
4546
CopyToOutputDirectory="Never"
4647
Visible="false"
4748
/>
4849
<None Include="$(NativeBuildOutputDir)\onnxruntime.dll"
49-
PackagePath="\runtimes\win-x64\native"
50+
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
5051
Pack="true"
5152
CopyToOutputDirectory="Always"
5253
Visible="false"
5354
/>
5455
<None Include="$(NativeBuildOutputDir)\onnxruntime.pdb"
5556
Condition="Exists('$(NativeBuildOutputDir)\onnxruntime.pdb')"
56-
PackagePath="\runtimes\win-x64\native"
57+
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
5758
Pack="true"
5859
CopyToOutputDirectory="Always"
5960
Visible="false"
6061
/>
6162
<None Include="$(NativeBuildOutputDir)\mkldnn.dll"
6263
Condition="Exists('$(NativeBuildOutputDir)\mkldnn.dll')"
63-
PackagePath="\runtimes\win-x64\native"
64+
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
6465
Pack="true"
6566
CopyToOutputDirectory="Always"
6667
Visible="false"
6768
/>
6869
<None Include="$(NativeBuildOutputDir)\mklml.dll"
6970
Condition="Exists('$(NativeBuildOutputDir)\mklml.dll')"
70-
PackagePath="\runtimes\win-x64\native"
71+
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
7172
Pack="true"
7273
CopyToOutputDirectory="Always"
7374
Visible="false"
7475
/>
7576
<None Include="$(NativeBuildOutputDir)\libiomp5md.dll"
7677
Condition="Exists('$(NativeBuildOutputDir)\libiomp5md.dll')"
77-
PackagePath="\runtimes\win-x64\native"
78+
PackagePath="\runtimes\win-$(TargetArchitecture)\native"
7879
Pack="true"
7980
CopyToOutputDirectory="Always"
8081
Visible="false"

csharp/src/Microsoft.ML.OnnxRuntime/props.xml

+35-2
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@
1010
</ResourceCompile>
1111
</ItemDefinitionGroup>
1212

13-
<ItemDefinitionGroup>
13+
<ItemDefinitionGroup Condition="'$(PlatformTarget)' == 'x64'">
1414
<Link>
1515
<AdditionalDependencies>$(MSBuildThisFileDirectory)../../runtimes/win-x64/native/onnxruntime.lib</AdditionalDependencies>
1616
</Link>
1717
</ItemDefinitionGroup>
1818

19+
<ItemDefinitionGroup Condition="'$(PlatformTarget)' == 'x86'">
20+
<Link>
21+
<AdditionalDependencies>$(MSBuildThisFileDirectory)../../runtimes/win-x86/native/onnxruntime.lib</AdditionalDependencies>
22+
</Link>
23+
</ItemDefinitionGroup>
24+
1925
<ItemGroup Condition="Exists('packages.config') OR
2026
Exists('$(MSBuildProjectName).packages.config') OR
2127
Exists('packages.$(MSBuildProjectName).config')">
2228
<None Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x64\native\onnxruntime.dll"
2329
Condition="'$(PlatformTarget)' == 'x64'">
24-
<Link>onnxruntime.dll</Link>
30+
<Link>onnxruntime.dll</Link>
2531
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
2632
<Visible>false</Visible>
2733
</None>
@@ -46,5 +52,32 @@
4652
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
4753
<Visible>false</Visible>
4854
</None>
55+
<None Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\onnxruntime.dll"
56+
Condition="'$(PlatformTarget)' == 'x86'">
57+
<Link>onnxruntime.dll</Link>
58+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
59+
<Visible>false</Visible>
60+
</None>
61+
<None Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\mkldnn.dll"
62+
Condition="'$(PlatformTarget)' == 'x86' AND
63+
Exists('$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\mkldnn.dll')">
64+
<Link>mkldnn.dll</Link>
65+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
66+
<Visible>false</Visible>
67+
</None>
68+
<None Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\mklml.dll"
69+
Condition="'$(PlatformTarget)' == 'x86' AND
70+
Exists('$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\mklml.dll')">
71+
<Link>mklml.dll</Link>
72+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
73+
<Visible>false</Visible>
74+
</None>
75+
<None Include="$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\libiomp5md.dll"
76+
Condition="'$(PlatformTarget)' == 'x86' AND
77+
Exists('$(MSBuildThisFileDirectory)..\..\runtimes\win-x86\native\libiomp5md.dll')">
78+
<Link>libiomp5md.dll</Link>
79+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
80+
<Visible>false</Visible>
81+
</None>
4982
</ItemGroup>
5083
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<Target Name="Microsoft_ML_OnnxRuntime_CheckPrerequisites" BeforeTargets="BeforeBuild">
4-
<!--
4+
<!--
55
Special case .NET Core portable applications. When building a portable .NET Core app,
66
the PlatformTarget is empty, and you don't know until runtime (i.e. which dotnet.exe)
77
what processor architecture will be used.
88
-->
9-
<Error Condition="'$(PlatformTarget)' != 'x64' AND
9+
<Error Condition="('$(PlatformTarget)' != 'x64' AND '$(PlatformTarget)' != 'x86' AND '$(PlatformTarget)' != 'AnyCPU') AND
1010
('$(OutputType)' == 'Exe' OR '$(OutputType)'=='WinExe') AND
1111
!('$(TargetFrameworkIdentifier)' == '.NETCoreApp' AND '$(PlatformTarget)' == '') AND
1212
'$(SuppressOnnxRuntimePlatformCompatibilityError)' != 'true'"
13-
Text="Microsoft.ML.OnnxRuntime only supports the x64 platform at this time."/>
13+
Text="Microsoft.ML.OnnxRuntime only supports the AnyCPU, x64, and x86 platforms at this time."/>
1414
</Target>
1515

1616
</Project>

csharp/tools/Microsoft.ML.OnnxRuntime.PerfTool/Microsoft.ML.OnnxRuntime.PerfTool.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
<ItemGroup>
3434
<ProjectReference Include="$(OnnxRuntimeCSharpRoot)\src\Microsoft.ML.OnnxRuntime\Microsoft.ML.OnnxRuntime.csproj" />
3535
<PackageReference Include="CommandLineParser" Version="2.4.3" />
36-
<PackageReference Include="Microsoft.ML.Scoring" Version="1.1.0" />
3736
</ItemGroup>
3837

3938

csharp/tools/Microsoft.ML.OnnxRuntime.PerfTool/Program.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ public static void Main(string[] args)
4343
var cmdOptions = Parser.Default.ParseArguments<CommandOptions>(args);
4444
cmdOptions.WithParsed(
4545
options => {
46-
Main(options);
46+
Run(options);
4747
});
4848
}
49-
public static void Main(CommandOptions options)
49+
public static void Run(CommandOptions options)
5050
{
5151
string modelPath = options.ModelFile;
5252
string inputPath = options.InputFile;

0 commit comments

Comments
 (0)