1- #
2- # Script for creating local development environment
3- # Please do not modify this script as it will be auto-updated from the AL-Go Template
4- # Recommended approach is to use as is or add a script (freddyk-devenv.ps1), which calls this script with the user specific parameters
5- #
1+ <#
2+ . SYNOPSIS
3+ Creates a local development environment for Business Central AL development using Docker containers.
4+
5+ . DESCRIPTION
6+ This script sets up a local development environment by:
7+ - Creating a Business Central container using Docker
8+ - Compiling and publishing all apps and test apps to the development scope
9+ - Configuring launch.json for Visual Studio Code with Local Sandbox configuration
10+ - Optionally applying custom settings to override repository settings
11+
12+ The script requires Docker to be installed and configured to run Windows containers.
13+ If Docker setup fails, users can alternatively run cloudDevEnv.ps1 for cloud-based development.
14+
15+ RECOMMENDED USAGE:
16+ Instead of modifying this script directly (which will be overwritten during AL-Go updates),
17+ create a custom script that calls this one with your preferred parameters. For example,
18+ create a file named after yourself (e.g., 'john-devenv.ps1') that contains:
19+
20+ # My personal development environment script
21+ $mySettings = '{"country":"us","artifact":"////nextminor"}'
22+ . .\.AL-Go\localDevEnv.ps1 -containerName "mydevenv" -auth UserPassword -customSettings $mySettings
23+
24+ This approach allows you to:
25+ - Maintain your personal preferences without losing them during updates
26+ - Share your setup with team members
27+ - Version control your custom development configurations
28+ - Easily switch between different development scenarios
29+
30+ . PARAMETER containerName
31+ The name of the Docker container to create. If not specified, the script will prompt for input.
32+ Default prompts for "bcserver" if not provided.
33+
34+ . PARAMETER auth
35+ Authentication mechanism for the container. Valid values are "UserPassword" or "Windows".
36+ If not specified, the script will prompt the user to select the authentication method.
37+
38+ . PARAMETER credential
39+ PSCredential object containing username and password for container authentication.
40+ If not provided, the script will prompt for credentials based on the selected auth method.
41+
42+ . PARAMETER licenseFileUrl
43+ Local path or secure download URL to a Business Central license file.
44+ For AppSource apps targeting BC versions prior to 22, a developer license with object ID permissions is required.
45+ For PTEs, this is optional but can be useful for dependent app object IDs.
46+ Set to "none" to skip license file input.
47+
48+ . PARAMETER fromVSCode
49+ Switch parameter indicating the script is being run from Visual Studio Code.
50+ When specified, the script will pause at the end waiting for user input before closing.
51+
52+ . PARAMETER accept_insiderEula
53+ Switch parameter to automatically accept the insider EULA when using Business Central insider builds.
54+ Required when working with insider artifacts.
55+
56+ . PARAMETER clean
57+ Switch parameter to create a clean development environment without compiling and publishing apps.
58+ Useful for setting up a fresh container without deploying any applications.
59+
60+ . PARAMETER customSettings
61+ JSON string containing custom settings that override repository settings.
62+ These settings have the highest precedence and can be used to override artifact URLs,
63+ country settings, or other configuration without modifying repository files.
64+
65+ . EXAMPLE
66+ .\localDevEnv.ps1
67+ Runs the script interactively, prompting for all required parameters.
68+
69+ . EXAMPLE
70+ .\localDevEnv.ps1 -containerName "mydevenv" -auth "UserPassword"
71+ Creates a container named "mydevenv" with username/password authentication, prompting for credentials and LicenseFile.
72+
73+ . EXAMPLE
74+ .\localDevEnv.ps1 -clean
75+ Creates a clean development environment without compiling and publishing apps.
76+
77+ . EXAMPLE
78+ .\localDevEnv.ps1 -customSettings '{"country":"dk","artifact":"////nextminor"}'
79+ Creates a development environment with custom settings for Denmark country and specific artifact.
80+
81+ . EXAMPLE
82+ # Programmatic setup with credentials and custom settings
83+ $Username = "SUPER"
84+ $Password = "<some password>"
85+ $cred = New-Object System.Management.Automation.PSCredential ($Username, (ConvertTo-SecureString $Password -AsPlainText -Force))
86+ $containerName = "bcserver"
87+ $settings = '{"artifact": "////nextminor"}'
88+
89+ . ./localDevEnv.ps1 -containerName $containerName -auth UserPassword -credential $cred -accept_insiderEula -licenseFileUrl "none" -customSettings $settings
90+
91+ Creates a development environment with predefined credentials, using next minor version artifact, accepting insider EULA, and no license file.
92+
93+ . NOTES
94+ - Requires Docker Desktop to be installed and running with Windows container support
95+ - For AppSource apps, may require a developer license for BC versions prior to 22
96+ - Script automatically downloads required AL-Go helper modules and actions
97+ - Modifies launch.json in VS Code workspace for Local Sandbox configuration
98+ - Custom settings parameter allows runtime override of repository settings
99+
100+ . LINK
101+ https://aka.ms/algosettings - AL-Go Settings Documentation
102+ #>
103+
6104Param (
7105 [string ] $containerName = " " ,
8106 [ValidateSet (" UserPassword" , " Windows" )]
@@ -11,7 +109,8 @@ Param(
11109 [string ] $licenseFileUrl = " " ,
12110 [switch ] $fromVSCode ,
13111 [switch ] $accept_insiderEula ,
14- [switch ] $clean
112+ [switch ] $clean ,
113+ [string ] $customSettings = " "
15114)
16115
17116$errorActionPreference = " Stop" ; $ProgressPreference = " SilentlyContinue" ; Set-StrictMode - Version 2.0
@@ -55,12 +154,12 @@ Write-Host -ForegroundColor Yellow @'
55154
56155$tmpFolder = Join-Path ([System.IO.Path ]::GetTempPath()) " $ ( [Guid ]::NewGuid().ToString()) "
57156New-Item - Path $tmpFolder - ItemType Directory - Force | Out-Null
58- $GitHubHelperPath = DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.0 /Github-Helper.psm1' - folder $tmpFolder - notifyAuthenticatedAttempt
59- $ReadSettingsModule = DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.0 /.Modules/ReadSettings.psm1' - folder $tmpFolder
60- $debugLoggingModule = DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.0 /.Modules/DebugLogHelper.psm1' - folder $tmpFolder
61- $ALGoHelperPath = DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.0 /AL-Go-Helper.ps1' - folder $tmpFolder
62- DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.0 /.Modules/settings.schema.json' - folder $tmpFolder | Out-Null
63- DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.0 /Environment.Packages.proj' - folder $tmpFolder | Out-Null
157+ $GitHubHelperPath = DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.1 /Github-Helper.psm1' - folder $tmpFolder - notifyAuthenticatedAttempt
158+ $ReadSettingsModule = DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.1 /.Modules/ReadSettings.psm1' - folder $tmpFolder
159+ $debugLoggingModule = DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.1 /.Modules/DebugLogHelper.psm1' - folder $tmpFolder
160+ $ALGoHelperPath = DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.1 /AL-Go-Helper.ps1' - folder $tmpFolder
161+ DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.1 /.Modules/settings.schema.json' - folder $tmpFolder | Out-Null
162+ DownloadHelperFile - url ' https://raw.githubusercontent.com/microsoft/AL-Go-Actions/v8.1 /Environment.Packages.proj' - folder $tmpFolder | Out-Null
64163
65164Import-Module $GitHubHelperPath
66165Import-Module $ReadSettingsModule
@@ -160,7 +259,8 @@ CreateDevEnv `
160259 - credential $credential `
161260 - licenseFileUrl $licenseFileUrl `
162261 - accept_insiderEula:$accept_insiderEula `
163- - clean:$clean
262+ - clean:$clean `
263+ - customSettings $customSettings
164264}
165265catch {
166266 Write-Host - ForegroundColor Red " Error: $ ( $_.Exception.Message ) `n Stacktrace: $ ( $_.scriptStackTrace ) "
0 commit comments