This is a very good idea. Sometimes you really need it.
Before I answer your question, I'll explain how to deal with icons and bitmaps in a usual way.
As a matter of fact, I do not recommend to add icon and bitmap resources via the Visual Studio editor even when it it quite suitable for some. Using a separate file is way more maintainable. One can even edit the file via Visual Studio separately and save it, but outside of the target project.
You can create a .resx node and use "Use existing file". The file you chose will first be added to the of of the project directories of your choice and referenced in the project file. It's "Copy" property will be set to "None". Then it will be referenced in the .resx file, but not embedded in it. Of course, it means that the file will be embedded in the resulting resource during the build.
Pay attention: the file will be copied from the original one, so exercise some precautions to avoid duplication. It's the best to have the original file ether outside of the project (you can later removed it), or at the exact location in your project file structure where you expect the copy.
Moreover, the node with C# auto-generated code will appear as a child node of your .resx node. The generated code is ready to use. Open this file in a text editor and locate some static property with the name close to the name of your original image file. Just use it.
On top of that, I recommend to avoid putting any icons in the client area of any forms/windows. It should be either bitmap (as opposed to icon) or, in case of WPF, XAML vector image based on Canvas element. If you read about standard-compliant icons, you will see how big they are. You are supposed to pack several different bitmap in different pixel sizes into a standard icon, which can easily make your icon way bigger than your whole output directory size with all your assemblies. Please see the section of my article where I explain it:
Practical Sound Recorder with Sound Activation, 3.4. Some Funny Peculiarities. See also the icon, to find out how many bitmaps of what pixel sizes you are supposed to provide. If you fail to make them all, some OS elements in some modes will re-sample your icons automatically, in quite an ugly way.
So, reserve your icons exclusively to two cases 1) application icon (see your project's Properties), 2) window/form icons. It would be the best if you also reuse your application icon for the window/form icon for one or all of your windows or forms.
Now, I can answer your question.
First of, create some simple sample project and do all the steps I recommended above. Then remove all non-source files: all "bin" and "obj" directories, *.user, and so on. Look at your project files. Locate the references to your icon and other stuff you need. Learn how to insert them in text.
Also, you can use MSBuild API to write code which would safely manipulate your project files:
https://msdn.microsoft.com/en-us/library/microsoft.build.tasks.msbuild.aspx[
^].
I will be pretty easy to write your own utility to inject some predefined resources in your projects and perform the build with it. You can even embed this utility into the build itself, which is done via development of the custom
Task
class which can then be used in some project. You can create some "master project" which uses some custom Tasks to manipulate other projects/solutions involved in your build. Please see, in particular:
https://msdn.microsoft.com/en-us/library/microsoft.build.utilities.task.aspx[
^],
https://msdn.microsoft.com/en-us/library/t9883dzc.aspx[
^].
—SA