Unmanaged DLL in desktop bridge app

Heiko 1,261 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.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,784 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,193 questions
Not Monitored
Not Monitored
Tag not monitored by Microsoft.
39,708 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 31,246 Reputation points Microsoft Vendor
    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.