Visual Studio项目平台依赖引用

时间:2021-11-16 17:03:36

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 (e.g.: 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。

I tried multiple ways but still could not find a solution that works both for Visual Studio and msbuild.

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

2 个解决方案

#1


3  

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>

#2


0  

You might be able to use some macros dependent on your build selection in VS. Example the two macros found within the linker are as follows:

您可以在VS中使用一些依赖于构建选择的宏。链接器中找到的两个宏的示例如下:

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

$(ProcessorArchitecture)我的例子= x86 $(ProcessorArchitectureAsPlatform),对我来说= Win32

and depending on the configuration you selected it will build in either Debug / Release.

根据您选择的配置,它将在Debug / Release中构建。

Similar to what Pinco said.

与Pinco所说的相似。

#1


3  

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>

#2


0  

You might be able to use some macros dependent on your build selection in VS. Example the two macros found within the linker are as follows:

您可以在VS中使用一些依赖于构建选择的宏。链接器中找到的两个宏的示例如下:

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

$(ProcessorArchitecture)我的例子= x86 $(ProcessorArchitectureAsPlatform),对我来说= Win32

and depending on the configuration you selected it will build in either Debug / Release.

根据您选择的配置,它将在Debug / Release中构建。

Similar to what Pinco said.

与Pinco所说的相似。