Adding source files from outside directory WITHOUT them being copiedto the projectdirectory

A

Anders Eriksson

I have some source files that are created via an another program. The
are in there own directory. How do I add those files to my C# project
without them being copied to the project directory?

Since the files changes every time the other program runs I must be sure
that I'm using the last version of the files!

I tried using Pre-build Event Command and copied the files myself, but
then VS2010 complains about that the source is not the same...

// Anders
--
Visual Studio 2010 Pro
C#

English isn't my first language.
So any error or strangeness is due to the translation.
Please correct my English so that I may become better.
 
M

Marcel Müller

I have some source files that are created via an another program. The
are in there own directory. How do I add those files to my C# project
without them being copied to the project directory?

Do not add the files but add the external assembly/project that contains
them instead.
This is the only clean solution.

I tried using Pre-build Event Command and copied the files myself, but
then VS2010 complains about that the source is not the same...

Many version control systems allow project aliases on folders (or
sometimes files too). You could use a link to the external files and let
your version control system synchronize between the different locations.

The dirtiest way is to use a NTFS reparse point (junction) and link the
files into your project.


Marcel
 
A

Anders Eriksson

Do not add the files but add the external assembly/project that contains
them instead.
This is the only clean solution.
Since the other program doesn't create an assembly, just a number of .cs
files (the program is TinyPG, which is an compiler compiler)
I have to create an Class Library project and then we have the same
problem...
I actually found a setting that removed the warning and made it possible
to run the debugger.
Tools - Options - Debug - General - Require source files to exactly
match the original version

Uncheck this value.
Many version control systems allow project aliases on folders (or
sometimes files too). You could use a link to the external files and let
your version control system synchronize between the different locations.
I'm not using any control system at the moment. I will look into it!
The dirtiest way is to use a NTFS reparse point (junction) and link the
files into your project.
Hmmm... Doesn't feel like a good solution ;-)
Thank you very much for your input!

// Anders
 
A

Anders Eriksson

Do not add the files but add the external assembly/project that contains
them instead.
This is the only clean solution.
Since the other program doesn't create an assembly, just a number of .cs
files (the program is TinyPG, which is an compiler compiler)
I have to create an Class Library project and then we have the same
problem...
I actually found a setting that removed the warning and made it possible
to run the debugger.
Tools - Options - Debug - General - Require source files to exactly
match the original version

Uncheck this value.
Many version control systems allow project aliases on folders (or
sometimes files too). You could use a link to the external files and let
your version control system synchronize between the different locations.
I'm not using any control system at the moment. I will look into it!
The dirtiest way is to use a NTFS reparse point (junction) and link the
files into your project.
Hmmm... Doesn't feel like a good solution ;-)
Thank you very much for your input!

// Anders
 
A

Anders Eriksson

I have some source files that are created via an another program. The
are in there own directory. How do I add those files to my C# project
without them being copied to the project directory? [...]

When you add the files to your project (using the "Add Existing Item..."
command), click the triangle on the "Add" button and choose "Add As Link"
instead.

This will set the project to reference the file where it already exists,
rather than creating a new copy of it.

I really must go to the optician!
I can't believe that I haven't seen this...

Thank you very much!

// Anders
 
J

Jeff Johnson

I really must go to the optician!
I can't believe that I haven't seen this...

Thank you very much!

Don't feel bad, I didn't see it either at first. In older versions of the
IDE there was a check box to add a linked file, so when that check box went
away I never noticed that the Add button was now a dropdown button. I
learned about it the last time this question came up.
 

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