Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File marked as Content -> Copy Always is not being copied

I have a file in a folder of my C# VS2010 project marked Content and Always Copy.

When I change this file and save it, externally to VS, and then run the project, the modified file is not copied to the output. If I rebuild, then it is. My guess is that VS does not use the modified date time stamp of the file to determine whether it should be copied or not.

Am I missing something? It's driving me nuts as I'm losing 5 minutes per run.

Thank you!

like image 314
Simon Avatar asked Nov 18 '12 15:11

Simon


People also ask

What is Copytooutputdirectory?

"Copy to Output Directory" is the property of the files within a Visual Studio project, which defines if the file will be copied to the project's built path as it is. Coping the file as it is allows us to use relative path to files within the project.

Where is Copy to Output Directory property?

Add the file to your project, then in the file properties select under "Copy to Output Directory" either "Copy Always" or "Copy if Newer".

How do I create a release folder in Visual Studio?

The simplest way of doing it is by adding the desired folder to your project and the exe file on the folder. Change the properties of the exe file to "Content" and "Copy always". By doing that, everytime you rebuild your solution, the output will have the folder and exe file.


2 Answers

Hard to explain so start by getting better diagnostics. Tools + Options, Projects and Solutions, Build and Run settings. Change the "MSBuild project build output verbosity" setting to Normal. In that same property page, ensure that the "On Run, when projects are out of date" setting is set to Always build. Look in the Output window when you press F5 or Build + Build, the _CopyOutOfDateSourceItemsToOutputDirectory task is the one that copies the file.

One possible trap when you use Project + Add Existing Item: the IDE makes a copy of the file that you selected. You might be changing the original file instead of the copy in the project directory. You'd fix that by clicking the arrow on the Add button in the dialog and selecting "Add As Link".

like image 86
Hans Passant Avatar answered Sep 21 '22 20:09

Hans Passant


The behavior you are expecting can be achieved by changing the Build Action from "Content" to "Embedded Resource".

like image 39
Ananth Ramasamy Meenachi Avatar answered Sep 19 '22 20:09

Ananth Ramasamy Meenachi