+1-905-282-9675 query@smartmilestones.com

When building extensions for Microsoft Dynamics 365 Business Central, developers work with multiple configuration files in Visual Studio Code. Two critical files—app.json and launch.json—play distinct roles in development and debugging. Knowing the difference between app.json and launch.json is essential for any AL developer who wants to avoid common pitfalls and streamline the extension deployment lifecycle.

App.json and launch.json in Business Central

Use Case: When to Use Which?

To truly grasp the app.json vs. launch.json distinction, let’s look at their primary use cases:

app.json: Think of app.json as your application’s manifest or blueprint. It contains static, high-level information about your application itself. This includes metadata that defines your application’s identity and general behavior. For instance, in environments like Expo for React Native, app.json defines your app’s name, icon, splash screen, and other core properties that are inherent to the application’s build and deployment. In other contexts, it might specify dependencies, target platforms, or even object ID ranges for extensions (e.g., in Business Central AL development).

launch.json: In contrast, launch.json is all about debugging and execution. It’s a Visual Studio Code-specific file that defines how VS Code should launch or attach to a debugger for your project. This file is highly dynamic and focused on your development workflow. It specifies configurations for running your code, setting breakpoints, attaching to running processes, and controlling the debugger’s behavior. If you want to run your application with specific arguments, environment variables, or on a particular port, launch.json is where you’ll define those settings.

Analogy: Imagine building a house. app.json is like the architectural blueprint – it defines the house’s overall structure, number of rooms, and fundamental characteristics. launch.json is like a set of instructions for a specific tour or inspection of the house – how to turn on the lights, where to start the walkthrough, and what tools to bring for examining specific areas (the debugger).

Steps (With Warnings)
Let’s look at how these files typically appear and how you might interact with them

app.json Configuration (General Example)
The structure and content of app.json can vary significantly depending on the framework or platform you are using. Here’s a generic example and some common properties:

Sample App.JSON
{
  “id”: “434b9a77-03e3-432d-999b-d6cb43f41dd5”,
  “name”: “ALProject2”,
  “publisher”: “Default Publisher”,
  “version”: “1.0.0.0”,
  “brief”: “”,
  “description”: “”,
  “privacyStatement”: “”,
  “EULA”: “”,
  “help”: “”,
  “url”: “”,
  “logo”: “”,
  “dependencies”: [],
  “screenshots”: [],
  “platform”: “1.0.0.0”,
  “application”: “26.0.0.0”,
  “idRanges”: [
    {
      “from”: 50100,
      “to”: 50149
    }
  ],
  “resourceExposurePolicy”: {
    “allowDebugging”: true,
    “allowDownloadingSource”: true,
    “includeSourceInSymbolFile”: true
  },
  “runtime”: “15.0”,
  “features”: [
    “NoImplicitWith”
  ]
}

Common Properties in app.json (may vary by platform):

  • name: The public-facing name of your application.
  • version: The version number of your application.
  • description: A brief description of your application.
  • slug: A unique identifier used in URLs or package names.
  • icon, splash: Paths to images used for your app’s icon and splash screen.
  • platforms: Which platforms your app is intended for.
  • idRanges (e.g., in Business Central AL): Specifies ranges for object IDs for extensions.
  • dependencies: Lists external application dependencies.
  • extra: Custom fields for application-specific configurations.

Warnings for app.json:

  • Platform Specificity: Be aware that app.json might have platform-specific sections (e.g., expo.ios, expo.android). Ensure you configure the correct section for your target platform.
  • Schema Validation: Many app.json implementations are schema-validated. Typos or incorrect data types can lead to build failures. Use IDE extensions for auto-completion and validation where available.
  • Version Control: Always commit app.json to your version control system as it defines core application properties.

launch.json Configuration (VS Code Specific)

launch.json is found in a .vscode directory at the root of your project. If it doesn’t exist, VS Code can often generate a basic one for you.

To generate or edit launch.json in VS Code:

Open your project in VS Code.

Go to the Run and Debug view (the play button with a bug icon on the left sidebar, or Ctrl+Shift+D).

