Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include architecture specific files in UWP application package

I'm using 3rd party .NET library that is essentially a wrapper over c++ library. This library is not NuGet package. I have only the C++ libraries for different architectures (ARM, x86, x64) and the managed library.

I have referenced the managed library in my project, and I have created Post-build event that copies the correct C++ library to the build directory:

xcopy /Y "$(ProjectDir)ExternalReferences\NoesisGUI\uwp_$(Platform)*.*" "$(TargetDir)"

The problem I have is that this C++ library is not copied to the AppX folder when deploying, so I get System.DllNotFoundException .

What is the correct way to include architecture specific files in the application package?

This is the project folder structure with C++ libraries:

Project folder structure with C++ libraries

like image 356
Kenshin Avatar asked Feb 09 '26 19:02

Kenshin


1 Answers

There's no need for scripting, it's easier to just add those as Content of the project.

First, move your ExternalReferences folder outside of the project. The parent folder (which by default is where you have the .sln file) should do fine.

Manually edit your .csproj file and add the following before the ending </Project> tag:

<ItemGroup>
  <Content Include="..\ExternalReferences\NoesisGUI\uwp_$(Platform)\Noesis.dll">
    <Link>Noesis.dll</Link>
  </Content>
</ItemGroup>

This will include the Noesis.dll file in the project taking into account the platform it is currently being built for.

Note: above I used "..\" to use the parent folder, make sure to change this if you moved the folder somewhere else!

like image 108
Pedro Lamas Avatar answered Feb 12 '26 13:02

Pedro Lamas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!