By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,993 Members | 1,984 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,993 IT Pros & Developers. It's quick & easy.

Multiple projects, Single source file?

P: n/a
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
May 25 '06 #1
Share this Question
Share on Google+
13 Replies


P: n/a
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Paul Cheetham" <PA******@dsl.pipex.com> wrote in message
news:OL**************@TK2MSFTNGP04.phx.gbl...
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

May 25 '06 #2

P: n/a
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 Nietzsche
May 25 '06 #3

P: n/a
>> 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.

May 25 '06 #4

P: n/a
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?)

May 25 '06 #5

P: n/a
Hello James,

Use "Link" property of Add button as Nicolas said, thus you get link to the
file - not the copy.
Right mouse button click to call context meny on the
project->Add->Existed Item and point you class

JC> What's wrong with this? <<
JC> Because, if the file is not in the project folder, VS will copy it
JC> there.
JC>
---
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 Nietzsche
May 25 '06 #6

P: n/a
>> 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.

May 25 '06 #7

P: n/a
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.

<ja**********@gmail.com> wrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
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?)

May 25 '06 #8

P: n/a
"J.Marsch" <jm*****@newsgroup.nospam> wrote in message
news:uI**************@TK2MSFTNGP03.phx.gbl...
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
May 25 '06 #9

P: n/a
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
May 26 '06 #10

P: n/a

Thanks for that!
Just what I wanted.
Paul

Nicholas Paldino [.NET/C# MVP] wrote:
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.

May 26 '06 #11

P: n/a
ja**********@gmail.com wrote:
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
May 26 '06 #12

P: n/a
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).
"Mark Wilden" <Ma********@newsgroups.nospam> wrote in message
news:u6**************@TK2MSFTNGP02.phx.gbl...
"J.Marsch" <jm*****@newsgroup.nospam> wrote in message
news:uI**************@TK2MSFTNGP03.phx.gbl...
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

Jun 5 '06 #13

P: n/a
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)

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


Jun 6 '06 #14

This discussion thread is closed

Replies have been disabled for this discussion.