Is there a way to take an existing .NET assembly, compiled to either x86 or x64, and create another assembly with the same API but compiled as AnyCPU? The new assembly will never actually be executed; it will only be used as a compile-time reference.
Background
I have a .NET assembly that was written in C++/CLI. I'm putting it into a nuget package, using nuget's runtimes
and ref
folders to handle the 32 vs 64 bit issue. Normally the assemblies in the ref
folder are compiled as AnyCPU, but that isn't an option for C++ assemblies. For now I've got a copy of the 32 bit version in the ref folder, but that causes a warning when included in an x64 project:
There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "c:...\myassembly.dll" "x86".
I realize this won't cause any problems at runtime, but I'd like to get rid of the warning if possible. If this were written in C# or VB I'd be able to use CorFlags to turn it into an AnyCPU assembly, but that trick doesn't work with C++ assemblies. When I set the ILONLY
flag on a 32 bit C++ assembly, Visual Studio is no longer able to load the assembly at all.
So can anyone suggest how to create a version of this assembly that would be suitable for use as a compile time reference in a nuget package?