diff --git a/CHANGELOG.md b/CHANGELOG.md index 003c1c78a..09afaa86a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed +- Respect the lockfile [#948](https://github.com/paritytech/cargo-contract/pull/948) + ## [2.0.0-rc.1] - 2023-02-01 Second release candidate compatible with `ink! 4.0.0-rc`. diff --git a/crates/build/src/workspace/mod.rs b/crates/build/src/workspace/mod.rs index e41d87f40..a51847fd8 100644 --- a/crates/build/src/workspace/mod.rs +++ b/crates/build/src/workspace/mod.rs @@ -200,7 +200,7 @@ impl Workspace { .tempdir()?; tracing::debug!("Using temp workspace at '{}'", tmp_dir.path().display()); let new_paths = self.write(&tmp_dir)?; - let root_manifest_path = new_paths + let tmp_root_manifest_path = new_paths .iter() .find_map(|(pid, path)| { if *pid == self.root_package { @@ -210,6 +210,21 @@ impl Workspace { } }) .expect("root package should be a member of the temp workspace"); - f(root_manifest_path) + + // copy the `Cargo.lock` file + let src_lockfile = self.workspace_root.clone().join("Cargo.lock"); + let dest_lockfile = tmp_root_manifest_path + .absolute_directory()? + .join("Cargo.lock"); + if src_lockfile.exists() { + tracing::debug!( + "Copying '{}' to ' '{}'", + src_lockfile.display(), + dest_lockfile.display() + ); + std::fs::copy(src_lockfile, dest_lockfile)?; + } + + f(tmp_root_manifest_path) } }