Groups | Blog | Home
all groups > visual studio .net ide > february 2005 >

visual studio .net ide : Copying references between projects



Carlos J. Quintero [.NET MVP]
2/14/2005 2:37:18 PM
You have to do it by hand or write a macro.

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com


"Ruslan Popov" <ruslan -at- triangularweb -dot- com> escribió en el mensaje
news:%23$yCB6oEFHA.3536@TK2MSFTNGP15.phx.gbl...
[quoted text, click to view]

Ruslan Popov
2/14/2005 3:16:13 PM
Hello,

Is there a way to copy a list of references from one project in a solution
to another project in the same solution? Or one should use the Add Reference
dialog, then Browse for projects or assemblies each time again for each of
the different projects?

--
Yours, respectfully
Ruslan Popov

Carlos J. Quintero [.NET MVP]
2/15/2005 11:13:23 AM
This macro should get you started:

Public Sub CopyProjectReferences()

Dim sSourceProject As String
Dim objProject As Project
Dim objSourceProject As Project
Dim objVSProject As VSLangProj.VSProject
Dim objVSSourceProject As VSLangProj.VSProject
Dim objReference As VSLangProj.Reference

Try

sSourceProject = InputBox("Filename (ex: " &
DTE.Solution.Projects.Item(1).UniqueName & ") source project to copy
references?")

objSourceProject = DTE.Solution.Projects.Item(sSourceProject)
objVSSourceProject = DirectCast(objSourceProject.Object,
VSLangProj.VSProject)

For Each objProject In DTE.Solution.Projects

' If it is not the source project to copy references
If objProject.Name <> objSourceProject.Name Then

objVSProject = DirectCast(objProject.Object,
VSLangProj.VSProject)

For Each objReference In objVSSourceProject.References

If
objVSProject.References.Find(objReference.Identity) Is Nothing Then
objVSProject.References.Add(objReference.Path)
End If

Next

End If

Next

Catch ex As Exception

MessageBox.Show(ex.ToString)

End Try

End Sub
--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com


"Ruslan Popov" <ruslan -at- triangularweb -dot- com> escribió en el mensaje
news:OamTxN0EFHA.624@TK2MSFTNGP09.phx.gbl...
[quoted text, click to view]

Ruslan Popov
2/15/2005 12:51:09 PM
Thanks. Can you give me some clue on such a macros?

Had references been kept in some file, one would be able to copy them
between projects.

--
Yours, respectfully
Ruslan Popov

Ruslan Popov
2/15/2005 1:46:42 PM
Outstanding! Many thanks.

--
Yours, respectfully
Ruslan Popov

AddThis Social Bookmark Button