Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / IDE / September 2005

Tip: Looking for answers? Try searching our database.

Add Linked Files to new C# Project

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tony Maresca - 16 Sep 2005 23:39 GMT
I have created my own derivative of the C# DLL
wizard (New Class Library), and I need to link
several source code files into the project, but
without adding the files to the project folder.

These .cs files are shared by many projects
that are to be built with this wizard, so I do
not want to copy the files to each project's
folder, but rather have them linked to the
project from their existing location.

The AddFilesToCSharpProject() wizard function
is cryptic to the point where I am completely
baffled by how to achieve this.

Any tips are appreciated.

Signature

Tony M.

Carlos J. Quintero [VB MVP] - 19 Sep 2005 09:58 GMT
Hi Tony:

The AddFilesToCSharpProject uses templates and does the following (more or
less):

- It gets the template file.
- It copies it with a temporary name to a temporary folder.
- It perform some replacements of the template placeholders by actual values
(class name, etc.)
- It copies the modified temporary template to the destination folder.
- It removes the temporary template
- It opens the file

The key is that the wizard uses:

var projfile = projItems.AddFromTemplate(strFile, strTarget);

The ProjectItems collection class has 4 methods to add files:
AddFromDirectory, AddFromFileCopy, AddFromFile, AddFromTemplate.

Both AddFromTemplate and AddFromFileCopy, by definition, copy the file to
the destination folder. If you want to link a file rather than copying it,
you should use AddFromFile. Finally, just for completeness, AddFromDirectory
copies all files of the given directory recursively to the target directory.

Another approach instead of using AddFromFile in the script is to use a
modified project template which already contains the linked files, and
therefore the script does not have to deal with them.

For more information, check the help files of Visual Studio about those
methods. Also, chapter 9 "Visual Studio .NET Wizards" of the book "Inside
Microsoft Visual Studio .NET", Microsoft Press, by Craig Skibo and others is
also invaluable.

Signature

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com

>I have created my own derivative of the C# DLL
> wizard (New Class Library), and I need to link
[quoted text clipped - 12 lines]
>
> Any tips are appreciated.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.