I have a solution with two projects, one is a C# WinUI3 project which uses a native code DLL in the other project via interop. My DLL itself requires some other DLLs which are provided by vcpkg.
How to I set up the solution/project files in VS2022 so that the DLL part is built first and then everything copied into the required place for the WinUI part?
At the moment I've got a .targets file like this
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="CopyDLLBinaries" BeforeTargets="GetCopyToOutputDirectoryItems">
<ItemGroup>
<PackageDLLBinaries Include="$(SolutionDir)$(Platform)\$(Configuration)\*.dll" />
</ItemGroup>
<Copy SourceFiles="@(PackageDLLBinaries)"
DestinationFolder="$(OutputPath)AppX"
SkipUnchangedFiles="true"
OverwriteReadOnlyFiles="true"
/>
</Target>
</Project>
but this seems unreliable; if I clean the project or change anything in the DLL project I might need to build the solution several times until it works in the debugger. Building the DLL seems reliable, as does building the WinUI exe but I find that the AppX final output directory sometimes is missing the DLLs that should be copied in there.
Is there an approved way to do this, it seems like it would be a common-ish requirement?