 |
|
 |
I looked a many example methods of updating the revision information in VB 2005. This was the only one that worked. I had to update the macro from VC to VB and I could do it based on how easily the code was to read.
|
|
|
|
 |
|
 |
It would seem that the Visual Studio 2008 Express editions do not support macros! Can anyone confirm this or know a workaround?
|
|
|
|
 |
|
|
 |
|
 |
I am getting build error for DTE as "Reference to a non-shared member requires an object reference"
Thank You,
Sampath T.
|
|
|
|
 |
|
 |
I created a new Macro in Visual Studio 2005 (Menu Tools -> Macros) for increasing the Build-Number
There is a shared Member declared in the Macro-IDE (I do not know where this Code exists):
Public DTE As EnvDTE80.DTE2
|
|
|
|
 |
|
 |
with DTE.ActiveSolutionProjects you get the projects in the solution, while the first Project in the list is allways the active project. ActiveProject = DTE.ActiveSolutionProjects()(0) every project has a property "Properties". In these properties, there are two very interesting properties: AssemblyFileVersion and AssemblyVersion You can get these properties by (VB-CODE) Dim VersionProp As [Property] = ActiveProject.Properties.Item("AssemblyFileVersion") (of course, you should add some errorhandlers to get a property and the ActiveProject) The VersionProp.Value is of type String. You can set the value by VersionProp.let_Value("1.0.0.1") Important: Don't forget to save the Project after this change: ActiveProject.Save()
-- modified at 7:22 Monday 23rd April, 2007
|
|
|
|
 |
|
|
 |
|
 |
I can use it in my project. thanks for your writing.
|
|
|
|
 |
|
 |
When the writer (Darrel Liu) mentioned that Microsoft use AA.BB.CCDD.EEFF, I think he was mislead into thinking Microsoft uses this approach internally.
The actual fact is that if the AssemblyVersion attributes it set to 1.1.* then the compiler will replace the * with a CCDD.EEFF equivalent. So it replaces the * with a date and time based version number - thus making this macro redundent.
The code has been useful to me as I've been writing a versioning macro to work with my C#, VB and C++ projects (some solutions I've written are mixed due to legacy reasons). So thanks Darrel for the article either way.
----
AAMP
|
|
|
|
 |
|
 |
I have spent some time to figure out why the namespace, VSLangProj, is not available. It's because I have not added a reference to VSLanProj.dll.
|
|
|
|
 |
|
 |
Does anybody knows how to get the AssemblyVersion value from AssemblyInfo.cs using C#?? I need to display this value in a Web Form.
Raul Macias
raul.macias@act.com
|
|
|
|
 |
|
 |
You can use this code, be sure to change the app name "DatabaseFun.exe" to your exe/dll name.
try
{
System.Reflection.Assembly ASS = System.Reflection.Assembly.LoadFrom("DatabaseFun.exe");
MessageBox.Show("Version : " + ASS.GetName().Version.ToString());
}
catch(System.Exception exception)
{
MessageBox.Show(exception.Message);
}
|
|
|
|
 |
|
 |
You can use the GetName method of the Assembly returned by the GetExecutingAssembly method of the Assembly class in the System.Reflection namespace to retrieve version information for the current executable
MessageBox.Show(System.Reflection. _
Assembly.GetExecutingAssembly. _
GetName.Version.Major)
|
|
|
|
 |
|
 |
hi,
i think a © (copyright-char) in the assembly-file is lost after running the macro.
i initialized the streamreader and streamwriter with "System.Text.Encoding.Default" and everything worked fine.
regards, thilo.
|
|
|
|
 |
|
 |
Hi,
I think there is a problem if the AssemblyInfo.cs file is open while executing the macro. the version in the AssemblyInfo.cs file is updated correctly but the Command "Build.BuildSolution" uses the previous values of the version-info.
can anybody confirm this?
regards, thilo.
|
|
|
|
 |
|
 |
If you are looking for a hands-off way to enumerate through the active solution and increment the build number for *all* C# projects the following modification worked great for me. With this change, all you need to do is run the macro (without regard to the currently selected project) and it will enumerate through all of the C# projects contained within the solution and update the build number. Replace the original BuildNumberAutomation() with this version...
Sub BuildNumberAutomation()
Dim aProject As Project
Dim aVSProject As VSLangProj.VSProject
Dim aProjectPath As String
Try
For Each aProject In DTE.Solution.Projects.DTE.GetObject("CSharpProjects")
aProjectPath = aProject.Properties.Item("FullPath").Value
ModifyBuildNumber(aProjectPath & theAssemblyInfoFilePath)
Next
Catch e As Exception
MsgBox("Unknown Build Number Automation error captured.", MsgBoxStyle.Critical, "Build Number Automation Error")
Exit Sub
End Try
If theBuildSolution Then
DTE.ExecuteCommand("Build.BuildSolution")
End If
End Sub
Of course, you can always replace the literal "CSharpProjects" with "VBProjects" or "VCProjects" to target your desired language. I am not aware of documented support for J# projects, however.
Enjoy!
-bill
|
|
|
|
 |
|
 |
Thanx a lot man, that's very useful!
|
|
|
|
 |
|
 |
Hello,
I have tryed it with VB.NET and it failed at that line
aVSProject = CType(aProject.Object(), VSLangProj.VSProject)
Any clue?
Thanks,
Olivier
|
|
|
|
 |
|
 |
Did you have an open solution with at least one project in it already? Sorry I don't have VB.NET so I can't test it out...
|
|
|
|
 |
|
 |
Yes I did.
I don't know what I changed, but i got it working now.
Thanks,
Olivier
|
|
|
|
 |
|
 |
I tried, but it did not work...
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
|
|
|
|
 |
|
 |
Could you describe how it failed? Or do you mean walkthrough of creating a new macro?
|
|
|
|
 |
|
 |
I created a macro (I think mostly I did not do it correctly) and copied code from you to this macro, after then I tried to load macro project (do I need to do this step?) and failed with message: this project is already loaded. Anyway, I compiled my own C# project, but version number is not changed.
Maybe it is better for you to provide how to do it step by step.
Thanks!!
WWW: http://hardywang.1accesshost.com
ICQ: 3359839
yours Hardy
|
|
|
|
 |
|
 |
OK, here are brief steps:
1) Load your C# project first;
2) Goto menu View -> Other Window -> Macro Explorer;
3) In Macro Explorer, You should be able to see a "MyMacros". Right click on it and choose "New Module...";
4) Name your new module "MyModule" (or something else) and click Open;
5) Right click on "MyModule" and choose Edit;
6) COpy and paste my entire code to the new Macro editor;
7) Save and close the Macro editor, and you can see there's a new macro named "BuildNumberAutomation". Double click to run.
|
|
|
|
 |
|
 |
thanx. plus put this up in the article above.
|
|
|
|
 |