Auto Increment Build Numbers for C# Projects in VS.NET 2003

Ok… I was really sick of incrementing the build number, each time that I built my project. Also, I know that I could use the NAnt task to increment build numbers, but this project does not have NAnt configuration files, and I don’t feel like writing them just to increment the build number. Since no one else has apparently created one of these for Visual Studio .NET C# projects, I hacked together this macro to do it autonomously. It basically opens up all projects in the solution (you can change this to only the active projects) and tries to open the corresponding AssemblyInfo.cs file in each project. You can specify which field you would like to increment, also. To install, do the following:

  1. Tools->Macros->New Macro Project
  2. Call it whatever you want. Example BuildMacros
  3. Alt-F11 (Opens up the Macros IDE)
  4. Copy and paste the macro code below, in the Module1 code.
  5. Rename Module1 macro to BuildIncrementer
  6. Open up EnvironmentEvents macro under BuildMacros (Or whatever you named your macro project)
  7. Add the following under the Automatically generated code region in the EnvironmentEvents macro

Private Sub BuildEvents_OnBuildDone(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildDone

    IncrementBuildNumber()

End Sub

This is the macro:


 

Option Strict Off
Option Explicit Off
 
Imports EnvDTE
Imports
System.Diagnostics

Public Module BuildIncrementer

    ‘ From http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q237/8/70.ASP&NoWebContent=1
    Function GetProjectDir(ByVal FullName)

    Dim proj_path proj_path = Split(StrReverse(FullName), "", -1, 1)
    Dim count
    count = UBound(proj_path)
    Dim full_path full_path = ""

    Dim i
    For i = 1 To count

      full_path = full_path & "" & proj_path(i)

    Next

    GetProjectDir = StrReverse(full_path)

    End Function

    ‘ objSel- Represents the TextSelection object highlighting the version string to increment
    ‘ count- Represents the position, in the version string, to be incremented
    ‘ incrementBy- Represents a number to increment the version number by

    Sub ReplaceText(ByVal objSel As TextSelection, ByVal count As Integer, ByVal incrementBy As Integer)

      Dim strTemp As String() = Nothing
      Dim strTemp2 As String = ""
      Dim i As Integer = 0

      strTemp = objSel.Text.Split(".")
      Dim s As String
      For i = 1 To strTemp.Length – 1

        If i = count Then

          Dim oldValue As Integer = strTemp.GetValue(i)
          Dim newValue As Integer
          newValue = oldValue + incrementBy
          Dim strNewValue As String = newValue
          strTemp.SetValue(strNewValue, i)
          Exit For

        End If

      Next i

      objSel.Text = Join(strTemp, ".")

    End Sub

    ‘ This event will be triggered after every build of a project
    ‘ You can modify the code below to only update projects that are active
    ‘ It currently will scan all projects in the solution for AssemblyInfo.cs files
    ‘ to update.

    Sub IncrementBuildNumber() 

      ‘Comment the follow 3 lines, if you want the build number to increment even if the build fails
      If DTE.Solution.SolutionBuild.LastBuildInfo() <> 0 Then

        Exit Sub

      End If

      ‘ Change this, if you would only like to modify the AssemblyInfo file in active project files
      ‘ For Each proj As Project In DTE.ActiveSolutionProjects

      For Each proj As Project In DTE.Solution.Projects

        Dim full_path
        full_path = GetProjectDir(proj.FullName)
        ‘ Attempt to open the AssemblyInfo.cs file
        full_path = full_path & "AssemblyInfo.cs"

        Try

          DTE.ItemOperations.OpenFile(full_path).Activate()
          Dim activeDoc As Document = DTE.ActiveDocument
          Dim objSelection As TextSelection
          objSelection = DTE.ActiveDocument.Selection
          Dim objStartPosition As Integer

          ‘ Get the text between AssemblyVersion(" and ")
          objSelection.FindText("AssemblyVersion(""")
          objStartPosition = objSelection.BottomPoint.DisplayColumn
          Dim objEndPosition As Integer
          objSelection.FindText(""")]")
          objEndPosition = objSelection.AnchorPoint.DisplayColumn

          ‘ Get back to after the AssemblyVersion" part
          objSelection.StartOfLine()
          objSelection.FindText("AssemblyVersion(""")
          objSelection.Collapse()
          objSelection.MoveToDisplayColumn(0, objEndPosition, True)
          ReplaceText(objSelection, 3, 1)
          activeDoc.Close(vsSaveChanges.vsSaveChangesYes)

        Catch

        End Try

      Next

    End Sub

End Module

My “theme-park” dream

Last night/this morning I had a dream, which I remember some of the details from.  I was at a theme park, waiting in line to go on this ride… It was a water ride.  This water ride consisted of two cars on separate rails.  These cars were 2 seaters, at most, though I think only one person at a time, rode in each car throughout my dream… when people got in the cars, and the ride was ready, the cars backed up a “track” almost vertically.  The cars then proceed to ride down the track and splash in the water.  A pretty uneventful ride, if I do say so myself… So for part of this dream, I was waiting in line and I watched the ride I remember seeing one person, who jumped out of a car, did 2 & 1/2 flips and landed pretty awkwardly in the water below.  I remember thinking, as I approached the front, how the person was not injured, and how they actually pulled it off.  The rest of the dream gets somewhat foggy… I know that I rode the ride and when I was getting off, people were leaving the amusement park in a hurried fashion.  Sorry folks, but that’s pretty much all I can remember…

Depression and thoughts

I wrote this last night before going to bed.  I felt as though I needed to get it off my mind…

 

How skewed I find myself today… I believe that this is due to the depression that has been building up throughout the course of today.  Since Rob left yesterday, Rachel has shown little interest in things around her.  That is unfortunate, since it seems to be rubbing off onto me.  Not to be totally selfish, I think that she must be going through a pretty depressed moment, as she faces the next 2 months without seeing the love in her life.  I feel for her, and I would like to offer her a better solution, other than sleeping away the feelings.  Ultimately, I do not think that sleeping for long periods of time brings the person out of their depression.  It is only the involvement in activities, getting ones mind off of the major subject causing said depression.  Enough of that though…

I have been contemplating my world quite a bit, today.  I have to admit that I feel much older than I did two days ago.  I recently found out that one of my best friends (Andy Noth) from Green Bay is engaged.  I would like to congratulate Andy & Amy and wish them the best.  This coupled with the other engagement announcement from another GB couple, Jake & Brooke, has taken me out of the “college student” role and thrust me into the “life after college” role.  As I look around at those near my age, and those close to me, I see happy couples going about the life laid out for them.

This brings me to yet another thing that has shrouded my mind lately.  It seems that the common thing to do is to get married between ages 25 & 30.  In general, ladies like closer to 25, while guys would prefer 30 or older.  I myself, feel as though I will miss that range.  I just don’t picture myself settling down into the typical family role.  By the typical family role, I picture a middle aged guy coming home from a mediocre job, to find dinner ready at 6:00.  After dinner, watch TV and finally go to bed, only to do it all over again.  This type of life style seems so unfulfilling to me.  Granted, the love part is what keeps things warm and makes it all worth it.  Then again, maybe I’ll find someone who will make me feel as though I should settle down with them, only to leave my dreams for the dreams of our children.  And so the cycle continues… As a side note, I did feel as though I met that person once before, but it apparently was not meant to be…

The final part is about the whole money thing… Oh, I have many thoughts on this subject.  I actually had one major feeling toward my current employment situation until I read some excerpts from Einstein.  So taken in by what I have read tonight, I am going to hold off on my original plans and do some thinking on how I want to approach my future.  How much do I feel I should sacrifice for a green piece of paper?  Are the sacrifices necessary?  Do I play the existing game or change the rules of the game?  So much of how this world works frustrates me.  It’s not that I can’t get involved and add my 2 or 4 cents worth, it’s just how things work that really pisses me off.  The fact that population control has a higher price tag than exploration / research.   I agree with Einstein in that it amazes me how the human race, with how intelligent we are, still practices and makes a point to have wars and bickering be the backbone of society. 

Anyway, I have to admit that putting this down in writing has lifted some of the weight of the world.  I hope that I am able to express myself like this, if not more, in the future.  For now, I’m back to reading some more of Einstein’s genius.

Dreams

I saw something today that sparked a little bit of an interest in me.  Here is a post about someone’s dream.  I’ve been known to have a few weird dreams now and again.  Not to mention getting up and doing all sorts of interesting things while sleeping.  So, if I remember my dream when I hop on the computer in the morning, I’ll jot down whatever I can recall.  It’s been a while since I’ve had a real vivid dream, so I’m about due…

Tim Reynolds

I recently went to the Tim Reynolds show here in Baltimore.  Actually, it was the night that hurricane Isabel was supposed to hit.  When I was driving there and back to my house, it was only windy outside with sprinkles here and there.  Later that night (Friday morning), one of the roads that I drove down became flooded.  So, I guess I was pretty lucky with that.  Tim had an excellent opening act for his show.  It was Kaki King, this girl who is phenomenal on guitar.  For some of her songs, she had both hands on the fret board, tabbing with all 8 fingers.  If you get a chance, check her out.  Tim was, as expected, just plain awesome.  He played so many styles that night, that it would be hard to classify him into a specific genre.   The recommendation to go see him goes without saying.  All in all, it was a pretty intimate setting though, with about 50 people at the newly designed Funk Box (http://www.thefunkbox.com). 

Also, it is worthy to note that http://www.timreynolds.com has been updated.  This update is quite welcomed.  If you didn’t visit that site before, consider yourself lucky for not dealing with the old interface.  Also, Tim is very open to sharing of music, so the have an ftp site to download some of his shows.

Blog start

Today I started the blog.  I setup 3 websites today to be hosted on my home server.  http://www.biasecurities.com, http://www.eclecticvibe.com, and http://www.stellarteller.com.  Bia Securities will act as the parent to all of my websites.  I am going to make Bia Creations my main “portal” for software development.  Eclectic Vibe belongs to my friend Dan, but if he is not interested in what I’ve set up, then I am going to make it all things music related.  Stellarteller is for my Mom.  She is a wonderful story teller, and I want her to have a place to show people and talk about her experiences.

I have other web domains registered, so I might be adding those later, as I find a use for them.  After reading this article about host header names, I must admit that I feel very comfortable hosting multiple domains on my dinky server.  Since the amount of traffic to these domains is trivial, it beats shelling out $10 or so per month, per domain for sites that very few people will see.

Jeana – Last attempt… 3 months after the split

Today I talked with Jeana.  Basically I called to confirm whether or not I should move to Minneapolis to be with her.  She told me again that she didn’t think it would work out because we have different views. 

She used the drug thing again as a major point.  When I told her that that was behind me, she brought up our views on finance, politics, and religion.  She said that someone said that people should have those views in common.  I disagree… maybe people need to have opposite views to be interesting to each other… maybe not though. 

Anyway, we have the same view on finance, but the other two views are different.  I’m not completly aware of her political view, but I do know that it differs from mine.  I can remember last christmas when we were home… she automatically took her Dad’s view on politics, which is understandable… though, at the time, it seemed like she just took it with lack of reason.  Anyway, I’m deviating.

I told her that I hoped that she wasn’t basing everything about us not being together from that phone call… she said that it was a combination of phone calls, which stemed from that call.  A few of them, I made some mistakes with some of my statements.  The one about drugs was misplaced.  I was thinking short-sighted and saying what I had hoped since junior year of highschool…. as I look at it now, I don’t think that I will smoke into my grey years.  It might be an occasional thing, but it’s not going to be a major issue for me. 

Also, her sister is moving to Minneapolis in August, so that will probably cheer her up and get her mind off me.  I really hope that she has properly thought this through because at this point, I feel quite drained from the amount of time and thought I have put into moving. 

One thing that she brought up that seemed out of place was that if I moved there, it would weird her out.  I could see that… being that it would make her uncomfortable if I hover around her, instead of allowing her to get on with her life.  I just wanted to offer my companionship with her, if she desired it.

She also brought up that if I would have said, 6 months ago, that I was going to move there, she would’ve been all for it.  Which basically points fingers to that downfall of events that happened.  I can’t help but think that calling her Julie’s name added to this madness.

Jeana tried to comfort me by saying that there is someone perfect for me out there, with more in common than what we have.  She did bring up the comfort zone type of saying too.  Jeana mentioned that our relationship was very comfortable, but we never really got to talk about our views on major issues.  She said that it could be easy going back into our relationship, but she is ready to move on.  She said that she has learned a lot about herself and what she wants from relationships.

So right now, I sit here pretty depressed thinking what if, what if… etc.  I know things could have changed, if I would have said this or not have said that.  I don’t know if this is a good thing for me, or if I’ll regret this later in life.  I do know that I want to respect her and not move there.  I will be moving with Rob and Rachel to Baltimore and start fresh, I guess…

So, while I’m reading this looking back on my last days in Milwaukee, picture myself sitting at my desk in boxers and a white t-shirt, fan blowing on me… pretty much in tears, while feelings rush through me from all directions and times.

The uncertanty is so great that I feel slightly uncomfortable.  Basically, I’m feeling like I did when I first went to college.  Except now, I know that I’ll be starting fresh with some great people in my life.

Well, I’m going to finish packing for the trip to Microsoft.  That is also adding to my wave of emotions.  Till next time…

Update: Ported over from my Journal in my old PhpNuke setup.

Split Up -> Talked with Rachel

Well, I talked to Rachel about the whole situation.  She told me again that her and Rob go through that type of argument a few times yearly.  Anyway, she told me to give Jeana a call because girls expect the guy to initiate first. 

So I called up Jeana and we carried on a conversation somewhat like we would any other time.  There was one point at the end, where it appeared as though both of us had exhausted our topics to talk about.  At this point, I gave her an out, and asked if I should let her go.  She said yeah, and told me that Julie called… Part of me doubts that, but I do think that she talked with Julie afterwards. 

At the end of the phone call, we said good night & i told her that I loved her.  She said it back, but it appeared to me that she was waiting for me to say it first.  Maybe this goes along with how girls want the guy to initiate things first. 

The only thing that I’m completly sure about now, is that girls are fucking retarted with their little mind games.  It’s enough to piss a person off.  And this realization came to Rachel, as I talked with her, and she agreed completly.

Update: Ported over from my Journal in my old PhpNuke setup.

Update on the split up

Well… I went to Michigan this weekend, and had a really good time.  We gamed mostly, and I *hopefully* fixed Bill’s computer, by installing WinXP & changing all drives to NTFS.  I talked to him briefly about the situation, and he basically said that he has been in the same position, but he didn’t really offer that much insight, unfortunately. 

So now it’s Monday, and I decided that I should get a girl’s perspective on the issue.  I talked with Rachel, for about 10 minutes tonight, about the whole situation.  She basically said that her and Rob had similar arguments and that it’s just something that comes up now and again.  The only thing different in their situation is that she used to smoke, so her thoughts might be a little different than Jeanas. 

Anyway, Rachel told me that it was pretty much up to me to call Jeana.  That if it was Rachel in that position, she would be expecting a call from her boyfriend.  So I called Jeana, and we had a pretty good talk.  We seemed to avoid the topic, and carried on a "normal" conversation.  We talked about general things such as what we did this last weekend, how work/school was going, etc…. After getting through all of that, we both were silent for a while, and I kind of sensed that she hessitated bringing it up.  Personally, I didn’t really want to talk about it, either, since I really didn’t have anything new to say about the issue. So rather than drag the phone call on and make both of us feel uncomfortable, I let her go.

So now I sit wondering what this is all about.  Rachel mentioned that every fight that girls have with their boys is a "test" to see how much the other loves them.  If this is a test, I think it sucks… Anyway I’m just going to play this by ear and see what happens.

In the mean time, the thought of single life has sparked an interest in me.  Maybe it’s just the warm weather that we’ve had this past weekend.  I dunno… to be continued 🙂

Update: Ported over from my Journal in my old PhpNuke setup.

Split up

Well… tonight, Jeana & I decided that we should take some time off from each other.  It kind of came as a shock to me, but it’ll be interesting none the less.  I feel as though we haven’t stopped our relationship since last fall, so maybe this is a good thing.

The main reason was that I turn into a non-social person when I smoke.  That and when we talked about it, I defended my smoking, rather than focused on her feelings.  Strange, random thoughts are going through my head.  Basically summed up by "girls are confusing."

So now… who knows.  I don’t know if this is one of those "tests" that girls do, or what.  I’m going to talk to Rachel when I get back and see what she has to say about it all.  In any case, it’ll be nice to hear a neutral girl’s opinion on the matter. 

Btw, I’m kind of saddened that it took this event for me to write in this journal.  I think this is kind of cool.  Anyway, till next time… I’m sure I’ll have some more thoughts on this or something.

As for this weekend, I’m headed over to Saginaw to visit Bill.  I’ll see if he has anything to add too… I do plan on waiting the weekend and not calling her till I talk to Rachel, or if Jeana calls first.

Update: Ported over from my Journal in my old PhpNuke setup.