Visual Studio 项目平台依赖引用

Visual Studio project platform dependent references

我有一个 WP 项目,我为此使用了来自单独项目的运行时模块。

如果我从主项目引用运行时模块项目,platform/configuration(例如:x86/Debug vs ARM/Release)在构建时由 visual studio 自动处理.

现在,我想删除项目依赖项,只引用主项目中的二进制文件,这样当我选择特定的 platform/configuration 时,将使用正确的引用来构建。

例如,如果我为 ARM/Release 构建它应该使用来自 ./lib/ARM/Release/MyLibrary.winmd 的二进制文件,如果我为 x86/Debug 构建它应该使用来自 ./lib/x86/Debug/MyLibrary.winmd.[= 的二进制文件17=]

我尝试了多种方法,但仍然找不到同时适用于 Visual Studio 和 msbuild 的解决方案。

我实际上让它工作,使提示路径使用平台和配置变量。

<Reference Include="MyLibrary, Version=255.255.255.255, Culture=neutral, processorArchitecture=MSIL">
  <SpecificVersion>False</SpecificVersion>
  <HintPath>..\..\lib$(Platform)$(Configuration)\MyLibrary\MyLibrary.winmd</HintPath>
</Reference>

根据您在 VS 中的构建选择,您或许可以使用一些宏。 例如,在链接器中找到的两个宏如下:

$(ProcessorArchitecture) which for my example = x86 $(ProcessorArchitectureAsPlatform) which for me = Win32

根据您选择的配置,它将在调试/发布中构建。

和Pinco说的差不多