Friday, August 20, 2010

Where Am I.cmd

After re-installing I have yet again found my static DHCP lease is no longer holding my IP address. I am at home and can't think of another way to find the IP, pinging my machine name continues to resolve to the static lease. If you find your self in the same boat and want to scan the network for IP to name resolution the following script should do the trick:

FOR /L %%i IN (1,1,254) DO (
ECHO 10.1.1.%%i
nbtstat -A 10.1.1.%%i

Tuesday, August 17, 2010

VSTS 2010 MsBuild Extension Pack TfsSource and Win32Exception: The system cannot find the file specified

I came across this error while trying to check out a file using MsBuild under TFS2010. The error message is misleading because your first inclination is to check the ItemPath or WorkingDirectory in the task. Had I not come across this forum post I may have been stuck for a bit The current version of the Extension Pack has some hard coded paths in the task that tell it where to find the tf.exe file. After taking a look at the source code I found if you just add the following path to your Path environment variable the task will function properly.

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\

Where's the Build Number, using MSBuild with VSTS 2010

I wanted to key the our assembly versions using the VSTS build number I quickly found the solution is not as simple as it seems. At first I thought this property would be a first class member of the IBuildDetail class making it easily accessible in the VSTS workflow but, it's not. After popping open the UpdateBuildNumberActivity I found the build number is actually extracted from the IBuildDetail.Uri. Use the format below in your MsBuild task to gain access to the BuildID and the SourceGetVersion. While the SourceGetVersion may return a sequential change set number (C123) it is not guaranteed to be numeric so it's probably not a good fit for the revision part of your version number. You may consider adding it to your AssemblyConfiguration attribute or AssemblyInformationalVersion attribute. Connecting the change set or source version to the assemblies generated may prove to be useful in troubleshooting version related issues later on.

String.Format("/p:SkipInvalidConfigurations=true /p:BuildID=""{1}"" /p:SourceGetVersion=""{2}"" {0}", MSBuildArguments, LinkingUtilities.DecodeUri(BuildDetail.Uri.ToString()).ToolSpecificId, BuildDetail.SourceGetVersion)

Wednesday, August 11, 2010

More Time Saving Macros Who's Under Source Control

I am in the process of switching from Subversion to Teams Server source control. Unfortunately when merging project files the source control in teams is not applied causing build errors. Using my last macro as an example I now scan every file in the solution to see if it is in source control and correct if not. One could probably add the extra code to add the item to source control.

Public Module SourceControlScanner
Private Sub Write(ByVal name As String, ByVal message As String)
Dim output As Window = DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput)
Dim window As OutputWindow = output.Object
Dim pane As OutputWindowPane = window.OutputWindowPanes.Item(name)
End Sub
Private Sub Scan(ByVal project As Project)
If Not project.ProjectItems Is Nothing Then
If TypeOf (project.Object) Is VSProject Then
Dim visualStudioProject As VSProject = DirectCast(project.Object, VSProject)
For Each item As ProjectItem In project.ProjectItems
For index As Integer = 0 To item.FileCount
Dim file As String = item.FileNames(index)
If Not visualStudioProject.DTE.SourceControl.IsItemUnderSCC(file) Then
Write("Debug", String.Concat(project.Name, " ", item.Name))
End If
End If
For Each childProjectItem As ProjectItem In project.ProjectItems
If Not childProjectItem.SubProject Is Nothing Then Scan(childProjectItem.SubProject)
End If
End Sub
Public Sub CheckSourceControl()
For Each project As Project In DTE.Solution.Projects
End Sub
End Module