Click here to Skip to main content
15,867,939 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!

I would like to know more about how the Copy to Output Directory works?

Can users implement the property in source code?

If so, will it also work on all file types and not just for components and databases?


Thanks in advance for your response.


JohnPDB
Posted
Comments
Sergey Alexandrovich Kryukov 25-May-12 21:58pm    
What do you mean by "implement the property in source code"? it is already implemented, you can use it...
--SA

1 solution

From the very end: if your mean the project's node property; yes, it works on all files.
"Can user implement the property in source code" — simply makes no sense as you formulate it, if I could understand you correctly, of course. I'll try to explain what you can do.

And, finally, I'll try to explain how it works. Please don't blame me if I'm answering a wrong question: you did not explain properly, what kind of property do you mean, so I'll assume that you refer to the property shown, in particular, for the Visual Studio project node. Actually, this is a property of the XML-based standard project file which can be built using the application MSBuild.exe. By the way, this application and C# and VB.NET compilers come for free with the freely re-distributable .NET Framework, so you do not need Visual Studio or any other commercially licensed software tool to build projects; you can even do all the .NET development without Visual Studio. This project format is also valid for Mono (http://en.wikipedia.org/wiki/Mono_%28software%29[^], http://www.mono-project.com/[^]), so it can be used on many non-Microsoft platforms. Visual Studio itself does not build or compile anything; it runs the build utility, most likely through its managed interface available in .NET; you can also do it. You can read about integration of MSBuild with Visual Studio here:
http://msdn.microsoft.com/en-us/library/ms171468[^].

The project document has many features; the concept of the property is just one of them. You can write a custom property, among other things, notably — creating custom tasks (please see http://msdn.microsoft.com/en-us/library/t9883dzc.aspx[^], http://msdn.microsoft.com/en-us/library/microsoft.build.utilities.task.aspx[^]).

"Copy to Output Directory" is one of the basic properties which causes the file referenced by the project node to be copies to the output directory (which is merely another property, per configuration) as is. This action is, in turn, one of the basic tasks available in the build system. You can use this task if you want to develop a custom project.

The build technology based on MSBuild is a very flexible and robust system; it tracks dependencies between files and time stamps which allows for incremental build free from repeated steps and it is very power in terms of customization, compared to "classic" build. Practically, you can create custom tasks and other build-related component in the form of specially interfaced .NET assemblies and easily plug them in the system. You can even use this system to design a build project using the languages and other tools having nothing in common with Visual Studio and Microsoft, and you can do it on non-Microsoft systems (via Mono, for example).

You can learn it all starting from this point:
http://msdn.microsoft.com/en-us/library/wea2sca5%28v=vs.90%29[^].

For build API, you can start here:
http://msdn.microsoft.com/en-us/library/gg145008[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900