Profile specification along with 'cargo package' command

Hi,

While using 'cargo package' command, it looks like by default it uses 'dev' profile.
As like with other cargo commands (cargo build), option '--profile ' is not available.
So, wondering is there any other way to specify the profile name?
Basically, I'm looking to create a custom profile (RelWithDebug) and use it with all cargo commands - build/package/publish etc.
Appreciate any help on this regard.

You mean like a defined profile which you can declare in the Cargo.toml?

Cargo has 4 built-in profiles: dev, release, test, and bench. The profile is automatically chosen based on which command is being run if a profile is not specified on the command-line. In addition to the built-in profiles, custom user-defined profiles can also be specified.

As described on Custom Profiles
you can do this cargo build --profile release-lto by specifying your custom profile in the Cargo.toml

Thanks for the response.
However, as I mentioned, I'm looking specifically with command 'cargo package '. Other commands like 'cargo build' do take '--profile' as comman line argument, except 'cargo package ' command.
'cargo command' by default using 'dev' profile which I want to change.

The question is: why do you want to do this?
cargo package merely packages up your source code into a distributable tarball (it does "verify" it before by compiling, but that step can be skipped). A profile should not have any effect on what ends up in the package nor will it have any effect on those depending on the package later.

If you look in the cargo package doc and compare it with the cargo build doc then you will see that cargo package has no --profile argument like cargo build. So I would say it is not possible. But to follow on from @jer 's question: is it really necessary to use the cargo package?

Profiles provide a way to alter the compiler settings, influencing things like optimizations and debugging symbols.

Since the Profiles are more intended for different compiling and debugging options it is only neccessary to use them for cargo build.

Thanks for the responses.
I was thinking, 'cargo package' would be packaging with pre-built libs/binaries (something similar to what 'conan create' does). Hence was the query.
Now, I realize that, it packages source code rather.