Visual studio 使用不同引用编译Win32和x64 csproj
我想保留我的.csproj项目并编译两个版本的dll,一个用于Win32平台,另一个用于x64平台 我遇到了一个问题,因为我需要为每个平台使用不同的引用 例如,对于ExternalReference.dllVisual studio 使用不同引用编译Win32和x64 csproj,visual-studio,64-bit,csproj,Visual Studio,64 Bit,Csproj,我想保留我的.csproj项目并编译两个版本的dll,一个用于Win32平台,另一个用于x64平台 我遇到了一个问题,因为我需要为每个平台使用不同的引用 例如,对于ExternalReference.dll <Reference Include="ExternalReference"> <SpecificVersion>False</SpecificVersion> <HintPath>c:\win32_repository\Exte
<Reference Include="ExternalReference">
<SpecificVersion>False</SpecificVersion>
<HintPath>c:\win32_repository\ExternalReference.dll</HintPath>
</Reference>
我读过$ReferencePath变量,但它似乎只在.csproj.user文件中起作用,并且这些文件不存在于我们的版本控制中,因此这不是一个解决方案
你们有什么想法吗?我能否在.csproj中定义一个自定义变量,如下所示:
<PropertyGroup Condition=" '$(Platform)' == 'Win32' >
<CustomReferencePath>c:\win32_repository</CustomReferencePath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x64' >
<CustomReferencePath>c:\x64_repository</CustomReferencePath>
</PropertyGroup>
<Reference Include="ExternalReference">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(CustomReferencePath)\ExternalReference.dll</HintPath>
</Reference>
然后添加如下引用:
<PropertyGroup Condition=" '$(Platform)' == 'Win32' >
<CustomReferencePath>c:\win32_repository</CustomReferencePath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x64' >
<CustomReferencePath>c:\x64_repository</CustomReferencePath>
</PropertyGroup>
<Reference Include="ExternalReference">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(CustomReferencePath)\ExternalReference.dll</HintPath>
</Reference>
但它似乎不起作用,我做错什么了吗?为什么不简单地:
<Reference Include="ExternalReference" Condition=" '$(Platform)' == 'Win32'>
<SpecificVersion>False</SpecificVersion>
<HintPath>c:\win32_repository\ExternalReference.dll</HintPath>
</Reference>
<Reference Include="ExternalReference" Condition=" '$(Platform)' == 'x64'>
<SpecificVersion>False</SpecificVersion>
<HintPath>c:\x64_repository\ExternalReference.dll</HintPath>
</Reference>
不起作用怎么办?未引入正确的程序集或根本无法工作?.NET元数据不依赖于位。发生什么事了那是什么?或者这仅仅是将正确的DLL复制到构建文件夹中的问题吗?嗨,我在一个扩展软件上写了这个软件库。有些库可能不是.Net,无论如何,我真的希望使用正确的依赖项,以与我们使用的扩展设计保持一致。