Click on the “create a launch.json file” link if it’s not present. VS Code will prompt you to select an environment (e.g., Node.js, Python, C++, Chrome). This selection will pre-populate a basic launch.json with relevant configurations.

A typical launch.json might look like this for a Node.js project:

Sample Launch.json File
{
    “version”: “0.2.0”,
    “configurations”: [
        {
            “name”: “Microsoft cloud sandbox”,
            “request”: “launch”,
            “type”: “al”,
            “environmentType”: “Sandbox”,
            “environmentName”: “sandbox”,
            “startupObjectId”: 22,
            “startupObjectType”: “Page”,
            “breakOnError”: “All”,
            “launchBrowser”: true,
            “enableLongRunningSqlStatements”: true,
            “enableSqlInformationDebugger”: true
        }
    ]
}

Common Properties in launch.json:

name: A display name for the debug configuration that appears in the Debug dropdown.

type: The type of debugger to use (e.g., node, python, chrome).

request: The debug request type, usually launch (to start a new process) or attach (to connect to a running process).

program: The entry point file for your application (e.g., ${workspaceFolder}/index.js).

cwd: The current working directory for the launched program.

args: Command-line arguments to pass to your program.

env: Environment variables to set for the debug session.

port: The port for attaching a debugger.

console: Where to display the program’s output (e.g., integratedTerminal, externalTerminal).

preLaunchTask: A task to run before launching the debugger (e.g., building your code, defined in tasks.json).

Warnings for launch.json:

Debugger Type: Ensure the type property matches the language or environment you are debugging. Incorrect types will prevent debugging.

Paths: Use ${workspaceFolder} for relative paths to ensure portability across different development machines.

Environment Variables: Be mindful of sensitive information in env if launch.json is committed to a public repository. Consider using .env files and envFile property if your debugger supports it for secure handling of credentials.

Task Dependencies: If you use preLaunchTask, ensure the corresponding task is correctly defined in tasks.json.

PRO Tips

Use IntelliSense: Both app.json (if a schema is defined or through extensions) and launch.json benefit greatly from VS Code’s IntelliSense. Hover over properties to see descriptions and available options.

Variables in launch.json: Leverage VS Code’s predefined variables like ${workspaceFolder}, ${file}, ${fileDirname} to make your launch.json configurations more flexible and portable.

Compound Configurations: For complex projects with multiple parts (e.g., frontend and backend), use “compound” configurations in launch.json to launch and debug multiple processes simultaneously.

tasks.json Integration: launch.json can be linked with tasks.json (another VS Code configuration file for defining tasks like building, testing, or linting). Use the preLaunchTask property in launch.json to ensure necessary build steps run before debugging.

Version Control: Always keep both app.json and launch.json under version control. This ensures consistent project setup and debugging configurations across your team.

Your content goes here. Edit or remove this text inline or in the module Content settings. You can also style every aspect of this content in the module Design settings and even apply custom CSS to this text in the module Advanced settings.

What Have You Learned in This Post?

In this post, we’ve explored the key difference between app.json and launch.json, two fundamental configuration files in modern development. You’ve learned that:

app.json defines your application’s fundamental characteristics and build-time metadata. It’s the “what” of your application.

launch.json dictates how Visual Studio Code debugs and runs your code, specifying runtime parameters and debugger behavior. It’s the “how” of your development process.

We’ve covered typical use cases, from mobile app configuration with app.json to precise debugging setups using launch.json.

You now understand how to access and modify these files within VS Code and have insights into important properties and potential pitfalls.

Do you know how to configure app.json for an Expo React Native project? This file is essential for setting up your app’s identity and build environment.

Are you struggling with VS Code debugging configurations with launch.json? This file is your go-to for customizing how your code runs and interacts with the debugger.

What is the purpose of app.json in application development beyond just metadata? It’s often critical for defining platform-specific behaviors and resource paths.

How does launch.json help in efficient code debugging within an IDE? It allows you to define multiple debug scenarios, attach to processes, and manage environment variables on the fly.

query@smartmilestones.com

Contact us for more tips and consulting support!