Power Platform: App Maker Challenge, deel 28

Ingediend door Dirk Hornstra op 11-jun-2022 21:16

Het achtentwintigste deel, verwachte tijd: 40 minuten. En dan hebben we alle modules gehad!
Dit deel gaat over het aanpassen van broncode van een canvas app.

Als je een canvas app in Microsoft Power Apps Studio opent, zie je een visuele weergave.
Je kunt een kopie van je app opslaan, dit wordt dan in een bestand gezet met extensie .msapp
Als de canvas app onderdeel uitmaakt van een Microsoft Dataverse oplossing, dan kun je de Microsoft Power Platform CLI (link) gebruiken.

Met het unpack commando van Power Platform CLI kun je alle ingepakte bestanden uitpakken. En dan kun je de meeste bestanden openen in bijvoorbeeld Visual Studio Code.

Hiermee kun je:

  • Zelf de broncode snel aanpassen.
  • Bepaalde (of alle) bestanden in versiebeheer opslaan om te zorgen dat dit geborgd is.
  • Geautomatiseerde tools gebruiken om je code te valideren, controleren.


Documentatie over Power Platform CLI kun je hier nalezen: link. Directe link voor de CLI: link.

Controleer na installatie altijd of je de up-to-date versie hebt met:


pac install latest

Uitpakken van een canvas-app kan met:


pac canvas unpack --msapp "Account Manager.msapp" -- sources src

En natuurlijk wil je zaken ook weer "in kunnen pakken", dat doe je met:


pac canvas pack --msapp "Account Manager.msapp" -- sources src


Soms heb je in een solution meerdere .msapp bestanden. Uitpakken kan dan met:


pac solution unpack --solution-zip c:\samplesolution.zip --folder .\SampleSolutionUnpacked\.

En ook hier kun je de boel weer inpakken:


pac solution pack --solution-zip c:\samplesolution.zip --folder .\SampleSolutionUnpacked\.


Source control wordt nog even genoemd als "application lifecycle management (ALM)": link.

Hierna volgt een oefening. Je gaat naar de Power Apps Maker portal en kiest daar voor Home, Dataverse.
Je maakt een nieuwe connectie en slaat het resultaat op, op jouw computer.
Hierna ga je naar Visual Studio Code. Bij de Extensies kies je voor Power Platform.
Hierna unpack je jouw .msapp-applicatie en open je die map in VS Code.

Je ziet daar heel veel YAML bestanden. Daarin wordt de opmaak van de controls gedefinieerd.

  • Controls worden ingesteld met: LblAppName1 As label:
  • Alle formules starten met het = teken, net als Excel dus.
  • Sommige formules moeten in YAML multi-line syntax ingesteld worden. Als je een formule hebt met een # dan denkt YAML dat het start van commentaar is. Om dit te voorkomenen gebruik je de multi-line syntax, vaak met gebruik van het pipe-teken: | meer info staat hier: link.


Structuur:

\src   The control and component files. This file contains the sources.
*.fx.yaml   The formulas that are extracted from the control.json file. This place is where you can edit your formulas.
CanvasManifest.json   A manifest file that contains what is normally in the header, properties, and publishInfo.
*.json   The raw control.json file.
\EditorState*.editorstate.json   Cached information for Power Apps Studio to use.
\DataSources   All data sources that are used by the app.
\Connections   Connection instances that are saved with this app and used when you are reloading into Power Apps Studio.
\Assets   Media files that are embedded in the app.
\pkgs   A downloaded copy of external references, such as templates, API Definition files, and component libraries. These files are similar to nuget/npm references.
\other   All miscellaneous files that are needed for re-creating the .msapp file.
entropy.json   Volatile elements (like timestamps) are extracted to this file. This file helps reduce noisy diffs in other files while ensuring that you can still round-trip. Holds other files from the .msapp file, such as what is in \references.


Hier kun je nog wat informatie vinden over "merge-conflicten", als meerdere developers dezelfde code aanpassen: link.
 

Hierna volgen nog een aantal voorbeelden van wijzigingen en koppelingen met source-control (oa. Github).