0

When I was working in the iOS world, I had a set of 4 projects that were nearly identical except for Text Data, PNG, and a few features here and there. To facilitate this, I set up 4 build targets that all pretty much referenced the same source files, but various differing data and image files. After that I could just select the build target from the top menu, and quickly put out that app.

I tried to add multiple projects to a visual studio solution that referenced the same files, but I ended up with "Namespace already contains a reference to XXX class" errors. What is the correct way to accomplish this behavior in Visual Studio (2012 Express)?

EDIT
There is a new error now. What I really want is only the startup project and its dependencies to be built. However, all of the projects get built every time. Now I get a weird error

Manifest references file 'XXX.exe' which is not part of the payload.

I edited both of the manifest files to explicitly use the .exe name, but no success.

borrrden
  • 33,256
  • 8
  • 74
  • 109
  • Why you encountered `Namespace already contains a reference ..`? When I create multiple projects and add the same file, it doesn't occur. – Ken Kin Apr 26 '13 at 04:32
  • Actually that error has gone away now. I don't know why, but there is a different one now @KenKin (I will update the question) – borrrden Apr 26 '13 at 04:34

2 Answers2

1

You can have different build targets in project and you can conditionally include files into CSPROJ if you edit files by hand. There is no UI to do that in any edition of VS.

Practically creating several projects referencing the same files maybe more user friendly approach:

  • I don't think Express editions expose build target management
  • VS editing will ignore all conditions and pretend all files are included into the project - depending on what actual files are this may range from perfectly normal to insane behavior during editing (i.e. it may completely confuse intellisense).

The other option would be to separate files into several projects so shared code is in one and non-shared code/data in separate individual projects.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
  • So you mean with the express edition I should make 4 different solution files? – borrrden Apr 26 '13 at 04:13
  • If it works for you it may be easiest option. If you care manly about one and are ok to build the rest via command line (or automated build system if you have one) having one solution could be easier (you will not need to update several project on each change). You can check how conditional include look like in this [question](http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/ed141cf9-4f6a-4ed4-b3e8-e23794fe017f). Basically if you are ok with manual editing/command line tools single project could work. – Alexei Levenkov Apr 26 '13 at 04:22
1

Here's a guide to create multiple projects and share the copy of references:

When using open source libraries, should we compile against the source or the binaries?

and this is a similar one, for the references are built with some project in the solution:

How do you organise open-source Visual Studio projects with open-source dependencies?

Note that ..

you can create the projects and share the source file;

you can create the projects and make them have some relation of dependent;

but, you cannot create the projects and share the source file and make them been dependencies to each other directly.

For the Manifest references file 'XXX.exe' which is not problem, I found an external link of a solution around that:

How to Resolve the ‘Manifest Reference file ‘XYZ’ is not part of the payload

Community
  • 1
  • 1
Ken Kin
  • 4,503
  • 3
  • 38
  • 76
  • Hmm, those conditions are OK. However, your answers deal with multiple DLLs and one EXE. I have one DLL, and multiple EXE projects and I only want to build one at a time. – borrrden Apr 26 '13 at 05:23
  • @borrrden: That would be a simpler case, however, the question is back to why you encountered the issue, do you copied all the things and only created `csproj`s? Or you created the projects first, then add the files? – Ken Kin Apr 26 '13 at 05:34
  • I duplicated the csproj. Right now I have two EXE file projects, and when I choose "Build Solution" I get the manifest file error (For the second included manifest. It complains about not being able to find App1.exe from App2.exe, but I have not setup any relation between them). – borrrden Apr 26 '13 at 05:42
  • Nevermind, I needed to change the build path (they were building to the same folder and that's why only the first manifest was used) – borrrden Apr 26 '13 at 05:45
  • Anyway, this answered the question and pointed me in the right direction for the error so I will accept it. I think my case is a bit odd. – borrrden Apr 26 '13 at 05:58
  • 1
    It did! I don't have the error anymore, now I am on to my next problem. – borrrden Apr 26 '13 at 06:13