microsoft-ui-xaml
microsoft-ui-xaml copied to clipboard
Is it possible to add a dll project to a WinUI 3 C++ Packaged solution ?
Hello,
I had already created an issue on this in early August but I did not see a change although "Production-Ready" Windows App SDK 1.0 is now available.
So I am asking the question: Did I miss something in my scenario or is there a real problem ???
Win 11 Home as Of : 11/23/2021 Windows 11 Version 10.0.2000 Build 22000 Visual Studio 2019 16.11.7 SDK 1.0
- Create a - Blank App, Packaged With Windows Application Packaging Project (WinUI 3 in Desktop) - C++
- Add a Desktop DLL project to the solution
- Add DLL as reference to the Desktop project
- In App.xaml.cpp of Desktop project, add a call to any DLL entry
- Build Solution: Everything is fine
- Run Package: Failure with error message: "DLL xxx cannot be found"
I can see the dll under the desktop project /references I can see the dll under the package project/dependencies/desktop project
A way to make it work is to manually copy dlls to: App (Package)/bin/x64/Release/AppX
Hi @jeromebjerome,
For my C++ WinUI Application Packaging Project I use the following fragments in the *.wapproj XML
<ItemGroup>
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="examples\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="myDllWithPath.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
The wildcards do not work well with sources from different folder levels. Thus, for dlls from different projects I use non-wildcard definitions. Use PreserveNewest
or Always
as you prefer. With the above definition, the DLLs should end up in the AppX folder. It also works correctly if the package gets installed.
@llongley FYI
@StephenLPeters Is there a better solution than the Content
"hack"?
@StephenLPeters Is there a better solution than the
Content
"hack"?
is this a hack? It's just updating the project file, isn't it?
A workaround I found is to right click on the project -> Add existing item -> add your dll, then change the Content
in file properties to True
, like this
.
I did this to package a COM dll that extend the right click context menu of Windows 11. Only adding a project reference will NOT package the dll into the msix in this case.
This however, feels extremely trickery, and should be improved.
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.