PC Review


Reply
Thread Tools Rate Thread

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

 
 
Anders Eriksson
Guest
Posts: n/a
 
      18th Aug 2012
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.
 
Reply With Quote
 
 
 
 
Marcel Müller
Guest
Posts: n/a
 
      18th Aug 2012
On 18.08.2012 10:46, Anders Eriksson wrote:
> 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
 
Reply With Quote
 
 
 
 
Anders Eriksson
Guest
Posts: n/a
 
      18th Aug 2012
On 2012-08-18 10:54, Marcel Müller wrote:
> On 18.08.2012 10:46, Anders Eriksson wrote:
>> 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.

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 tried using Pre-build Event Command and copied the files myself, but
>> then VS2010 complains about that the source is not the same...

>

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
--
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.
 
Reply With Quote
 
Anders Eriksson
Guest
Posts: n/a
 
      18th Aug 2012
On 2012-08-18 10:54, Marcel Müller wrote:
> On 18.08.2012 10:46, Anders Eriksson wrote:
>> 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.

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 tried using Pre-build Event Command and copied the files myself, but
>> then VS2010 complains about that the source is not the same...

>

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
--
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.
 
Reply With Quote
 
Anders Eriksson
Guest
Posts: n/a
 
      18th Aug 2012
On 2012-08-18 19:33, Peter Duniho wrote:
> On Sat, 18 Aug 2012 10:46:47 +0200, Anders Eriksson wrote:
>
>> 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


--
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.
 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      20th Aug 2012
"Anders Eriksson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

>> 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!


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.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
get projectdirectory at designtime Michael Meier Microsoft C# .NET 0 13th Nov 2008 09:31 AM
Can't get mail outside outside of windows mail PacificElla Windows Vista Mail 1 14th Oct 2008 07:29 PM
Adding text outside of margins without text box printing out =?Utf-8?B?UHV6emxlZCBuZW9waHl0ZQ==?= Microsoft Word Document Management 3 13th Sep 2007 04:02 AM
Connectiong to a users session - without locking them out and them having to request it Damon Windows XP Work Remotely 4 26th Jul 2004 02:10 PM
outside reference where there should not be an outside reference.... Heidi Microsoft Excel Worksheet Functions 2 2nd Aug 2003 04:29 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:12 AM.