Tuesday, February 15, 2011

Upgrade VS2008 to work with TFS 2010

Steps for VS2008 are quite similar to that for VS2005. You should install the below mentioned components in order. The Installation order is important.
- Install Visual Studio 2008
- Install
Team Explorer 2008
- Install Visual Studio 2008 SP1 (This will upgrade both VS2008 and Team Explorer 2008 to SP1)
- Install
VSTS 2008 Forward Compatibility Update
After the installation is completed successfully, you should provide the entire URL to connect TFS2010 server.
For more details see previous post:

Monday, February 14, 2011

Upgrade VS2005 to work with TFS 2010

Problem Statement: We made a decision move to TFS2010. Problem is we have a set of projects running in .Net Framework 2.0 (VS2005), 3.5 (VS2008) and some in 4.0 (VS2010).
And this it;
VS2010 is fine with TFS 2010. I have to check the feasibility to run TFS 2010 server with old clients VS 2005 and VS2008. Here is the sequence documented in different forums for VS2005:
Connect to TFS2010 Server using VS 2005 Client
1.    Fresh Machine
Be aware that the order of the installation is important for the solution to work correctly.
1.    Install Visual Studio 2005
2.    Install Team Explorer 2005
3.    Install latest Service Pack for Visual Studio 2005
4.    Install the Forward Compatibility Update for TFS 2010
When you install Team Explorer after you install the service pack, Team Explorer will not be patched by the Forward Compatibility Update!
2.    Machine with VS2005 and SP1 installed
Be aware that the order of the installation is important for the solution to work correctly.
1.    Install Team Explorer 2005
2.    Re-Install SP1 for Visual Studio 2005 to upgrade team explorer to SP1.
3.    Install the Forward Compatibility Update

ü  How to know whether VS2005 SP1 is already installed o?
I have some developers running VS2005 from Vista/Windows 7. So I should install ‘VS 2005 SP1 update to Vista/Win7 (not for XP)’ before last step ‘Install the Forward Compatibility Update.
3.    Important URLs for VS2005 upgradation
Here are some of the details:
ü  Visual Studio Team System 2005 Team Explorer
ü  Visual Studio 2005 Service Pack 1 Update for Windows Vista/Windows7  (not needed for XP)
ü  Visual Studio Team System 2005 Service Pack 1 Forward Compatibility Update for Team Foundation Server 2010 (Installer)
4.    How to connect with TFS2010 from VS2005 when everything is installed

As TFS2010 uses concept to Team Project Collections. And path in my case is like http://tfs-server:8080/tfs .  Problem is how to put this connection string in the dialog when there is no ‘Path’ textbox available. If I specify just IP and port, I get error ‘Unable to connect to this Team Foundation Server’. You should provide the entire URL to connect TFS2010 server.

Thursday, February 3, 2011

Full Migration from VSS 2005 to TFS 2010 with History

I wanted to perform 'Full Migration' along with all code/label history to transfer from Visual Source Safe 2005 (or V8) to TFS 2010.

I figured out, VSSConvertor 2010 is more stable than previous versions. All issues reported in previous version are fixed in VSSConvertor10 with framework4.0. VSSConvertor10 does not support old tfs migrations (tfs2008 and tfs2005). We can use VS2010 commandline to use VSSConverter tool. 
Here are the steps:
1. Make sure TFS 2010 is installed on accessible location
2. Make sure, TFS explorer is available on VSS machine
3. VSS is version 2005 or V.8
4. You have Admin password of VSS Application
5. Make sure all files are checked-in by all developers
6. Create a copy of VSS database file (Must do for safety purpose in case things go wrong).
7. Install KB947647 to fix known issue during migration. http://code.msdn.microsoft.com/KB947647/Release/ProjectReleases.aspx?ReleaseId=1028
8. Create the Analysis settings files like analysissettings.xml in a location you want. I have this path on my machine E:\BashVSS2TFSMigration\analysissettings.xml

