Creating Optional package without Visual Studio

%3CLINGO-SUB%20id%3D%22lingo-sub-283360%22%20slang%3D%22en-US%22%3ECreating%20Optional%20package%20without%20Visual%20Studio%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-283360%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20documentation%20and%20sample%20for%20creating%20optional%20packages%20uses%20Visual%20Studio.%26nbsp%3B%20Can%20Optional%20packages%20be%20created%20without%20Visual%20Studio%2C%20similar%20to%20creating%20a%20bundle%20using%20makeappx%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Fpackaging%2Foptional-packages-with-executable-code%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Fpackaging%2Foptional-packages-with-executable-code%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-284241%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20Optional%20package%20without%20Visual%20Studio%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-284241%22%20slang%3D%22en-US%22%3E%3CP%3EYes%20you%20should%20be%20using%20LoadPackagedLibrary%2C%20and%20statically%20linked%20delay%20loaded%20dlls%20should%20work%20the%20same%20way%20that%20they%20do%20for%20a%20main%20package.%20Let%20me%20know%20if%20you're%20having%20any%20issues%20with%20these.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-283719%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20Optional%20package%20without%20Visual%20Studio%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-283719%22%20slang%3D%22en-US%22%3E%3CP%3EYes%2C%20the%20Win32%20exe%20is%20also%20packaged.%26nbsp%3B%20Does%20this%20mean%20I%20have%20to%26nbsp%3Bchange%20all%20instances%20of%20LoadLibrary%20to%20LoadPackagedLibrary%3F%26nbsp%3B%20How%20do%20I%20handle%20statically%20linked%20delay%20loaded%20dlls%20that%20are%20optionally%20installed%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-283715%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20Optional%20package%20without%20Visual%20Studio%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-283715%22%20slang%3D%22en-US%22%3E%3CP%3EIs%20your%20Win32%20exe%20also%20packaged%3F%20If%20it%20is%20then%20yes%20this%20is%20possible%20with%20related%20set%2C%20your%20main%20app%20can%20use%20LoadPackagedLibrary%20to%20load%20the%20dlls%20in%20an%20optional%20package%20(main%20apps%20and%20optional%20packages%20are%20deployed%20to%20separate%20directories%2C%20but%20LoadPackagedLibrary%20should%20be%20able%20to%20find%20the%20dlls%20for%20you).%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20your%20Win32%20exe%20is%20not%20packaged%2C%20then%20optional%20packages%20won't%20work%20for%20you.%20Optional%20packages%20are%20not%20designed%20to%20be%20used%20stand-alone%20with%20an%20unpackaged%20Win32%20app.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-283708%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20Optional%20package%20without%20Visual%20Studio%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-283708%22%20slang%3D%22en-US%22%3E%3CP%3EMaybe%20I'm%20misunderstanding%20the%20purpose%20of%26nbsp%3BOptional%20Packages%20and%20Related%20sets.%26nbsp%3B%20I%20have%20a%20Win32%20exe%20that%20can%20use%26nbsp%3Boptional%20dlls%2C%20which%20are%20distributed%20separately%20from%20the%20exe.%26nbsp%3B%20The%20files%20need%20to%20be%20in%20the%20same%20folder%20as%20the%20main%20application%20(so%20LoadLibrary%20can%20find%20the%20files).%26nbsp%3B%20Is%20this%20possible%20with%20an%20Optional%20Package%20or%20Related%20Set%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-283591%22%20slang%3D%22en-US%22%3ERe%3A%20Creating%20Optional%20package%20without%20Visual%20Studio%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-283591%22%20slang%3D%22en-US%22%3E%3CP%3EYes%20optional%20packages%20can%20be%20created%20with%20MakeAppx%20directly.%20I%20recommend%20you%20to%20take%20a%20look%20at%20the%20packaging%20layout%20(used%20with%20MakeAppx)%20that%20can%20help%20you%20create%20your%20main%20package%20and%20optional%20packages%20easily%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Fpackaging%2Fpackaging-layout%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fuwp%2Fpackaging%2Fpackaging-layout%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EAre%20you%20looking%20to%20create%20optional%20packages%20that%20only%20contain%20assets%20or%20would%20they%20contain%20code%20to%20be%20loaded%20by%20the%20main%20package%20(ie%20a%20related%20set)%3F%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20it's%20the%20latter%2C%20then%20all%20you%20need%20to%20do%20is%20provide%20an%20appropriately%20specified%20AppxManifest.xml%20to%20the%20ManifestPath%20of%20your%20optional%20package%20in%20the%20packaging%20layout.%20Take%20a%20look%20at%20steps%203%20and%204%20of%20this%20blog%20post%20for%20how%20to%20mark%20a%20manifest%20for%20an%20optional%20package%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fblogs.msdn.microsoft.com%2Fappinstaller%2F2017%2F05%2F09%2Fbuild-your-first-optional-package%2F%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fblogs.msdn.microsoft.com%2Fappinstaller%2F2017%2F05%2F09%2Fbuild-your-first-optional-package%2F%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EIf%20it's%20the%20former%2C%20then%20in%20addition%20to%20the%20steps%20above%2C%20you%20should%20set%20the%20%22RelatedSet%22%20attribute%20of%20your%20optional%20package%20to%20be%20%22false%22%20in%20the%20packaging%20layout.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

The documentation and sample for creating optional packages uses Visual Studio.  Can Optional packages be created without Visual Studio, similar to creating a bundle using makeappx?

 

https://docs.microsoft.com/en-us/windows/uwp/packaging/optional-packages-with-executable-code

 

5 Replies
Highlighted

Yes optional packages can be created with MakeAppx directly. I recommend you to take a look at the packaging layout (used with MakeAppx) that can help you create your main package and optional packages easily: https://docs.microsoft.com/en-us/windows/uwp/packaging/packaging-layout

Are you looking to create optional packages that only contain assets or would they contain code to be loaded by the main package (ie a related set)? 

If it's the latter, then all you need to do is provide an appropriately specified AppxManifest.xml to the ManifestPath of your optional package in the packaging layout. Take a look at steps 3 and 4 of this blog post for how to mark a manifest for an optional package: https://blogs.msdn.microsoft.com/appinstaller/2017/05/09/build-your-first-optional-package/

If it's the former, then in addition to the steps above, you should set the "RelatedSet" attribute of your optional package to be "false" in the packaging layout. 

 

Highlighted

Maybe I'm misunderstanding the purpose of Optional Packages and Related sets.  I have a Win32 exe that can use optional dlls, which are distributed separately from the exe.  The files need to be in the same folder as the main application (so LoadLibrary can find the files).  Is this possible with an Optional Package or Related Set?

Highlighted

Is your Win32 exe also packaged? If it is then yes this is possible with related set, your main app can use LoadPackagedLibrary to load the dlls in an optional package (main apps and optional packages are deployed to separate directories, but LoadPackagedLibrary should be able to find the dlls for you). 

If your Win32 exe is not packaged, then optional packages won't work for you. Optional packages are not designed to be used stand-alone with an unpackaged Win32 app. 

Highlighted

Yes, the Win32 exe is also packaged.  Does this mean I have to change all instances of LoadLibrary to LoadPackagedLibrary?  How do I handle statically linked delay loaded dlls that are optionally installed?

Highlighted

Yes you should be using LoadPackagedLibrary, and statically linked delay loaded dlls should work the same way that they do for a main package. Let me know if you're having any issues with these.