Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions docs/cli-reference/dfx-build.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";

<MarkdownChipRow labels={["Reference"]} />

Use the `dfx build` command to compile your program into a WebAssembly module that can be deployed on the IC. You can use this command to compile all of the programs that are defined for a project in the project’s `dfx.json` configuration file or a specific canister.

Note that you can only run this command from within the project directory structure. For example, if your project name is `hello_world`, your current working directory must be the `hello_world` top-level project directory or one of its subdirectories.
Use the `dfx build` command to compile your program into a WebAssembly module that can be deployed on ICP. You can use this command to compile all of the canisters that are defined in the project’s `dfx.json` configuration file or compile only a specific canister.

The `dfx build` command looks for the source code to compile using the information you have configured under the `canisters` section in the `dfx.json` configuration file.

Note that you can only run this command from within the project directory structure. For example, if your project name is `hello_world`, your current working directory must be the `hello_world` top-level project directory or one of its subdirectories.

## Basic usage

``` bash
Expand All @@ -22,7 +22,7 @@ You can use the following optional flags with the `dfx build` command.

| Flag | Description |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--check` | Builds canisters using a temporary, hard-coded, locally-defined canister identifier for testing that your program compiles without connecting to the IC. |
| `--check` | Builds canisters using a temporary, hard-coded, locally-defined canister ID for testing that the canister compiles without connecting to ICP. |

## Options

Expand All @@ -31,37 +31,34 @@ You can specify the following options for the `dfx build` command.
| Option | Description |
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--network <network>` | Specifies the network alias or URL you want to connect to. You can use this option to override the network specified in the `dfx.json` configuration file. |
| `--output-env-file` | Writes dfx environment variables to a provided path. Overrides the `output_env_file` configuration from `dfx.json` if passed. |
| `--output-env-file` | Writes `dfx` environment variables to a provided path. Overrides the `output_env_file` configuration from `dfx.json` if passed. |

## Arguments

You can specify the following arguments for the `dfx build` command.

| Argument | Description |
| --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--all` | Builds all of the canisters configured in the project’s `dfx.json` file. |
| `canister_name` | Specifies the name of the canister you want to build. If you are not using the `--all` option, you can continue to use `dfx build` or provide a canister name as an argument (the canister name must match at least one name that you have configured in the `canisters` section of the `dfx.json` configuration file for your project.) |
| `--all` | Builds all canisters configured in the project’s `dfx.json` file. |
| `canister_name` | Specifies the name of the canister you want to build. If you are not using the `--all` option, you can continue to use `dfx build` or provide a canister name as an argument. The canister name must match at least one name that you have configured in the `canisters` section of the `dfx.json` configuration file for your project. |

## Examples

You can use the `dfx build` command to build one or more WebAssembly modules from the programs specified in the `dfx.json` configuration file under the `canisters` key. For example, if your `dfx.json` configuration file defines one `hello_world_backend` canister and one `hello_world_frontend` canister, then running `dfx build` compiles two WebAssembly modules.

Note that the file name and path to the programs on your file system must match the information specified in the `dfx.json` configuration file.

In this example, the `hello_world_backend` canister contains the main program code and the `hello_world_frontend` canister store frontend code and assets. If you want to keep the `hello_world_frontend` canister defined in the `dfx.json` file, but only build the backend program, you could run the following command:

``` bash
dfx build hello_world_backend
```

Building a specific canister is useful when you have multiple canisters defined in the dfx.json file, but want to test and debug operations for canisters independently.
Building a specific canister is useful when you have multiple canisters defined in the `dfx.json` file, but want to test and debug operations for canisters independently.

To test whether a canister compiles without connecting to the IC or the local development environment, you would run the following command:
To test whether a canister compiles without connecting to the mainnet or the local development environment, you would run the following command:

``` bash
dfx build --check
```

## Management canister

