我使用的是一个.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位构建目标,它始终是32位版本最终在我的构建的"Bin“文件夹中。
有谁知道这个过程是如何工作的,以及是什么决定了NuGet将决定以哪个平台为目标?如何使nuget-restore-and-build进程选择64位DLL?(使用Visual Studio或msbuild执行构建)
发布于 2021-06-12 05:47:59
您发布的目标文件与最新版本(4.2.4)的FiftyOne.DeviceDetection.Hash.Engine.OnPremise NuGet软件包的目标文件不匹配,其中AnyCPU匹配的是x86平台,而不是x64平台:
<?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' ">
<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' OR '$(Platform)' == 'AnyCPU' ">
<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>因此,为了让正确的本机dll在您的输出目录中结束,您应该在您的csproj文件中添加<Platform>x64</Platform>,或者通过指定如下Platform属性来构建您的项目:
dotnet build /p:Platform=x64 MyApp.csprojhttps://stackoverflow.com/questions/67942689
复制相似问题