Is a custom project hierarchy possible for C# projects?

S

SpookyET

/FooProject
/bin (release)
/doc
/src (only *.cs)
/temp (obj files)
/test (debug)
/build
/Visual Studio 2003
/Visual Studio 2005

I want the solution and project files in the IDE directories, and I want
those project files to have the source code root directory point to /src
and the object files point to /temp. I cannot figure out how to make
Visual Studio do this. It wants the project files in the same directory
as the source code. I'm using Visual C# Express Beta 1. C++ project
files have <Filter>, which looks like a directory in the solution
explorer, that can point to anywhere on disk. I am aware that one can
link files, but this is not enough. I'll have to create the files outside
of visual studio because "Add New File" won't add it to the right
directory. I need to link folders (don't know how) or set the root
directory to /src like I want to. Why are the Visual Studio Team being
despotic about C# projects?

C++ project file:

<Filter Name="My Foo Files" Filter="h;hpp;hxx;hm;inl">
<File RelativePath="..\..\..\src\Foo.h"></File>
<File RelativePath="..\..\..\src\Foo2.h"></File>
<File RelativePath="..\..\..\src\FooFoo.h"></File>
<File RelativePath="..\..\..\src\Bar.h"></File>

You can also have a filter inside this filter for a subdirectory.
</Filter>

In C++ projects, you can also set the obj folder to wherever you want. It
gives full control over how you want to manage the project.
Please help!

Thank you!
 
N

Nicholas Paldino [.NET/C# MVP]

SpookyET,

Have yout tried starting with a blank project/solution, and then adding
things to that? It's much easier to get the structure you need by doing
that.

Also, I believe you should be able to create directories in your sub
projects like you want, and place your source files in those sub
directories.

As for the obj files, you will have to go into the project file and
modify it yourself to do that. The Express edition should be using the
MSBUILD system in order to compile the project. However, it probably will
require you to go to the master build files on the system (they are in the
..NET install directory) and change those, or replicate the tasks in your
project file.

Hope this helps.
 
S

SpookyET

Mr. Paldino,

Starting with a blank solution does not help. Visual Studio wants source
files coupled with .csproj files. The file hierarchy that I want
decouples the project files from the source code and also have them under
different root directories.
This is how VS wants its directories.
/Foo
/Foo/Foo.csproj
/Foo/Foo.cs
/Foo/Bar/
/Foo/Bar/Bar.cs

Obviously, the hierarchy that I want goes against it. MSBUILD does not
care where your files reside on disk. This is a Visual Studio problem.
Also, the schemas that define the MSBuild tags in the .NET directory do
not define the VS project files. MSBuild allows you to have additional
tags that you define like <AppDesigner> that are useful for other tools,
which it ignores. However, those schemas are missing. The URL for the
..csproj "http://schemas.microsoft.com/developer/msbuild/2003" returns 404.

PS: You don't have to modify the master files to change something. You
can overwrite settings in your project files. It works like CSS.
 
N

Nicholas Paldino [.NET/C# MVP]

SpookyET,

I understand what you are saying now, and no, you can not decouple the
source and the project file in this manner. The best you could have is the
project file in a directory that is a parent directory of where the source
is.

Also, the VS.NET build system IS MSBUILD for VS.NET 2005, and for the
Express Editions (I believe, since they are locked down versions of VS.NET
2005).

And yes, project files in VS.NET 2005 (and the Express Editions) are
MSBUILD files.

I wouldn't expect the URL for the schema in the file to work either,
since the namespace definition doesn't have to necessarily point to a valid
resource, it just serves as a unique identifier.
 
S

SpookyET

I doubt that these settings are hard-coded. They are either in the
registry or in a settings file. I hope that someone has the answer on how
to change them. Adding <IntermediateOutputPath
..\..\temp\</IntermediateOutputPath> changes the obj dir to ../../temp,
but Visual Studio still creates /obj.
 
S

SpookyET

By the way, MSBuild is decoupled from Visual Studio. It comes with the
..NET Framework, so there is no locked down version.
 
J

James

Spooky,

Can you elaborate on what it is you are trying to accomplish and why? Maybe
if we knew what your ultimate reason was we might be able to suggest a
possible solution. Are you trying to use use to different dev tools at
once? Maybe what you could do is use a source control tool, then the actual
files are stored in a repository and the dev tool no longer matters.

JIM
 
S

SpookyET

I'm trying to make the project hierarchy more organized that would allow
for easier tagging and branching under Subversion. It would also allow
for many different IDEs to store their project files in a subdir under
/build. I've seen many open source projects having a similar project
hierarchy. For example, VCF (Visual Component Framework), a C++ GUI
library similar to Windows Forms, uses a similar hierarchy. I'm trying to
do the same. As I said earlier, Visual C++ projects do no have this
problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top