Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy file to ouput directory and rename it in c# project

I have a Visual Studio 2015 C# project that has a link to some external file.

<None Include="..\File.data">
  <Link>File.data</Link>
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

I want to copy this file (if it has been modified) to the output directory (as the above msbuild statement would do), but also want to change its name (e.g. to "Sample.data").

Is there an easy way to do this with the builtin msbuild tasks?

like image 250
Wilhelm Medetz Avatar asked Nov 01 '25 02:11

Wilhelm Medetz


1 Answers

Not sure for 2015. But in 2017 you can simply rename the tag.

<None Include="..\File.data">
 <Link>Sample.data</Link>
 <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
like image 130
Jason Li Avatar answered Nov 02 '25 17:11

Jason Li