If `dfx` detects that your Motoko project is importing the Management Canister (e.g. `import Management "ic:aaaaa-aa";`) it will automatically provide the Candid interface for the Management Canister during the build.
If `dfx` detects that your Motoko project is importing the management canister (e.g. `import Management "ic:aaaaa-aa";`) it will automatically provide the Candid interface for the management canister during the build.
32 changes: 12 additions & 20 deletions docs/cli-reference/dfx-cache.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";

<MarkdownChipRow labels={["Reference"]} />

Use the `dfx cache` command with flags and subcommands to manage the `dfx` version cache.
Use the `dfx cache` command to manage the `dfx` version cache. When a version of `dfx` is installed, it is added to the version cache.

The basic syntax for running `dfx cache` commands is:

Expand All @@ -17,7 +17,7 @@ Depending on the `dfx cache` subcommand you specify, additional arguments, optio
| Command | Description |
|----------------------------|-------------------------------------------------------------------------------|
| [`delete`](#delete) | Deletes the specified version of `dfx` from the local cache. |
| `help` | Displays usage information message for a specified subcommand. |
| `help` | Displays usage information message for the `dfx cache` command. |
| [`install`](#install) | Installs the specified version of `dfx` from the local cache. |
| [`list`](#_dfx_cache_list) | Lists the versions of `dfx` currently installed and used in current projects. |
| [`show`](#_dfx_cache_show) | Show the path of the cache used by this version of the `dfx` executable. |
Expand All @@ -30,7 +30,7 @@ dfx cache delete --help

## dfx cache delete

Use the `dfx cache delete` command to delete a specified version of the IC SDK from the version cache on the local computer.
Use the `dfx cache delete` command to delete a specified version of `dfx` from the version cache on the local computer.

### Basic usage

Expand All @@ -46,53 +46,47 @@ You can specify the following argument for the `dfx cache delete` command.
|-----------|--------------------------------------------------------------------|
| `version` | Specifies the version of `dfx` you to delete from the local cache. |

### Examples

You can use the `dfx cache delete` command to permanently delete versions of the IC SDK that you no longer want to use. For example, you can run the following command to delete the IC SDK version `0.6.2`:
### Example

``` bash
dfx cache delete 0.6.2
```

## dfx cache install

Use the `dfx cache install` command to install the IC SDK using the version currently found in the `dfx` cache.
Use the `dfx cache install` command to install the latest `dfx` version currently found in the `dfx` cache.

### Basic usage

``` bash
dfx cache install [flag]
```

### Examples

You can use the `dfx cache install` command to force the installation of `dfx` from the version in the cache. For example, you can run the following command to install `dfx`:
### Example

``` bash
dfx cache install
```

## dfx cache list

Use the `dfx cache list` command to list the IC SDK versions you have currently installed and used in projects.
Use the `dfx cache list` command to list `dfx` versions you have currently installed and used in projects.

If you have multiple versions of the IC SDK installed, the cache list displays an asterisk (\*) to indicate the currently active version.
If you have multiple versions of `dfx` installed, the cache list displays an asterisk (\*) to indicate the currently active version.

### Basic usage

``` bash
dfx cache list [flag]
```

### Examples

You can use the `dfx cache list` command to list the IC SDK versions you have currently installed and used in projects. For example, you can run the following command to list versions of the IC SDK found in the cache:
### Example

``` bash
dfx cache list
```

This command displays the list of the IC SDK versions found similar to the following:
This command displays the list of `dfx` versions found similar to the following:

``` bash
0.6.4 *
Expand All @@ -102,17 +96,15 @@ This command displays the list of the IC SDK versions found similar to the follo

## dfx cache show

Use the `dfx cache show` command to display the full path to the cache used by the IC SDK version you are currently using.
Use the `dfx cache show` command to display the full path to the cache used by the `dfx` version you are currently using.

### Basic usage

``` bash
dfx cache show [flag]
```

### Examples

You can use the `dfx cache show` command to display the path to the cache used by the IC SDK version you are currently using:
### Example

``` bash
dfx cache show
Expand Down
Loading