Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have many projects in my VS solution. It is annoying to add version resource to every project manually one by one(i.e.: right click on project, add resource, then choose version from dialog, and click new).

How to do this at once for all the projects? Any Visual Studio macro or some other option?
Posted
Updated 5-Aug-10 6:34am
v2

Do it for one project, then open the resource file (.rc) as source (right click and open with text editor). Copy the VS_VERSIONINFO block, and paste into all new projects' resource files.

Fastest way to do it without a program that processes your resource files...
 
Share this answer
 
If you open an rc file with the text editor, you can see how a version info block is inserted; you can refer to VERSIONINFO Resource (Windows)[^] on the MSDN for the full syntax.

Said that you can write a macro for Visual Studio that look at the rc file of your project, searches for the VERSIONINFO inside it, and if it doesn't exist the macro will add a standard one.
 
Share this answer
 
Thanks for answer, but you don't understand my problem.

Visual Studio creates (.rc) files after we add resource. I know how to edit this file, even for all projects but when this files exist.

The problem is that i want to create rc file for every project at once. I don't want to click at every project manually.

When adding a rc file to an empty dll project, VC will generate a filename.rc file and two files automatically: resource.h and filename.aps.

Here is the info about files: http://msdn.microsoft.com/en-us/library/fywbdhak%28VS.71%29.aspx[^]

So, I want to add rc file automatically for all projects.

I tried to write some macro for VS, but i'm only able to launch the AddResource dialog for ech project:
DTE.ExecuteCommand("Project.AddResource")


Any suggestion?
 
Share this answer
 
I found this searching on the MSDN and I think it could be a good starting point for your task:

How to: Programmatically Create Project Items[^]
 
Share this answer
 
Hi, thanks but it is very hard to use that.

I have wrote some macro. Fortunately when we launch a dialog the files are genereted, and only what i have to do is to close dialog for every project (with esc). It's faster but it is not a good way to solve this problem.

If you know how to do this, out of the VS, let me know.

Macro (for selected projects, it depends if we have projects in folders or not):
Imports System
Imports System.IO
Imports EnvDTE
Imports EnvDTE80
Imports System.Diagnostics
Imports Microsoft.VisualStudio

Public Module Module1


    Sub Macro1()

        Dim name As String
        Dim solutionName As String
        Dim subfolderName As String

        Dim count As Int16
        count = 0

        name = DTE.Solution.FullName
        solutionName = Path.GetFileNameWithoutExtension(name)

        Dim projects As Object
        projects = DTE.ActiveSolutionProjects


        For Each proj As Project In projects

            If (count <= 0) Then
                subfolderName = proj.Name

            End If

            If (count > 0) Then

                DTE.ActiveWindow.Object.GetItem(solutionName + "\" + subfolderName + "\" + proj.Name).Select(vsUISelectionType.vsUISelectionTypeSelect)
                DTE.ExecuteCommand("Project.AddResource")
            End If
            count = count + 1

        Next

    End Sub
End Module
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900