简体   繁体   English

Visual Studio项目平台依赖引用

[英]Visual Studio project platform dependent references

I have a WP project for which I use a runtime module from a separate project. 我有一个WP项目,我从一个单独的项目中使用运行时模块。

If I reference the runtime module project from the main project, the platform/configuration (eg: x86/Debug vs ARM/Release ) is handled automagically by visual studio at build time. 如果我从主项目引用运行时模块项目,则visual studio会在构建时自动处理平台/配置(例如: x86/Debug vs ARM/Release )。

Now, I would like to remove the project dependency and only reference the binaries from the main project in such a way that when I chose a specific platform/configuration the correct reference will be used to build. 现在,我想删除项目依赖项,并且只引用主项目中的二进制文件,这样当我选择特定平台/配置时,将使用正确的引用来构建。

For example if I build for ARM/Release it should use the binaries from ./lib/ARM/Release/MyLibrary.winmd and if I build for x86/Debug it should use the binaries from ./lib/x86/Debug/MyLibrary.winmd. 例如,如果我为ARM/Release构建它应该使用./lib/ARM/Release/MyLibrary.winmd的二进制文件,如果我为x86/Debug构建,它应该使用./lib/x86/Debug/MyLibrary.winmd.的二进制文件./lib/x86/Debug/MyLibrary.winmd.

I tried multiple ways but still could not find a solution that works both for Visual Studio and msbuild. 我尝试了多种方法,但仍然找不到适用于Visual Studio和msbuild的解决方案。

I actually have it working making the hint path use Platsform and Configuration variables. 我实际上有它使提示路径使用Platsform和配置变量。

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

You might be able to use some macros dependent on your build selection in VS. 您可以在VS中使用一些依赖于构建选择的宏。 Example the two macros found within the linker are as follows: 链接器中找到的两个宏的示例如下:

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

and depending on the configuration you selected it will build in either Debug / Release. 并且根据您选择的配置,它将在Debug / Release中构建。

Similar to what Pinco said. 与Pinco所说的相似。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM