PCF Solution Packaging: Unmanaged for Production (Release)

Usually I use React for my PCF components, and am I aware that there is a big difference between the debug and the production bundling, which can have a big performance impact. So I tried to be a good developer and deliver the right solution for production. But this time I needed an unmanaged solution, which cannot be generated with the default configuration.

Unfortunately I had some trouble to understand the documentation: https://docs.microsoft.com/en-us/powerapps/developer/component-framework/import-custom-controls. My bad. Fortunately the community forum provided right away an answer, so I could move on. Thank you Richard Wilson!

This blog is more or less a note to myself. Maybe helps somebody else too.

To generate a solution containing a PCF component you only need to use the “pac” CLI to generate a “Solution project” (cdsproj), and add a reference to the pcf project (pcfproj), then restore the project and you can build the solution. Maybe the only thing to keep in mind is that the name of the generated solution will be the name of the directory where the cdsproj is placed. Maybe it’s a good practice to let it always be named “Solution.zip” if you consider ALM, but maybe you’ll end up in chaos if every pcf solution is called “solution.zip”

pac solution init --publisher-name <PN> --publisher-prefix <pref>
pac solution add-reference --path <path to pcfproj>
msbuild /t:restore

You have now two possibilities

  • msbuild -> this will generate an unmanaged debug solution
  • msbuild /p:configuration=Release -> this will generate a managed release solution.

But you can modify the “.cdsproj” and specify the SolutionPackageType:

  • Managed
  • Unmanaged
  • Both – this will generate two solutions : managed and unmanaged

So, it’s possible to have all combinations using the cdsproj config and msbuild /p:configuration=Release command. I’ve checked the result and the size of my test solution (my pcf had react but not office-ui-fabric or other libraries).

cdsProj config ->DefaultManagedUnmanagedBoth
msbuild

Output: bin/Debug/
Size : 214 KB
Solution.zipSolution.zipSolution.zipSolution.zip
Solution_managed.zip
msbuild /p:configuration
=Release


Output: bin/Release/
Size: 47 KB
Solution.zip Solution.zip Solution.zipSolution.zip
Solution_managed.zip
  • orange are UNMANAGED solutions
  • purple are MANAGED solutions

Looking at the size of the solution I can tell how important it is to use the right bundling configuration for production.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