简体   繁体   中英

What is the Visual Studio / C# equivalent to Xcode build targets?

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.

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 (ie 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM