简体   繁体   中英

Visual Studio project platform dependent references

I have a WP project for which I use a runtime module from a separate project.

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.

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.

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

I actually have it working making the hint path use Platsform and Configuration variables.

<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. 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.

Similar to what Pinco said.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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