Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have an entire folder be an embedded resource in a Visual Studio project?

I'm working on a project which we'll call Container. Container has a bunch of EmbeddedResources. The original files for these EmbeddedResources are another project which we'll call FileProject.

FileProject is a project that is currently being worked on by a group of different developers and is always changing, so I have my EmbeddedResource files linked - so that whenever the original project changes and I do a rebuild of my project, it picks up the changes.

This setup catches whenever a file changes, but it doesn't catch whenever a new file is added or removed from the project. Is there a way to make EmbeddedResources out of an entire folder structure in Visual Studio to catch file removal and additions?

like image 932
Victor Chelaru Avatar asked Jan 24 '12 21:01

Victor Chelaru


People also ask

How do I create an embedded resource in Visual Studio?

Open Solution Explorer add files you want to embed. Right click on the files then click on Properties . In Properties window and change Build Action to Embedded Resource . After that you should write the embedded resources to file in order to be able to run it.

What is embedded resource in Visual Studio?

Embedded resource has no predefined structure: it is just a named blob of bytes. So called “. resx” file is a special kind of embedded resource. It is a string-to-object dictionary that maps a name to an object. The object may be a string, an image, an icon, or a blob of bytes.

How do you change a build action to an embedded resource?

Click in the solution explorer the file that will be modified. Then hit F4 or click with the right button in the file and then select the "Properties" option. In the Properties window, change Build Action to Embedded Resource.


1 Answers

Edit the project file for Container in a text editor and find the <EmbeddedResource> elements that link to the files in FileProject:

<EmbeddedResource Include="..\FileProject\Copy.bmp">
  <Link>Copy.bmp</Link>
</EmbeddedResource>
<EmbeddedResource Include="..\FileProject\Paste.bmp">
  <Link>Paste.bmp</Link>
</EmbeddedResource>

Delete all of these elements and replace them with a single <EmbeddedResource> element that has a suitable wildcard:

<EmbeddedResource Include="..\FileProject\*.bmp" />

Now if you add Cut.bmp to FileProject, it will also show up in Container.

like image 129
Michael Liu Avatar answered Oct 21 '22 06:10

Michael Liu