<?xml version="1.0" encoding="utf-8"?>
<SourceControlConverter>
<ConverterSpecificSetting>
<Source name="VSS">
<VSSDatabase name="E:\BashWorkspace\VSSRepository"></VSSDatabase>
<UserMap name="E:\BashVSS2TFSMigration\Usermap.xml"></UserMap>
<SQL Server="TEO-SRV-CCNET2K\SQLEXPRESS"></SQL>
</Source>
<ProjectMap>
<Project Source="$/PilotProject4Teo"></Project>
</ProjectMap>
</ConverterSpecificSetting>
<Settings>
<Output file="E:\BashVSS2TFSMigration\Analysis.xml"></Output>
</Settings>
</SourceControlConverter>
Here is xml description:

VSSDatabase = VSS Repository/databse file path
UserMap = User mapping frile name to be generated after analysis command.
SQL Server – instance name – can use SQL express for files < 4GB. Otherwise use Full SQL Server Instance where user should have access rights
Project = project name on vss to be ported
Output = analysis file to be generated after analysis command.
9. Analysis Command.

cmd> vssconverter analyze "E:\BashVSS2TFSMigration\analysissettings.xml"

10. Two files are generated with names Analysis.xml and Usermap.xml.
 11. I double clicked Analysis.xml and figure out that one Error Occured. Error was nothing but asking me to install a hot fix in VSS 'KB950185' from path: 
 12. Installed hotfix: KB950185
http://code.msdn.microsoft.com/KB950185/Release/ProjectReleases.aspx?ReleaseId=1123
 13. Again run the analysis command, this time things went correct. Here is analysis report with 0 Error and 1 Warning.
14. I edited Usermap.xml to assign destination users (which are Active Directory Users offcourse mapped to VSS users). History will be transferred to mapped users in tfs.

15. I edited Usermap.xml to assign destination users (which are Active Directory Users offcourse mapped to VSS users). History will be transferred to mapped users in TFS 2010.
<?xml version="1.0" encoding="utf-8"?>
<UserMappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <!--
This file is automatically created by VSS Converter. You can optionally use the file to map
a VSS user to a Team Foundation user. For example, <UserMap From="Jane" To="MyDomain\Janep"></UserMap>
This mapping causes all actions logged by VSS user “Jane” to be changed to Team
Foundation user “ MyDomain\Janep ” during migration.
-->
  <UserMap From="basharat.hussain" To="[MyDomain]\basharat.hussain" />
  <UserMap From="Cruisecontrol" To="[MyDomain]\shahid.iqbal" />
  <UserMap From="ADMIN" To="[MyDomain]\tfssetup001" />
</UserMappings>

At least users should have readonly rights on TFS team project.
16. Created a Team Project in TFS with name ‘GD Project’ and provided full rights to domain user ‘basharat.hussain’ and Shahid.Iqbal readonly rights.
17. Created a MigrattionSettings.XML file by copying from AnalysisSettings.XML.

<?xml version="1.0" encoding="utf-8"?>
<SourceControlConverter>
<ConverterSpecificSetting>
<Source name="VSS">
<VSSDatabase name="E:\BashWorkspace\VSSRepository"></VSSDatabase>
<UserMap name="E:\BashVSS2TFSMigration\Usermap.xml"></UserMap>
</Source>
<ProjectMap>
<Project Source="$/PilotProject4Teo" Destination="$/GD Project/PilotProject4Teo"/>
</ProjectMap>
</ConverterSpecificSetting>
<Settings>
<TeamFoundationServer name="192.168.3.249" port="8080" protocol="http"
collection="tfs/DefaultCollection"></TeamFoundationServer>
<Output file="E:\BashVSS2TFSMigration\Migration.xml"></Output>
</Settings>
</SourceControlConverter>
Here is xml description:
Project Source = Project path in VSS
Project Destination = Propased Project path under ‘GD Project’ team project
TeamFoundationServer = TFS2010 DNS or IP address, with port
Collection – Project collection Name, I accessed following url and I can see collection name in web page ‘http://192.168.3.249:8080/tfs/web’
Output = migration file to be generated after analysis command.
18. Migrate Command:
cmd> vssconverter migrate "E:\BashVSS2TFSMigration\MigrationSettings.xml"
19. Inspect TFS 2010 and you can see migrated projects with history
20. Done 

Saturday, January 29, 2011

Hot fix for VS 2010 - for building setup project

I was facing a strange issue in Web Setup project project for one of my Automated Distribution Project (developed in VS2010). It was not behaving smoothly, syptoms seems to be undefined. Sometimes  steup project build successfully when intially creaed. After a week or two when I used to build it agin then ‘error unable to update the dependencies of the project” used to occur.

