Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Apr 22nd, 2010 | Syntax: C# | Size: 3.63 KB | Hits: 100 | Expires: Never
Copy text to clipboard
  1.    Private Sub BuildEvents_OnBuildBegin(ByVal Scope As EnvDTE.vsBuildScope, ByVal Action As EnvDTE.vsBuildAction) Handles BuildEvents.OnBuildBegin
  2.  
  3.     End Sub
  4.  
  5.     Private Sub BuildEvents_OnBuildProjConfigBegin(ByVal Project As String, ByVal ProjectConfig As String, ByVal Platform As String, ByVal SolutionConfig As String) Handles BuildEvents.OnBuildProjConfigBegin
  6.  
  7.         If InStr(1, ProjectConfig, "Debug", 1) Then
  8.             Module1.WriteToOutputBuildPane(vbCrLf & "Debug mode, still counting" & vbCrLf)
  9.             'Exit Sub
  10.        End If
  11.  
  12.        ' get ver filename
  13.  
  14.         Dim res_filename As String
  15.  
  16.         res_filename = DTE.Solution.Projects.Item(Project).FullName 'DTE.Solution.FullName
  17.        res_filename = Path.ChangeExtension(res_filename, ".ver")
  18.  
  19.        Dim dt_filename As String
  20.        dt_filename = Path.ChangeExtension(res_filename, ".buildtime")
  21.  
  22.  
  23.        Dim projpath As String
  24.        projpath = DTE.Solution.Projects.Item(Project).FullName
  25.        ''Module1.WriteToOutputBuildPane("Polku: " + projpath)
  26.        If (projpath.ToUpper().StartsWith("HTTP:")) Then
  27.            Module1.WriteToOutputBuildPane("Polkua '" + projpath + "' ei tueta.")
  28.            Exit Sub
  29.        End If
  30.  
  31.        ' open VERSION FILE and increment build number
  32.         Module1.WriteToOutputBuildPane(vbCrLf & "--------------------------------------------------" & res_filename & vbCrLf)
  33.  
  34.         Module1.WriteToOutputBuildPane(vbCrLf & "Build trigger launched for " & res_filename & vbCrLf)
  35.  
  36.         Dim msg_text As String
  37.  
  38.         If File.Exists(res_filename) Then
  39.  
  40.             Dim line As String
  41.  
  42.             Try
  43.  
  44.                 Dim sr As StreamReader = New StreamReader(res_filename)
  45.                 line = sr.ReadLine()
  46.                 sr.Close()
  47.  
  48.             Catch ex As Exception
  49.  
  50.                 Module1.WriteToOutputBuildPane(vbCrLf & _
  51.                                           "Version file read failed : " & ex.Message & vbCrLf)
  52.  
  53.             End Try
  54.  
  55.             line = Right(line, line.Length - 5)
  56.  
  57.  
  58.             Try
  59.  
  60.                 Dim sw As StreamWriter = File.CreateText(res_filename)
  61.                 sw.WriteLine("build {0}", line + 1)
  62.                 sw.Close()
  63.  
  64.             Catch ex As Exception
  65.  
  66.                 Module1.WriteToOutputBuildPane(vbCrLf & _
  67.                                           "Version file write failed : " & ex.Message & vbCrLf)
  68.  
  69.             End Try
  70.  
  71.             msg_text = "Build number : " & line + 1 & ", " & Now
  72.  
  73.             Module1.WriteToOutputBuildPane(vbCrLf & msg_text & vbCrLf)
  74.             Module1.WriteToLogFile(msg_text)
  75.  
  76.         Else
  77.  
  78.             Try
  79.  
  80.                 Dim sw As StreamWriter = File.CreateText(res_filename)
  81.                 sw.WriteLine("build 1")
  82.                 sw.Close()
  83.  
  84.  
  85.             Catch ex As Exception
  86.  
  87.                 Module1.WriteToOutputBuildPane(vbCrLf & _
  88.                                           "Version file write failed : " & ex.Message & vbCrLf)
  89.  
  90.             End Try
  91.  
  92.             msg_text = "Build number : 1, " & Now
  93.  
  94.  
  95.  
  96.             Module1.WriteToOutputBuildPane(vbCrLf & msg_text & vbCrLf)
  97.             Module1.WriteToLogFile(msg_text)
  98.  
  99.         End If
  100.  
  101.         Try
  102.             Dim sw2 As StreamWriter = File.CreateText(dt_filename)
  103.             sw2.WriteLine(DateTime.Now().ToString("G", System.Globalization.DateTimeFormatInfo.InvariantInfo))
  104.             sw2.Close()
  105.             ''Module1.WriteToOutputBuildPane("Kirjoitettiin dtfile: " & dt_filename)
  106.  
  107.         Catch ex As Exception
  108.             Module1.WriteToOutputBuildPane("DateTime file write failed: " & ex.Message & vbCrLf)
  109.         End Try
  110.  
  111.  
  112.  
  113.     End Sub