Macro needed?

T

Tim Marsden

Hi

I wish to automatically fill in the assembly attributes (i.e <Assembly:
AssemblyTitle("")> etc) in my assembly.vb files in serveral projects in my
solution. Is there a way of doing this, perhaps with a macro?

Regards
Tim
 
G

Gary Chang[MSFT]

Hi Tim,
Is there a way of doing this, perhaps with a macro?

If you want to play it with a VS.NET IDE Macro, maybe you can take a try on
Edit.Find/Replace function:

Sub SetAssemblyTitle()
Dim prj As Project
Dim file As ProjectItem
Dim AssemblyTitle As String
For Each prj In DTE.Solution.Projects
For Each file In prj.ProjectItems
If file.Name = "AssemblyInfo.vb" Then
file.Document.Activate()

DTE.ExecuteCommand("Edit.Find")
DTE.Windows.Item("AssemblyInfo.vb").Activate()
DTE.Find.Action = vsFindAction.vsFindActionReplace
DTE.Find.FindWhat = "<Assembly: AssemblyTitle("""")>"

Select Case prj.Name
Case "Project1"
AssemblyTitle = "MyApp1" 'Set your assembly
title here
Case "TProject1"
AssemblyTitle = "MyApp12"
'...
'...
End Select

DTE.Find.ReplaceWith = "<Assembly: AssemblyTitle(""" +
AssemblyTitle + """)>"
DTE.Find.Target = vsFindTarget.vsFindTargetCurrentDocument
DTE.Find.MatchCase = True
DTE.Find.MatchWholeWord = True
DTE.Find.Backwards = False
DTE.Find.MatchInHiddenText = False
DTE.Find.PatternSyntax =
vsFindPatternSyntax.vsFindPatternSyntaxLiteral
DTE.Find.Action = vsFindAction.vsFindActionReplace

DTE.Find.Execute()
DTE.Find.Execute()

DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close()
DTE.ActiveDocument.Save()
file.Document.Close()
End If
Next
Next
End Sub


Wish it helps!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
G

Gary Chang[MSFT]

Hi Tim,

By the way, if you just want the project's name as your assembly title, you
can simplify the code as :

'Delete the Select Case code block and modify the following code with
DTE.Find.ReplaceWith = "<Assembly: AssemblyTitle(""" + prj.Name + """)>"


Thanks!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 
G

Gary Chang[MSFT]

OK, Tim, I am very glad to know my code works for you!


Good Luck!

Best regards,

Gary Chang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
 

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