Visual Studio Macro: Set ‘CopyLocal’ To False For All C# Project References

I wrote this macro for work and thought other people might be able to use it.

Public Sub MakeAllRefsCopyLocal()
    For Each aproj As Project In DTE.Solution.Projects
        If (aproj.Kind = PrjKind.prjKindCSharpProject) Then
            Dim vsProj As VSProject = CType(aproj.Object, VSProject)
            For Each ref As Reference In vsProj.References
                Try
                    ref.CopyLocal = False
                Catch ex As Exception
                End Try
            Next
        End If
    Next
    MsgBox("All References Made To Copy Local")
End Sub
  • Ciencia
    Note: you need to add the following line at the beginning in order to this macro work:

    Imports VSLangProj
  • Christriano Coutinho
    Good Job. I was looking for something like this.

    Thanks!
blog comments powered by Disqus