onnxruntime/csharp/src/Microsoft.AI.MachineLearning/Microsoft.AI.MachineLearning.targets
Sheil Kumar 7b51a1b17d
Enable Microsoft.AI.MachineLearning NuGet with WinUI projects (#16415)
Microsoft.AI.MachineLearning NuGet fails to build on WinUI projects due
to the conflict between the ReferenceCopy of binaries that occurs with
managed applications, with the manual binplacement that occurs with
native appliactions.

With WinUI, both cases are triggered, and a duplicate binplace is
detected as an error.

Fix: Don't rely on the ReferenceCopy for WinUI applications, and
manually binplace the Microsoft.AI.MachineLearning dll.
2023-06-20 13:10:19 -07:00

41 lines
2.4 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == 'x64'">$(Platform)</WindowsAI-Platform>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == 'Win32' Or '$(PlatformTarget)' == 'x86'">x86</WindowsAI-Platform>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == 'ARM'">$(Platform)</WindowsAI-Platform>
<WindowsAI-Platform Condition="'$(PlatformTarget)' == 'ARM64'">$(Platform)</WindowsAI-Platform>
</PropertyGroup>
<PropertyGroup>
<RuntimesDirectory>$(MSBuildThisFileDirectory)..\..\runtimes\win-$(WindowsAI-Platform)\_native</RuntimesDirectory>
<WindowsAIBinarySubfolder Condition="'$(UseWindowsMLStaticRuntime)' == 'true'">static\</WindowsAIBinarySubfolder>
<WindowsAIBinary>$(RuntimesDirectory)\$(WindowsAIBinarySubfolder)microsoft.ai.machinelearning.dll</WindowsAIBinary>
<WindowsAIWinMD>$(MSBuildThisFileDirectory)..\..\winmds\Microsoft.AI.MachineLearning.winmd</WindowsAIWinMD>
<WindowsAIExperimentalWinMD>$(MSBuildThisFileDirectory)..\..\winmds\Microsoft.AI.MachineLearning.Experimental.winmd</WindowsAIExperimentalWinMD>
<WindowsAIBinary>$([System.IO.Path]::GetFullPath($(WindowsAIBinary)))</WindowsAIBinary>
<WindowsAIWinMD>$([System.IO.Path]::GetFullPath($(WindowsAIWinMD)))</WindowsAIWinMD>
<WindowsAIExperimentalWinMD>$([System.IO.Path]::GetFullPath($(WindowsAIExperimentalWinMD)))</WindowsAIExperimentalWinMD>
</PropertyGroup>
<PropertyGroup Condition="'$(DisableOnnxRuntimeDllCopy)' != 'true'">
<OnnxRuntimeBinary>$(RuntimesDirectory)\$(WindowsAIBinarySubfolder)onnxruntime.dll</OnnxRuntimeBinary>
</PropertyGroup>
<ItemGroup>
<Reference Include="$(WindowsAIWinMD)">
<Implementation>$(WindowsAIBinary)</Implementation>
</Reference>
<Reference Include="$(WindowsAIExperimentalWinMD)">
<Implementation>$(WindowsAIBinary)</Implementation>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(NuGetProjectStyle)' != 'PackageReference' AND WinAppSDKPackageName == ''">
<ReferenceCopyLocalPaths Include="$(WindowsAIBinary);" />
</ItemGroup>
<ItemGroup Condition="'$(NuGetProjectStyle)' != 'PackageReference' OR '$(TargetPlatformIdentifier)' == 'UAP'">
<ReferenceCopyLocalPaths Include="$(OnnxRuntimeBinary)" />
</ItemGroup>
</Project>