【发布时间】:2021-08-28 17:35:22
【问题描述】:
我正在使用一个 .net NuGet,它包含一个编译为本机代码的 DLL。该原生 DLL 有两个版本,一个 32 位版本和一个 64 位版本。
nuget 使用其“build”文件夹中的“.targets”文件来确定要复制的 DLL。目标文件看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- Ensure that for Framework projects the correct DLL is copied to the build directory -->
<ItemGroup Condition=" '$(Platform)' == 'x64' OR '$(Platform)' == 'AnyCPU' ">
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win-x64\native\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll</Link>
</Content>
</ItemGroup>
<ItemGroup Condition=" '$(Platform)' == 'x86' ">
<Content Include="$(MSBuildThisFileDirectory)..\runtimes\win-x86\native\FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Link>FiftyOne.DeviceDetection.Hash.Engine.OnPremise.Native.dll</Link>
</Content>
</ItemGroup>
</Project>
但是,即使我使用的是 64 位计算机并使用 64 位构建目标,最终在我的构建的“Bin”文件夹中的始终是 32 位版本。
有谁知道这个过程是如何工作的,以及什么决定了 NuGet 将决定以哪个平台为目标?如何让 nuget-restore-and-build 进程选择 64 位 DLL? (使用 Visual Studio 或 msbuild 执行构建)
【问题讨论】: