{{~*set command=“package”}} {{~*set actionverb=“Package”}} {{~*set noall=true}} {{~*set multitarget=true}}
cargo-package --- Assemble the local package into a distributable tarball
cargo package [options]
This command will create a distributable, compressed .crate file with the source code of the package in the current directory. The resulting file will be stored in the target/package directory. This performs the following steps:
dev-dependencies do not have this restriction..crate file.Cargo.toml file is rewritten and normalized.[patch], [replace], and [workspace] sections are removed from the manifest.Cargo.lock is automatically included if the package contains an executable binary or example target. {{man “cargo-install” 1}} will use the packaged lock file if the --locked flag is used..cargo_vcs_info.json file is included that contains information about the current VCS checkout hash if available, as well as a flag if the worktree is dirty..crate file and build it to verify it can build.--no-verify flag can be used to skip this step.The list of files included can be controlled with the include and exclude fields in the manifest.
See the reference for more details about packaging and publishing.
Will generate a .cargo_vcs_info.json in the following format
{ "git": { "sha1": "aac20b6e7e543e6dd4118b246c77225e3a3a1302", "dirty": true }, "path_in_vcs": "" }
dirty indicates that the Git worktree was dirty when the package was built.
path_in_vcs will be set to a repo-relative path for packages in subdirectories of the version control repository.
The compatibility of this file is maintained under the same policy as the JSON output of {{man “cargo-metadata” 1}}.
Note that this file provides a best-effort snapshot of the VCS information. However, the provenance of the package is not verified. There is no guarantee that the source code in the tarball matches the VCS information.
{{#option “-l” “--list” }} Print files included in a package without making one. {{/option}}
{{#option “--no-verify” }} Don't verify the contents by building them. {{/option}}
{{#option “--no-metadata” }} Ignore warnings about a lack of human-usable metadata (such as the description or the license). {{/option}}
{{#option “--allow-dirty” }} Allow working directories with uncommitted VCS changes to be packaged. {{/option}}
{{> options-index }}
{{#option “--registry registry”}} Name of the registry to package for; see cargo publish --help for more details about configuration of registry names. The packages will not be published to this registry, but if we are packaging multiple inter-dependent crates, lock-files will be generated under the assumption that dependencies will be published to this registry. {{/option}}
{{/options}}
{{> section-package-selection }}
{{> options-target-triple }}
{{> options-target-dir }}
{{/options}}
{{> section-features }}
{{> options-manifest-path }}
{{> options-locked }}
{{> options-lockfile-path }}
{{/options}}
{} {{> options-jobs }} {{> options-keep-going }} {{/options}}
{} {{> options-display }} {{/options}}
{{> section-options-common }}
{{> section-environment }}
{{> section-exit-status }}
Create a compressed .crate file of the current package:
cargo package
{{man “cargo” 1}}, {{man “cargo-publish” 1}}