TFS 2010 tracking build definition changes? - visual-studio

Is there a way to track changes to a build definition in TFS 2010? Please go to 'Team Explorer > ProjectName > Builds' in visual studio to see what I am talking about. You need to have access to a TFS server in order to see what I am referring to. Now once you are in the Team Explorer> ProjectName > Builds, you can create a build definition to compile your csproj or sln files on TFS. What I am wondering is, Is there a way to version these build definitions if I do any changes to existing ones or add a new one?

I got into the same issue when someone from the team modified the Build Definition, I tried to find all the available option but found none except Xeam Build Definition Extension which is only supported VS 2012 onward and has some downsides, so finally to get the immediate work around I wrote a small app which returns the Last Modified By and Last Modified Date and the complete Build Definition details which you can compare with previous version to find what got changed.
Imports Microsoft.TeamFoundation.Build.Client
Private Const RootFolder As String = "C:\TFS Utility Reports\"
''' <summary>
''' To Get the Build Definition Details
''' </summary>
''' <param name="teamProjectName"></param>
''' <param name="buildDefinitionName"></param>
''' <returns></returns>
''' <remarks></remarks>
Public Shared Function GetBuildDefinitionDetails(teamProjectName As String, buildDefinitionName As String) As String
Dim buildDefinitionSummary As String = Nothing
Dim buildDefinitionDetails As String = Nothing
Dim reportPath As String = RootFolder & "Build Definitions\" & buildDefinitionName
Dim buildDefinitionDetailsFileName As String = reportPath & "\" & buildDefinitionName & "_" & Date.Now.ToString(CultureInfo.CurrentCulture).Replace("/", String.Empty).Replace(":", String.Empty) & ".txt"
Dim buildService = CType(TfsTeamProjectCollection.GetService(GetType(IBuildServer)), IBuildServer)
Dim buildDefinition As IBuildDefinition = buildService.GetBuildDefinition(teamProjectName, buildDefinitionName)
If buildDefinition IsNot Nothing Then
GetAllBuildDefinitions(teamProjectName)
buildDefinitionSummary = buildDefinition.ToString()
UpdateFile(buildDefinitionSummary, buildDefinitionDetailsFileName, reportPath)
If buildDefinition.Workspace IsNot Nothing Then
buildDefinitionDetails = String.Format(CultureInfo.CurrentCulture, "Last Modified By: {0}, Last Modified Date: {1}",
buildDefinition.Workspace.LastModifiedBy,
buildDefinition.Workspace.LastModifiedDate)
End If
End If
Return buildDefinitionDetails
End Function
''' <summary>
''' Generate Log/Summary/Report
''' </summary>
''' <param name="lineToWrite"></param>
''' <param name="filePath"></param>
''' <param name="folderPath"></param>
''' <remarks></remarks>
Private Shared Sub UpdateFile(ByVal lineToWrite As String, ByVal filePath As String, ByVal folderPath As String)
Dim strFileName As String = String.Empty
lineToWrite = lineToWrite.Trim()
strFileName = filePath
Dim di As IO.DirectoryInfo = New IO.DirectoryInfo(folderPath)
If Not di.Exists Then
di.Create()
End If
Dim streamWriter As New StreamWriter(strFileName, True, System.Text.Encoding.ASCII)
Try
Dim strOutput As String
strOutput = lineToWrite.ToString
streamWriter.WriteLine(strOutput)
Catch ex As Exception
Throw
Finally
streamWriter.Dispose()
End Try
End Sub

There is no way to track changes to a build definition. If you have multiple branches / versions you need to build I suggest creating a different build definition.
Some of the properties can be set when you queue the build, so if you want a CI build that does not copy it's output to the drop server, you can have that, but then if you want to deploy a version you can set a drop folder when you queue the build.
In the TFS Power Toys you get a "Clone Build Definition" context menu so you can copy builds easier if you have a lot of settings you want to keep similar.

There is a way. There is this tool in the vsgallery:
http://visualstudiogallery.msdn.microsoft.com/ec36f618-d122-48a3-8236-7d9cd19791ee
I used it with tfs2012. I don't know if it works with tfs2010

Related

Google Spreadsheet to SSIS VB Code issue

