Unmanaged DLL in desktop bridge app

Heiko 1,291 Reputation points
2023-05-05T13:55:39.0733333+00:00

I have a WPF desktop bridge application. In this solution I have a C# project and a project for an unmanaged C++ dll. I manually added the dll project as a reference to the C# project by editing the csproj file. When building the whole solution, the created dll is then copied to the output directory of the C# project. But unfortunately this dll is not copied to the output directory of the package project:

MySolution\MyPackageProject\bin\x64\Debug\AppX\MySolution.

So when I start the application (MyPackageProject is the startup project), the DLL cannot be loaded because it is not found.

Is there any way to get the dll copied to the package output directory? I want to publish the application later and want to be sure that the dll is included in the msixupload file.

Developer technologies | Windows Presentation Foundation
Developer technologies | Visual Studio | Other
Community Center | Not monitored
0 comments No comments
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 34,456 Reputation points Microsoft External Staff
    2023-05-08T07:35:24.0433333+00:00

    Hello @Heiko,

    Welcome to Microsoft Q&A forum.

    You can try to custom a Target in .csproj file like following to copy the file to destination folder automatically after building this project.

    <Target Name="CopyFiles" AfterTargets="Build">
    	<Copy 
    		SourceFiles="XXXX\XXXX\xxxx.dll" 
    		DestinationFolder="XXXX\XXXX" 
    	/>
    </Target>
    

    Document: Copy task

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.