Part 5 – Build, Test and Deploy your Power Apps Custom Control

The article is a part of series of blog posts on Custom component framework topic. In order to get the context I would suggest to get started from beginning.

Now that we have developed our control in the previous article it’s time to build, test and deploy.

The first is to build your component. To build you need to open Visual Studio 2017 developer command prompt and navigate to folder where your code file is there (index.ts).

In my case it is c:\Debajit\Blog\PowerControls\FileControl

image

Once in the directory, run the command “npm run build”

image

As you can see, Build is successful. Now it’s time to test whether your control is rendering correctly before we deploy it to CRM.

Just type “npm start” in command line. It will launch IE process and show you. As you can see from screenshots my file control with submit button is rendered successfully. Look’s ugly but works just fine.

image

image

So build successful and tested as well. Now we need to put in CRM. But how?

The first thing we need is to create a solution file (zip archive) and bundle our custom component inside that solution. Before I do that, I create a new folder called “Deployment” inside my “PowerControls” folder and navigate to that folder from Visual studio command prompt. In my case the full path is “C:\debajit\blog\powercontrols\deplpoyment”.

I then run the below command

pac solution init --publisherName <enter your publisher name> --customizationPrefix <enter your publisher name>

Here in publisher name I put – “xrmforyoucontrols” and in customizationPrefix I put – x4uctrl. So my command line is

pac solution init --publisherName xrmforyoucontrols --customizationPrefix x4uctrl. Basically it creates a publisher with the specified customization prefix.

You will get notified in the console that deployment is successful.

image

The next step is to add our custom control reference. To do this run the below command.

pac solution add-reference --path <path or relative path of your PowerApps component framework project on disk>

Please note here that the path is till the directory where your component directory resides. My component directory is “FileControl” and is within C:\Debajit\Blog\PowerControls

image

To generate the solution zip file, the final step is to run first – “msbuild /t:restore” and then once that is completed, run “msbuild”

MSBUILD /t:restore

image

MSBUILD

image

And finally when I open my deployment folder, I could see bin folder. Navigate inside bin\debug and you would find your solution file.

image

Import the solution file into your environment and publish all customizations.

The final step is using the control in CRM which is covered in the next article.

Advertisements

14 thoughts on “Part 5 – Build, Test and Deploy your Power Apps Custom Control

  1. Hello Debajit, amazing job! really!

    But, I got stuck up in the step when you have to write the “add reference” command in order to add reference to solution. My script looks like “pac solution add reference –path “My path”” But not successfully. It says me, that is not a valid command. However, I tried to build without the previous step, and don’t get the “ZIP” file as an outcome.

  2. Please ignore my last comment as I managed to resolve the issue.

    The issue was due to the space in the Folder Name CRMKNOWHOW BLOG instead of CRMKNOWHOWBLOG.

    Thanks for sharing the detailed information (Step-by-Step) on PCC.

  3. Hi Debajit. I’m kinda stuck. I did a timer control using pcf and it run fines locally. If I take the solution to D365 and adding this custom control to a text field, nothing shows up. Can you please help me out?

    1. Hi Arthur..thanks for reading my blog..I guess it was –publisherName (two hypens) only last time i developed. If you see the screenshot below the command, it is working. Didnt check with the latest version though.

      Cheers!
      Debajit

  4. I keep getting this error in the last command – ‘msbuild’ is not recognized as an internal or external command,
    operable program or batch file.

  5. hi Debajit,
    Yes I am using VS command prompt, I have had to set the path of my MSbuild in the VS command prompt, but now getting this error- Deployment.cdsproj(25,70): error MSB4066: The attribute “Ve
    rsion” in element is unrecognized. Build Failed.

  6. hi,
    I am getting all sorts of errors, which you never mentioned. And finding solutions to command line errors is almost close to impossible, as the erros are all vague and can relate to almost every application out there. currently getting this error now – “C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.tar
    gets(114,5): warning : The plugin credential provider could not acquire credentials. Authentication may require manual
    action. Consider re-running the command with –interactive for `dotnet`, /p:NuGetInteractive=”true” for MSBuild or remo
    ving the -NonInteractive switch for `NuGet`.”

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