Thypari
Thypari

Reputation: 861

Using resources / files in multiple projects. Which way to go?

So I have files that are used in multiple projects (in one solution). Which way would I choose?

Right now the files reside inside a Resource-Folder in the root directory of the solution. But this way there is no relative path to these files.

I could add them to properties/resources but to which project? There is no "main" project that handles these files. Or create a new "ResourceHolder"-project just for resources?

If I add them to multiple projects they are all copies and not links to the original file/path as far as I know... so that's also no option.

Can't you add resources solution wide? Or better have a solution wide folder and only if a project uses a file it is then copied to output and can be used with a relative path?

Upvotes: 1

Views: 1190

Answers (1)

Kristof U.
Kristof U.

Reputation: 1281

There are no solution-wide resources, because there is no artifact produced by the solution itself. The place to put the resources depends, in my opinion, on the semantics of the resources.

If they are, for example, icons, which must be consistent over several assemblies (i.e. over several controls that reside in different assemblies or several different applications belonging to a set of applications), then they semantically are global resources. Hence, I would put them into a separate resource assembly that is referenced by all other assemblies.

If they are separate resources that just happen to be the same right now (i.e. test data for different test assemblies), then they have, in my opinion, no global semantics and should be copied into every project which requires them. This would then also allow to distribute the resulting assemblies independently as they have no further dependencies on each other.

Regarding your third option: I would always try to avoid working on files directly. This only may be applicable in two scenarios: First, if the files do not belong to the application, i.e. they are user data (such as documents read and written by the application); that doesn't seem to be the case her. Second, if the files are so large that duplicating them would result in a substantial demand of disk space. Your question does not read like that's the case, but in such a situation it might be feasible to provide a central repository of the data.

Upvotes: 2

Related Questions