Download all Microsoft Dynamics 365 Business Central Source Code with PowerShell

You might wonder: why would I need this? Why would I need to download source code of Business Central, while I can simply access it through the symbols when I’m working in VSCode – or even better, while I can simply click the symbol, and look at the code from there?
Well …

Searchability

Didn’t you ever wonder: “hey, previous version, this codeunit was still in this app – where is it now”? Or something in the line of: “Where can I find an example of a test-codeunit where they create and post picks”? In the old days, it was easy to get to the source code. It was simply an “export all”. These days – Microsoft’s source code is spread over a multitude of apps. Either as “Application” or as “platform” .. It doesn’t really matter.
Sometimes, it’s just very useful to simply be able to search trough every single letter of source code Microsoft has released as part of a certain version of Business Central. So …

PowerShell to the rescue! 😉

I wrote a little script:

As you can see, I’m using BcContainerHelper to simply:

  • Download the artifacts and its platform
  • For each “.source.zip”-file, I’ll unpack it in a decent destination directory

You can apply “filters” or “excludes” when you’re for example only interested in a portion of the apps – just to speed up the process.

When done, you’ll have a directory (that you configured in the variable “$Destination“). Simply open the required version in VSCode, and you’ll be able to search all files.

As you see in the first line of the script .. you can indicate the exact version of BC by providing the right parameters in the “Get-BCArtifactUrl” CmdLet. More info here: Working with artifacts | Freddys blog
May be one interesting example, you can also do something like this:

To get all Test-apps from the be, nl and w1 localization.

Now – this is just the tip of the iceberg of something that someone else in the community is working on (Stefan Maroń) – which is currently in approval state at Microsoft. Nothing to share just yet – but fingers crossed it’s going to get approved, and let the above just be a completely wasted internet space!

Meanwhile – enjoy!

5.00 avg. rating (98% score) - 4 votes

Permanent link to this article: https://www.waldo.be/2020/12/16/download-all-microsoft-dynamics-365-business-central-source-code-with-powershell/

6 comments

4 pings

Skip to comment form

  1. Hey waldo, any tips on how to include all, really all, test apps? You have to know that C:\bcartifacts.cache\onprem\17.2.19367.19735\platform\Applications\testframework\TestLibraries also contains test related code

      • waldo on January 4, 2021 at 8:46 pm
        Author

      The script will extract both platform as localized code .. so you will have all, no? Am I missing something?

    1. Yep, I did forget ‘only’: any tips on how to include only all, really only all, test apps?

    2. To your example with $filter = ‘Test’ you state “To get all Test-apps from the be, nl and w1 localization, but is does not get all test related .apps as C:\bcartifacts.cache\onprem\17.2.19367.19735\platform\Applications\testframework\TestLibraries contains test libraries that do not have the word Test in the .app filename.

      • waldo on January 5, 2021 at 5:28 pm
        Author

      Hm, ok .. well .. I guess that’s the never-ending problem with the naming inconsistency with anything Microsoft :(. I have been struggling with that with anything where you rely on naming conventions :(.

      If you have a generic way to get to “all” test apps – let me know. I’ll script it ;-).

    • Guido Robben on February 16, 2021 at 11:37 am
    • Reply

    thanks, I rebuild it to use the DVD

  1. […] Download all Microsoft Dynamics 365 Business Central Source Code with PowerShell […]

  2. […] Source: Download all Microsoft Dynamics 365 Business Central Source Code with PowerShell […]

  3. […] Source : Waldo’s Blog Read more… […]

  4. […] relatively easy to instantly get these files in place. I have been using waldo's script to download all Microsoft Dynamics 365 Business Central source code with PowerShell a lot lately. In no time you have a local copy the source you […]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.