Shared C# source files.

  • Thread starter Thread starter Sijmen Grunbauer
  • Start date Start date
S

Sijmen Grunbauer

Hi,

We have a VS.Net solution with numerous C# projects. Each
time we want to change the AssemblyCopyright or the
AssemblyTrademark, etc, we have to edit the
AssemblyInfo.cs in each project, even thought the
information is the same in all projects.

In C++, we were able to create a shared header file, which
contained #define's for each symbol, and simply include
the header file in each project, and reference the
symbols. However this does not seem obvious with C# in
CS.Net.

How can a use a shared file across all my projects,
without duplicating the code?

Regards,
Sjimen.
 
Hi,

If you use a source control system, you could share the same file across
multiple projects by the source control system's sharing feature. Should any
of the projects have a different version of the file, the file is branched
for that project.

Or, you could simply put the file in some folder on disk and add it manually
to each of the projects (right-click on a project in Solution Explorer and
choose Add Existing Item...).
 
Dmitriy Lapshin said:
Hi,

If you use a source control system, you could share the same file
across multiple projects by the source control system's sharing
feature. Should any of the projects have a different version of the
file, the file is branched for that project.

Or, you could simply put the file in some folder on disk and add it
manually to each of the projects (right-click on a project in
Solution Explorer and choose Add Existing Item...).
Don't know if this is just my machine, but if I try this, VS copies the
file into the project I'm adding it to. So the only way to go for me, is
to share the file via Sourcesafe. is there a way prevent the copy?
Thanks in advance,
Andy
 
Carlos J. Quintero has suggested the following way in the
microsoft.public.vsnet.ide:
In the Add Existing Item dialog, drop down the Open button and select "Link
File".

However, I have just tried it with VS .NET 2002 and there's no such item in
this drop-down box - only Open and Open With... items are there.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
 
If you select Add Existing Item the Open button on the File Dialog drops
down to reveal Link File.

Use this option when adding the file to the project and it will not copy the
file.

Good luck
Brian W



Dmitriy Lapshin said:
Carlos J. Quintero has suggested the following way in the
microsoft.public.vsnet.ide:
In the Add Existing Item dialog, drop down the Open button and select "Link
File".

However, I have just tried it with VS .NET 2002 and there's no such item in
this drop-down box - only Open and Open With... items are there.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
 
Back
Top