title: Rust build script to copy a file to target directory
body: <p>For my project, I would like to copy the file config.ron that is in the root of my project to the target directory when the project is built. I know that you can use include_str! to add the content of the file to the program at compile time, but I would like the file to stay in the root of the target folder so that it can be edited without the need to recompile the program.</p>
  <p>I've currently been trying out a build script to accomplish this but I am have no luck.</p>
  <pre><code>use std::process::Command;
  use std::env;
  
  fn main() {
      let profile = std::env::var(&quot;PROFILE&quot;).unwrap();
      match profile.as_str() {
          &quot;debug&quot; =&gt; {
              Command::new(&quot;cmd&quot;)
                  .args(&amp;[&quot;copy&quot;, &quot;/y&quot;])
                  .arg(&amp;format!(r#&quot;{}\config.ron&quot;#, env::var(&quot;CARGO_MANIFEST_DIR&quot;).unwrap()))
                  .arg(&amp;format!(r#&quot;{}\target\debug&quot;#, env::var(&quot;CARGO_MANIFEST_DIR&quot;).unwrap()))
                  .status()
                  .expect(&quot;Copy failed to execute.&quot;);
              ()
          },
          &quot;release&quot; =&gt; {
              Command::new(&quot;cmd&quot;)
                  .args(&amp;[&quot;copy&quot;, &quot;/y&quot;])
                  .arg(&amp;format!(r#&quot;{}\config.ron&quot;#, env::var(&quot;CARGO_MANIFEST_DIR&quot;).unwrap()))
                  .arg(&amp;format!(r#&quot;{}\target\release&quot;#, env::var(&quot;CARGO_MANIFEST_DIR&quot;).unwrap()))
                  .status()
                  .expect(&quot;Copy failed to execute.&quot;);
              ()
          },
          _ =&gt; (),
      }
  }
  </code></pre>
  <p>What would be the correct way to get this file copied to the target directory using a build script?</p>