After investigation, I reach a hot fix, microsoft provided for VS2010. Problem is solved after installing it.
Link URL:
http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30681

Tuesday, January 25, 2011

What is this in VS2010?

 Could not resolve mscorlib for target framework '.NETFramework,Version=v4.0'.  This can happen if the target framework is not installed or if the framework moniker is incorrectly formatted.

I just get latest version from onshore client using SOS. Project is in VS2010. I compiled the project and all of a sudden I get following issue.
Solution compilation failed but with no error.
If I delete WCF reference following error appeard.


I unlinked the project from source repository, then manually deleted the reference from folder (from VS it still not allow me to delete the reference). then Reoped the project, added fresh WCF reference, bilt the solution afterwards. It worked untill I checked in the code again to VSS using SOS.

Then I repaired the  existing VS 2010 installation. But still not succeeded to resolve the issue. Every time I have to perform above practice.

Now I am considering to uninstall the existing setup, and install fresh VS2010 copy, Will check if problem still occur. (Every thing is working fine on another developer's computer).

Saturday, December 25, 2010

Continuous Integration Step 2 – FxCop Integration with MsBuild

An FxCop project specifies the set of assemblies to be analyzed, the rules used to analyze the assemblies, and the most recent analysis results reported by FxCop.
Local Path of FxCopCmd.exe on my build server is for example:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe
Challenge is to write a custom target for code analysis, plug that target in build process to perform analysis as last task and then produce the report in xml file.  So below the After Build target in previous post, I wrote following script:
  <PropertyGroup>
    <BuildDependsOn>
      $(BuildDependsOn);
      Bash_CodeAnalysis
    </BuildDependsOn>
  </PropertyGroup>
   
  <Target Name="Bash_CodeAnalysis">
      <Message Text ="Static Code Analysis Starts Here"  Importance="high"> </Message>
  </Target>

Build and verify that message appear at the end of “After Build” target execution. The code above is very simple that is, run Bash_CodeAnaysis target after standard build. Now I can write Exec Command afterwards.

<Target Name="Bash_CodeAnalysis">
      <Message Text ="Static Code Analysis Starts Here"  Importance="high"> </Message>
  
   <Exec Command="&quot;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe&quot; /searchgac /rule:&quot;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\Rules&quot; /file:$(ProjectDir)bin /out:C:\fxCop.xml" 
          ContinueOnError="true">
    </Exec>
</Target>

Note: Prefer to write Command value in single line otherwise command line tool will consider it separate commands and throws an error.
Parameters details that are passed in:
/searchgac – Tells FxCop to search the gac for any referenced dll's not found in say the bin folder.  If you forget this FxCop will error out.
/rule:Rull.dll – You can specify as many rules as you like to check against your compiled dll just repeat this command with each of the Rules you like.  Unless you have a specific FxCop project you must specify at least one rule. You can specify Rules folder as well
Note: As we are calling it from an MsBuild file which is XML we have to encode the quotes as “&quot;” otherwise famous 9009 error will be encountered.
/file:YourCompiled.dll – Much like the rule parameter you can specify as many .dll’s as you would like to check but need at least one. I specified project’s bin folder means all dlls to be analyzed in it.
/out:someXml.xml – You are going to want to specify an XML file to output the results to so that you can integrate the results in your build log.   CruiseControl.net uses XSL to transform the generated XML into HTML for viewing in its Web Dashboard and auto generated Emails.
ContinueOnError – Unless you have written your own FxCop rules you are most likely going to want to set this value to true so that your build doesn’t fail each time you break one of the many rules that FxCop specifies.

Here is another example analyzing single NamingRules.dll on single dlls only.
<Target Name="FxCop" DependsOnTargets="BuildProject> 
<Exec Command="&quot;C:\Program Files\Microsoft FxCop 1.36\FxCopCmd.exe&quot;
 /searchgac /rule:&quot;C:\Program Files\Microsoft FxCop 1.36\Rules\NamingRules.dll&quot;
 /file:C:\Project\bin\My.Framework.dll /out:fxCop.xml" ContinueOnError="true">
    </Exec>
</Target>

Now save the project file.
Open VS2010 command line tool again and browse to the folder where csproj file exists. Execute  this command:
 >>> MSbuild GD.AutoDist.MainService.csproj /fl
After build, static code analysis is performed by FxCop as follows.


Now next is to dig into CCNet  configurations :)
Provide your comments

