{"id":12972,"date":"2021-01-14T17:00:40","date_gmt":"2021-01-15T01:00:40","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/source-code-files-for-canvas-apps\/"},"modified":"2025-06-11T07:55:58","modified_gmt":"2025-06-11T14:55:58","slug":"source-code-files-for-canvas-apps","status":"publish","type":"post","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-apps\/source-code-files-for-canvas-apps\/","title":{"rendered":"Source code files for Canvas apps"},"content":{"rendered":"
Imagine using GitHub with a Canvas app.\u00a0 And I mean using GitHub as it was meant to be used, with text diffs between versions, and not just storing opaque .msapp blobs.\u00a0 \u00a0Teams can collaborate on apps: they can work on private branches, diff changes, create pull requests for review, and merge into master.<\/p>\n
Imagine using Visual Studio Code with a Canvas app, a full screen editor with search and replace.<\/p>\n
We are very pleased to announce the experimental release of a tool that enables these modern miracles.\u00a0 It is but the first step as we make application lifecycle management easier for formulas and Canvas apps.<\/p>\n
To illustrate, in this short video we will change the Icon property of an Icon control with these steps:<\/p>\n
<\/p>\n
This new tool enables the source code of a Canvas app to be effectively managed in GitHub or Azure DevOps.\u00a0 Diffs, pull requests, and comments can be based on lines of formula text rather than .msapp blob files.<\/p>\n
In this next example, we’ll make the same change to the Canvas app stored in GitHub as text source code files.\u00a0 We’ll go through all the steps required to manage the change, have it reviewed, commented on, merged in to master, and the result tested.<\/p>\n
<\/p>\n
We’ll work with this GitHub repo in Visual Studio Code.\u00a0 First we’ll create a new branch, make modifications there (change the icon from “Person” to “People”), and push the changes to our new branch on GitHub.<\/p>\n
<\/p>\n
Back on GitHub, we’ll create a pull request for this new branch to merge into master.\u00a0 We’ll have an opportunity to review the one line change, to comment on the change, and to approve the merge.\u00a0 Canvas apps become a part of your existing application lifecycle management workflow.<\/p>\n
<\/p>\n
And after the merge has been made, we sync changes back to our client and recreate the .msapp file.\u00a0 We can now load the file into Power Apps Studio and see our change.<\/p>\n
<\/p>\n
Excited?\u00a0 These examples only scratches the surface of what is possible.\u00a0 By supporting text files, all the tools that you love and all the unique workflows that you have created can now be used with Canvas apps too.<\/p>\n
But before you get too excited, let’s reiterate that this is experimental.\u00a0 We are making this available now for your feedback and to find issues.<\/p>\n
Please do not convert all your .msapp files to source files and throw away the originals.\u00a0 We are working toward a day when you can do this, but that is not today.\u00a0 \u00a0By far, Power Apps Studio is still the best place to edit a Canvas app.\u00a0 We are introducing a new way to manage and edit Canvas apps, a companion to Studio, not a replacement.<\/p>\n
There are some known limitations and gotchas:<\/p>\n
So, how do you get the cool PASopa<\/strong> tool used above?\u00a0 \u00a0To download and use:<\/p>\n More details on building are available in the GitHub readme<\/a>.<\/p>\n I did say this was experimental. \ud83d\ude42 This isn’t going to be for everyone at this time and that is OK.\u00a0 At this early juncture we are looking for savvy early adopters that can give us good feedback on the directory structure and file format.\u00a0 Eventually we will be integrating this directly with the Power Apps CLI<\/a>\u00a0and it can be run by anyone without needing to do a build.\u00a0 PASopa is just a test harness that we are using in the meantime.<\/p>\n We are releasing this tool as open source, and that will still be true even after we integrate with the Power Apps CLI.\u00a0 We’d love your feedback and issue reports directly through GitHub.\u00a0 Eventually, we will also welcome your pull requests, but are limiting outside contributions until we are better established.<\/p>\n We adopted a subset of YAML as our file format.\u00a0 Our first priority was a format that was super easy to read and write by humans.\u00a0 But we also wanted something that could be embedded in other places within the Power Platform, and many of them use YAML already or are considering this move.\u00a0 \u00a0We wanted to leverage existing libraries and tools and not create something completely new.<\/p>\n There are three unique aspects to how we embed within YAML:<\/p>\n Full details on the file format are available in docs included in the GitHub repo<\/a>.<\/p>\n Note that we support only a very specific subset of YAML.\u00a0 Properties with static values, such as trying to set Size: 24<\/strong>\u00a0(without a leading =<\/strong>) won’t work.\u00a0 We also deliberately avoided YAML line comments that start with a\u00a0#<\/strong> because of the confusion they can cause.\u00a0 \u00a0Over time and based on your feedback we may support more YAML, but for now, it is very restrictive and that is by design.<\/p>\n Here is a simple example form the Hospital Emergency Response solution<\/a> we shipped last spring.\u00a0 Note that as with all YAML, the indentation level indicates what is inside a container (SplashScreen<\/strong> in this case) and is also used for line continuation of the OnHidden<\/strong> property.<\/p>\n Not everything gets the YAML treatment.\u00a0 There are a number of app resources and settings that retain their original not-meant-for-humans treatment and are not intended to be edited outside of Power Apps Studio.\u00a0 The full directory structure and how to deal with merge conflicts in other files is outlined in the GitHub readme<\/a>.<\/p>\n For the simple one Icon control app that started this blog post, let’s walk through the files we find after PASopa -unpack<\/strong> has done it’s work.<\/p>\n First, let’s look at the files that are the most critical, that truly define the app.\u00a0 These should never be deleted and merges should be handled as you normally would in GitHub:<\/p>\n Next comes files that are boiler plate, copied in when the app was created.\u00a0 Normally these will not change.\u00a0 If the Theme of the app is changed, the entire file will be swapped out.<\/span><\/p>\n Power Apps Studio maintains state between sessions, so you can get back to where you were\u00a0 \u00a0These can be deleted at any time and are not a concern for merge conflicts.<\/p>\n And finally, there are a set of files that the\u00a0PASopa\u00a0<\/strong>tool uses to ensure proper roundtripping of an app between .msapp and source files.\u00a0 It is safe to keep the latest version of these files if there is a merge conflict.<\/p>\n We are experimental.\u00a0 Have I mentioned that yet? \ud83d\ude42 Now is the time to let us know what you think, now is the time to make any needed changes.\u00a0 Please use GitHub issues<\/a> to the fullest, for comments, questions, actual issues, and any other feedback you may have.<\/p>\n \u00a0<\/p>\n \u00a0<\/p>\n","protected":false},"excerpt":{"rendered":" Imagine using GitHub and Visual Studio Code with the text formulas of a Canvas app.\u00a0 Teams can collaborate on apps: they can work on private branches, diff changes, create pull requests for review, and merge into master. We are very pleased to announce the experimental release of a tool that enables these modern miracles.\u00a0 It is but the first step as we make application lifecycle management easier for formulas and Canvas apps.<\/p>\n","protected":false},"author":86,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ms_queue_id":[],"ep_exclude_from_search":false,"_classifai_error":"","_classifai_text_to_speech_error":"","_alt_title":"","ms-ems-related-posts":[],"footnotes":""},"audience":[3378],"content-type":[3424],"job-role":[],"product":[3473],"property":[],"topic":[3421,3422],"coauthors":[2104],"class_list":["post-12972","post","type-post","status-publish","format-standard","hentry","audience-it-professional","content-type-news","product-power-apps","topic-application-modernization","topic-hyperautomation"],"yoast_head":"\n\n
YAML File Format<\/h2>\n
\n
SplashScreen\u00a0As\u00a0screen:\n\u00a0\u00a0\u00a0\u00a0Width:\u00a0=Max(App.Width,\u00a0App.DesignWidth)\n\u00a0\u00a0\u00a0\u00a0Height:\u00a0=Max(App.Height,\u00a0App.DesignHeight)\n\u00a0\u00a0\u00a0\u00a0Size:\u00a0=1\u00a0+\u00a0CountRows(App.SizeBreakpoints)\u00a0-\u00a0CountIf(App.SizeBreakpoints,\u00a0Value\u00a0>=\u00a0SplashScreen.Width)\n\u00a0\u00a0\u00a0\u00a0Orientation:\u00a0=If(SplashScreen.Width\u00a0<\u00a0SplashScreen.Height,\u00a0Layout.Vertical,\u00a0Layout.Horizontal)\n\u00a0\u00a0\u00a0\u00a0OnHidden:\u00a0|-\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0=\/\/Check\u00a0to\u00a0see\u00a0if\u00a0this\u00a0is\u00a0a\u00a0mobile\u00a0device\u00a0if\u00a0so,\u00a0then\u00a0save\u00a0data\u00a0for\u00a0all\u00a0other\u00a0apps\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/Notify(\"Trying\u00a0Save\",NotificationType.Information);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0If(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Value(AltCheck_Lbl_1.Text)\u00a0>\u00a00,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0SaveData(\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0MySplashSelectionsCollection,\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"MySplashSelections\"\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0);\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\/\/Notify(\"Did\u00a0Save\",NotificationType.Information);\u00a0\u00a0\u00a0\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0);\n\u00a0\u00a0\u00a0\u00a0OnVisible:\u00a0=Refresh(Systems);Refresh(Regions);\n\n\u00a0\u00a0\u00a0\u00a0Splash_Main_Icon\u00a0As\u00a0image:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Image:\u00a0=SplashIcon\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ZIndex:\u00a0=1\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0HoverFill:\u00a0=ColorFade(Splash_Main_Icon.Fill,\u00a020%)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0PressedFill:\u00a0=ColorFade(Splash_Main_Icon.Fill,\u00a0-20%)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Height:\u00a0=499\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Width:\u00a0=638\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0FocusedBorderColor:\u00a0=Splash_Main_Icon.BorderColor\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0HoverBorderColor:\u00a0=ColorFade(Splash_Main_Icon.BorderColor,\u00a020%)\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0PressedBorderColor:\u00a0=ColorFade(Splash_Main_Icon.BorderColor,\u00a0-20%)<\/pre>\n<\/div>\n<\/div>\n
Directory Structure<\/h2>\n
\n
Screen1\u00a0As\u00a0screen:\n\n\u00a0\u00a0\u00a0\u00a0Icon1\u00a0As\u00a0icon.Person:\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Icon:\u00a0=Icon.People\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Width:\u00a0=1366\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Height:\u00a0=768\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ZIndex:\u00a0=1<\/pre>\n<\/div>\n
\n
\n
\n
\n
Feedback<\/h2>\n