Requirement:
Convert Google Spreadsheet data to SQL Server through SSIS.
Method:
With help from this website, I'm doing coding in Visual Studio 2015 Community edition. I have prepared Variables, Control Flow, Data Flow and added Script component and the required Google References.
Code pasted in VS as Visual Basic 2015:
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports Google.GData.Client
Imports Google.GData.Extensions
Imports Google.GData.Spreadsheets
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> 'Line 15 Error here
<CLSCompliant(False)> 'Line 17 Error here
Public Class ScriptMain
Inherits UserComponent
Dim objListFeed As ListFeed
Public Overrides Sub PreExecute()
MyBase.PreExecute()
Dim objService As SpreadsheetsService
Dim objWorkSheetQuery As WorksheetQuery
Dim objWorkSheetFeed As WorksheetFeed
Dim objWorkSheet As WorksheetEntry
Dim objListFeedLink As AtomLink
Dim objListQuery As ListQuery
Dim bt(0) As Byte
'Create a connection to the google account
objService = New SpreadsheetsService("exampleCo-exampleApp-1")
Me.Log(Variables.strPassword, 0, bt)
Me.Log(Variables.strUserName, 0, bt)
objService.setUserCredentials(Variables.strUserName, Variables.strPassword)
Me.Log("Service: " + Variables.strUserName, 0, bt)
'Connect to a specific spreadsheet
objWorkSheetQuery = New WorksheetQuery(Variables.strKey, "private", "full")
objWorkSheetFeed = objService.Query(objWorkSheetQuery)
objWorkSheet = objWorkSheetFeed.Entries(0)
Me.Log("Spreadsheet: " + objWorkSheet.Title.Text.ToString, 0, bt)
'Get a list feed of all the rows in the spreadsheet
objListFeedLink = objWorkSheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, Nothing)
objListQuery = New ListQuery(objListFeedLink.HRef.ToString())
objListFeed = objService.Query(objListQuery)
Me.Log("ListFeed: " + objListFeed.Feed.ToString, 0, bt)
End Sub
Public Overrides Sub PostExecute()
MyBase.PostExecute()
End Sub
Public Overrides Sub CreateNewOutputRows()
Dim objRow As ListEntry
For Each objRow In objListFeed.Entries
With Output0Buffer
.AddRow()
.Product = objRow.Elements.Item(0).Value
.Qty = objRow.Elements.Item(1).Value
End With
Next
Output0Buffer.EndOfRowset()
End Sub
End Class
Problem:
Upon pressing Build, I get the following error on Line 15 and 17.
BC32035 VB.NET Attribute specifier is not a complete statement. Use a
line continuation to apply the attribute to the following statement.
Here it says to add a space and underscore following the attribute, however, when I add them they are just automatically removed.
I just created a new script component in a new SSIS package dataflow, and here are the lines between the import block and the Class declaration:
' This is the class to which to add your code. Do not change the name, attributes, or parent
' of this class.
<Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute> _
<CLSCompliant(False)> _
Public Class ScriptMain
Inherits UserComponent
I have never heard of the situation you describe where the underscores just "disappear", but maybe if you paste these lines over your lines it will work.
If not, you may need to copy your code to the clipboard, and then destroy the script component and create a new one, and paste your code into it.

VS addin for quickly viewing preprocessed or assembly output

I'm searching for a one-click way to inspect preprocessed or assembly output.
It's just tedious to open file properties, change the respective setting, compile, go to the obj directory and open the resulting file by hand.
Does anyone know of any Visual Studio add-in, macro or whatever to automate this task?
EDIT: An extension for VS 11+ is available # https://github.com/Trass3r/DevUtils
I solved it myself by creating a nice macro.
It's way more sophisticated but basically works like this:
Imports EnvDTE
Imports Microsoft.VisualStudio.VCProjectEngine
Dim doc As EnvDTE.Document = DTE.ActiveDocument
Dim prj As VCProject = doc.ProjectItem.ContainingProject.Object
Dim file As VCFile = prj.Files.Item(doc.Name)
Dim fileconfigs As IVCCollection = file.FileConfigurations
Dim fileconfig As VCFileConfiguration = fileconfigs.Item("Release|x64")
Dim tool As VCCLCompilerTool = fileconfig.Tool
Dim asmFile = System.IO.Path.GetTempFileName + ".asm"
tool.WholeProgramOptimization = False
tool.AssemblerOutput = asmListingOption.asmListingAsmSrc
tool.AssemblerListingLocation = asmFile
fileconfig.Compile(True, True)
Dim window = DTE.ItemOperations.OpenFile(asmFile, Constants.vsViewKindCode)
Very useful in combination with AsmHighlighter.
Preprocessed file can be generated similarly with
tool.GeneratePreprocessedFile = preprocessOption.preprocessYes
' there's no separate option for this, so misuse /Fo
tool.ObjectFile = System.IO.Path.GetTempFileName + ".cpp"

Getting Error as 'User defined type not defined' in the code