Wednesday, December 22, 2010

Continuous Integration Step 1 – MsBuild Integration


How to start a Continuous Integration process is a difficult task. When things are up and running with Automated Process, it seems very helpful and easy to maintain. With minimal human interaction you can reduce your build time and accuracy and hence time to market the application. A great advantage.
There are a large set of options and combination of tools. We prepared a dedicated Build server machine in the company (TEO). Here is a set of software components on Build Server, I will discuss about each component’s wiring later on (decision about set of chosen package is based on our defined criteria including wide acceptance, open source availability and our needs).

MsBuild Integration with csproj file:
Our target is command line building of CSharp project  using MSBuild. I created an asp.net website in VS2010 and want to configure it to execute from command line tool. One goal is to copy the build files to root drive destination folder (also configured in metadata dynamically). So I unloaded the project file in VS and right clicked to go to “Edit project file”.  It opens the project file for editing.

At the end of file we can find ‘Before Build’ and ‘After Build’ commented targets. In the after build target we will write custom code.


Here is my code snippet instead:

  <!--MSBuild integration started here by Bash 20-Dec-2010-->

  <Target Name="AfterBuild">
    <Message Text ="Custom After Build Action Started" Importance="high"></Message>
    <ItemGroup>
      <ProjectFolder Include="$(ProjectDir)\*.*"                    Exclude="$(ProjectDir)\*.cs;$(ProjectDir)\*.csproj;$(ProjectDir)\*.user" >
        <!--Only imediate file of project folder-->
        <PublishTo>2010_MSBuild</PublishTo>
      </ProjectFolder>

      <BinFolder Include="$(ProjectDir)bin\**\*.*" Exclude="*.cs">
        <!--All files and sub folders in bin-->
        <BinFolderTo>2010_MSBuild/bin</BinFolderTo>
      </BinFolder>

      <AccountFolder Include="$(ProjectDir)Account\**\*.*" Exclude="$(ProjectDir)Account\**\*.cs" >
        <!--All files and sub folders in Account-->
        <AccountFolderTo>2010_MSBuild/Account</AccountFolderTo>
      </AccountFolder>

      <ScriptsFolder Include="$(ProjectDir)Scripts\**\*.*">
        <!--All files and sub folders in Scripts-->
        <ScriptsFolderTo>2010_MSBuild/Scripts</ScriptsFolderTo>
      </ScriptsFolder>

      <StylesFolder Include="$(ProjectDir)Styles\**\*.*">
        <!--All files and sub folders in Styles-->
        <StylesFolderTo>2010_MSBuild/Styles</StylesFolderTo>
      </StylesFolder>
    </ItemGroup>

    <Message Text="ProjectFolder :@(ProjectFolder)" Importance="high"/>

    <Copy SourceFiles="@(ProjectFolder)"  DestinationFiles="@(ProjectFolder->'%(RootDir)%(PublishTo)\%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(BinFolder)"  DestinationFiles="@(BinFolder->'%(RootDir)%(BinFolderTo)\%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(AccountFolder)"  DestinationFiles="@(AccountFolder->'%(RootDir)%(AccountFolderTo)\%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(ScriptsFolder)"  DestinationFiles="@(ScriptsFolder->'%(RootDir)%(ScriptsFolderTo)\%(Filename)%(Extension)')" />
    <Copy SourceFiles="@(StylesFolder)"  DestinationFiles="@(StylesFolder->'%(RootDir)%(StylesFolderTo)\%(Filename)%(Extension)')" />

  </Target>

Now save the project file.
Open VS2010 command line tool and browse to the folder where csproj file exists. Execute  this command:
 >>> MSbuild GD.AutoDist.MainService.csproj /p:Configuration=Release
1.       MsBuild – Standard command
2.       Cs project file to be built
3.       /p is parameter with key-value pair; key= configuration and value=release
After build, the files will copy to root’s 2010_MSBuild folder.

Now next target is to analyze the code by Static Code Analysis. FxCop is the goal for integration.