如何在使用MSBuild构建C#应用程序时选择32位或64位DLL?

时间:2018-05-08 06:02:44

标签: msbuild

我有一个应用程序的分支,它运行64位DLL。我现在已经找到了相同库的32位等效DLL。如何根据我是否要为32位或64位平台构建应用程序来告诉MSBuild使用某个DLL?

我担心我甚至不知道从哪里开始。我看过也许在MSBuild中使用PropertyGroup项目,但它没有多大意义......

1 个答案:

答案 0 :(得分:0)

您想根据项目目标平台引用不同的dll(不同的路径/名称)吗?使用条件,类似的东西:

<ItemGroup>
   <Reference Include="Dependency.dll" Condition="$(Platform) == 'x64'">
      <HintPath>x64\Dependency.dll</HintPath>
   </Reference>
   <Reference Include="Dependency.dll" Condition="$(Platform) == 'x86'">
      <HintPath>x86\Dependency.dll</HintPath>
   </Reference>
<ItemGroup>

另请参阅:How do I specify the platform for MSBuild?Active solution platform VS Project Platform VS Platform target