Greetings for the day,
Hi, I am a beginner using vb 6.0. I am using the following code and getting 'user defined type not defined'.the code is below.the line where i get error is highlighted.Kindly help.should i add some references or components?if so,what it would be. your timely and kindly help will be much more helpful for me
Public Sub LoadDocument()
Dim xDoc As MSXML2.DOMDocument
Set xDoc = New MSXML2.DOMDocument
xDoc.async = False
xDoc.validateOnParse = False
If xDoc.Load("C:\Users\284582\Desktop\XML1.xml") Then
DisplayNode xDoc.ChildNodes, 0
End If
End Sub
' Error on this line'
Public Sub DisplayNode(ByRef Nodes As MSXML.IXMLDOMNodeList, _
ByVal Indent As Integer)
Dim xNode As MSXML.IXMLDOMNode
Indent = Indent + 2
For Each xNode In Nodes
If xNode.NodeType = NODE_TEXT Then
Debug.Print Space$(Indent) & xNode.ParentNode.nodeName & _
":" & xNode.NodeValue
End If
If xNode.HasChildNodes Then
DisplayNode xNode.ChildNodes, Indent
End If
Next xNode
End sub
It's MSXML2.IXMLDOMNodeList, not MSXML.IXMLDOMNodeList.
The library may be missing from your references. Try this.
Manually adding MSXML2
1. Open MS Access.
2. Database Tools ribbon
3. Visual Basic ribbon item (icon)
4. Double-click on any module to open it.
5. Tools menu
6. References…
7. Find Microsoft XML, v6.0. is in the list
a. If in list but not checked, check it and click [OK].
b. If not in the list:
i. click [Browse…] and add "c:\windows\system32\msxml6.dll"
8. [OK] your way back to the Visual Basic window.
9. Close the Visual Basic Window. You should be good to go.
Programmatically adding MSXML2
Add the following sub and function. Run the sub. Edit the sub to include a path if necessary.
Check for broken references in the library
Adapted from Add references programatically
Sub CheckXmlLibrary()
' This refers to your VBA project.
Dim chkRef As Reference, RetVal As Integer ' A reference.
Dim foundWord As Boolean, foundExcel As Boolean, foundXml As Boolean
foundWord = False
foundExcel = False
foundXml = False
' Check through the selected references in the References dialog box.
For Each chkRef In References
' If the reference is broken, send the name to the Immediate Window.
If chkRef.IsBroken Then
Debug.Print chkRef.Name
End If
'copy and repeat the next 2 if statements as needed for additional libraries.
If InStr(UCase(chkRef.FullPath), UCase("msxml6.dll")) <> 0 Then
foundXml = True
End If
Next
If (foundXml = False) Then
'References.AddFromFile ("C:\Windows\System32\msxml6.dll") <-- For other than XML, modify this line and comment out line below.
RetVal = AddMsXmlLibrary
If RetVal = 0 Then MsgBox "Failed to load XML Library (msxml6.dll). XML upload/download will not work."
End If
End Sub
Add XML reference to the library
Developed by Chris Advena. Thanks to http://allenbrowne.com/ser-38.html for the insight.
Public Function AddMsXmlLibrary(Optional PathFileExtStr As String = "C:\Windows\System32\msxml6.dll") As Integer
On Error GoTo FoundError
AddMsXmlLibrary = 1
References.AddFromFile (PathFileExtStr)
AllDone:
Exit Function
FoundError:
On Error Resume Next
AddMsXmlLibrary = 0
On Error GoTo 0
End Function

How to automate Public folder calender to show in Favorite Folder of mail

