Multiple projects, Single source file?

  • Thread starter Thread starter Paul Cheetham
  • Start date Start date
P

Paul Cheetham

Hi,

I have two projects where I want to use the same source file in each
project.
If I add the file to each project, then a local copy is made.

I want to be able to have a single source file used by both projects so
that I only have to change one file.
I am using compiler directives within the file, and so I can't just
build it into a DLL and do it that way, I really do need to make both
projects reference the same source file.

Does anybody know how to do this?


Thanksyou.


Paul Cheetham
 
Paul,

Add an existing item to the project. When you do, in the dialog,
instead of clicking "Add", select the drop down box. Select "Add as Link"
and it will just have a link to the file, not copying the actual file to the
project itself.

Hope this helps.
 
Hello Paul,

Right mouse button click to call context meny on the project->Add->Existed
Item and point you class
What's wrong with this?

PC> Hi,
PC>
PC> I have two projects where I want to use the same source file in each
PC> project.
PC> If I add the file to each project, then a local copy is made.
PC> I want to be able to have a single source file used by both projects
PC> so
PC> that I only have to change one file.
PC> I am using compiler directives within the file, and so I can't just
PC> build it into a DLL and do it that way, I really do need to make
PC> both
PC> projects reference the same source file.
PC> Does anybody know how to do this?

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsch
 
Right mouse button click to call context meny on the project->Add->Existed Item and point you class
What's wrong with this? <<

Because, if the file is not in the project folder, VS will copy it
there.
 
The best way is probably to have two phyisical copies on your hard
disk, but have them as a "shared file" in source control so changes in
one place will be copied to the other when you do a "Get Latest". (you
are, of course, using source control, right?)
 
Use "Link" property of Add button as Nicolas said, thus you get link to the file - not the copy. <<

Yes, but you skipped that part in your description of what to do.
 
I agree with James. If you have to share the file, share it in source
control. You will get 2 physical copies of the file, but they will be
linked in source control.
 
I agree with James. If you have to share the file, share it in source
control. You will get 2 physical copies of the file, but they will be
linked in source control.

But that means you have to commit every time you change the shared file, in
order for both projects to see the changes. I like the linking idea.

///ark
 
Whatever works for you.

For me, the problem with linked files is that at least one of the projects
no longer exists as an independent, standalone entity. I share in
source-control, as it means that I can go to a vanilla machine (with VS and
CLR etc), get **just one project**, and I know it will build (allowing for
any necessary GAC entries - mainly 3rd party controls). The linking approach
doesn't do this... you get just the one project and it fails to build
because something is missing.

For my money, this is the best approach, as it allows different developers
to have different projects on the computers (and in their solutions), and
yet it will all just play nicely.

But if it works for you, that's great too.

Marc
 
The best way is probably to have two phyisical copies on your hard
disk, but have them as a "shared file" in source control so changes in
one place will be copied to the other when you do a "Get Latest". (you
are, of course, using source control, right?)


No I'm not using source control, but a single shared file is exactly
what I need, as the two projects are tied together.


Thanks.


Paul
 
If it works for you, then use it. The problem that I encounter with linking
a file is it doesn't scale well if you have multiple developers and multiple
projects. You will find that you run into situations where the developers
on other projects have to "just know" to get the latest version of your
project in order to build their own projects. Also, if you are just linking
and using

Sharing in source control moves this knowledge "up" into the source control
tool. This also makes it less likely that one of the teams will modify the
linked file outside of your project (without source, you would end up with 2
different "current" versions of the same file).
 
Source Control is a great advantage, even for the solitary programmer
(like me). You get a change history. You get to share common file.
You get a single point of backup for all you source code (that saved me
recently!) VSS is free with Visual Studio. SourceGear's Vault is
free for a single user (Vault requires IIS and a database). CVS &
Subversion are just free (require PHP and a database)
 
Back
Top