How to automate the process to show my public folder calender in Mail Favorite folder?
I wanted to do it either by login script or by group policy.
I am using Microsoft Exchange server 2007 with Windows Server 2008 R2 and Domain controller running Windows Server 2003 R2.
All workstation system have either Outlook 2010 or Outlook 2007.
While searching on this I found the script below, but by this script (already modified the path) I am just able to make public folder calender to show in public folder favorite but not in mail favorite folder.
Const olPublicFoldersAllPublicFolders = 18
Dim olkApp, olkSes, olkFolder
Set olkApp = CreateObject("Outlook.Application")
Set olkSes = olkApp.GetNameSpace("MAPI")
'Change the profile name on the next line'
olkSes.Logon "Outlook"
'Change the folder name on the next line. Repeat the next two lines for each folder
you want to add.'
Set olkFolder =
olkSes.GetDefaultFolder(olPublicFoldersAllPublicFolders).Folders("Public
calender").Folders("p cal")
olkFolder.AddToPFFavorites
'Change the folder name on the next line. Repeat the next two lines for each folder
you want to add.'
Set olkFolder = OpenOutlookFolder("Public Folders\Favorites\P cal")
AddFavoriteFolder olkFolder
olkSes.Logoff
Set olkApp = Nothing
Set olkSes = Nothing
Set olkFolder = Nothing
WScript.Quit
Sub AddFavoriteFolder(olkFolder)
' Purpose: Add a folder to Favorite Folders.'
' Written: 5/2/2009'
' Author: BlueDevilFan'
' Outlook: 2007'
Const olModuleMail = 0
Const olFavoriteFoldersGroup = 4
Dim olkPane, olkModule, olkGroup
Set olkPane = olkApp.ActiveExplorer.NavigationPane
Set olkModule = olkPane.Modules.GetNavigationModule(olModuleMail)
Set olkGroup =
olkModule.NavigationGroups.GetDefaultNavigationGroup(olFavoriteFoldersGroup)
olkGroup.NavigationFolders.Add olkFolder
Set olkPane = Nothing
Set olkModule = Nothing
Set olkGroup = Nothing
End Sub
Function OpenOutlookFolder(strFolderPath)
' Purpose: Opens an Outlook folder from a folder path.'
' Written: 4/24/2009'
' Author: BlueDevilFan'
' Outlook: All versions'
Dim arrFolders, varFolder, bolBeyondRoot
On Error Resume Next
If strFolderPath = "" Then
Set OpenOutlookFolder = Nothing
Else
Do While Left(strFolderPath, 1) = "\"
strFolderPath = Right(strFolderPath, Len(strFolderPath) - 1)
Loop
arrFolders = Split(strFolderPath, "\")
For Each varFolder In arrFolders
Select Case bolBeyondRoot
Case False
Set OpenOutlookFolder = olkSes.Folders(varFolder)
bolBeyondRoot = True
Case True
Set OpenOutlookFolder = OpenOutlookFolder.Folders(varFolder)
End Select
If Err.Number <> 0 Then
Set OpenOutlookFolder = Nothing
Exit For
End If
Next
End If
On Error GoTo 0
End Function
You can't do this. You can only add mail folders or search folders to the Mail Favorites view. Quoting Outlook's help, Favorites contain "shortcuts to folders such as your Inbox, Sent Items, and Search Folders. You can add, remove, and arrange folders [...] access your mail folders more easily" (my emphasis).
From MSFT's point of view, this is logically consistent.
Adding a public object to your public folder favorites is the type of activity that a user is expected to do infrequently. So it's not appropriate to handle that in a login script. It's like adding resources to your personal library of information, eg a folder with project status or manuals.
Adding a mail folder to your Mail Favorites is a quick and dirty trick for frequently used items. This is more like adding a bookmark.
You could argue that if you have to set up a large number of users that all need access to a public folder, that it makes sense to handle that in a login script, and that is fine, but again, it would be adding it to the public folder favotires, not the mail one....and you've have to have code to not create the favorite if it already existed.

Setting a VCProject property to default

I'm trying some VS2005 IDE macros to modify a large amount of projects (~80) within a solution. Some of the properties I wish to set do expose a programmatic interface to 'default', but many others do not. Is there a generic way to set such properties to their default? (eventually meaning erasing them from the .vcproj file)
Simplified example, setting some random properties:
Sub SetSomeProps()
Dim prj As VCProject
Dim cfg As VCConfiguration
Dim toolCompiler As VCCLCompilerTool
Dim toolLinker As VCLinkerTool
Dim EnvPrj As EnvDTE.Project
For Each EnvPrj In DTE.Solution.Projects
prj = EnvPrj.Object
cfg = prj.Configurations.Item(1)
toolLinker = cfg.Tools("VCLinkerTool")
If toolLinker IsNot Nothing Then
' Some tool props that expose a *default* interface'
toolLinker.EnableCOMDATFolding = optFoldingType.optFoldingDefault
toolLinker.OptimizeReferences = optRefType.optReferencesDefault
toolLinker.OptimizeForWindows98 = optWin98Type.optWin98Default
End If
toolCompiler = cfg.Tools("VCCLCompilerTool")
If toolCompiler IsNot Nothing Then
' How to set it to default? (*erase* the property from the .vcproj)'
toolCompiler.CallingConvention = callingConventionOption.callConventionCDecl
toolCompiler.WholeProgramOptimization = False
toolCompiler.Detect64BitPortabilityProblems = False
End If
Next
End Sub
Any advice would be appreciated.
For VS 2005, I believe you can use the ClearToolProperty method on VCConfiguration. The following code would accomplish this for CallingConvention (this is C#, but I'm sure something similar works for VB):
cfg.ClearToolProperty( toolCompiler, "CallingConvention" );
This would have the same effect as going into the GUI and choosing "<inherit from parent or project defaults>" for this option.
Unfortunately this seems to be deprecated in VS 2010, and I'm not sure what the new supported method is.

Resources