Tuesday, December 29, 2009

Apply FxCop Rules to Multiple Solutions

It's easy to apply FxCop into the projects with Visual Studio. You don't need to manually change each project settings using the project Properties dialogue. You can just copy and paste the settings to each .csproj file which is the MSBuild file.

The steps to applied the same FxCop rules to the multiple projects at the same time are:

  • Unload the projects in a batch.
  • Edit the csproj files in a batch. This will automatically check the .csproject files out. Past the following lines into the .csproj file in each configuration files.

<PropertyGroup Condition=" '$(Configuration)$(Platform)' == 'DebugAnyCPU' ">

<RunCodeAnalysis>true</RunCodeAnalysis>

<CodeAnalysisRules>-Microsoft.Design#CA1005;-Microsoft.Design#CA1011;-Microsoft.Design#CA1009;-Microsoft.Design#CA1019;-Microsoft.Design#CA1000;-Microsoft.Design#CA1006;-Microsoft.Design#CA1046;-Microsoft.Design#CA1035;-Microsoft.Design#CA1033;-Microsoft.Design#CA1014;-Microsoft.Design#CA1017;-Microsoft.Design#CA1018;-Microsoft.Design#CA1060;-Microsoft.Design#CA1034;-Microsoft.Design#CA1052;-Microsoft.Design#CA1057;-Microsoft.Design#CA1030;-Microsoft.Design#CA1003;-Microsoft.Design#CA1007;-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1306;-Microsoft.Globalization#CA1305;-Microsoft.Globalization#CA1300;-Microsoft.Globalization#CA1309;-Microsoft.Interoperability#CA1403;-Microsoft.Interoperability#CA1406;-Microsoft.Interoperability#CA1413;-Microsoft.Interoperability#CA1402;-Microsoft.Interoperability#CA1407;-Microsoft.Interoperability#CA1404;-Microsoft.Interoperability#CA1410;-Microsoft.Interoperability#CA1411;-Microsoft.Interoperability#CA1405;-Microsoft.Interoperability#CA1409;-Microsoft.Interoperability#CA1415;-Microsoft.Interoperability#CA1408;-Microsoft.Interoperability#CA1414;-Microsoft.Interoperability#CA1412;-Microsoft.Interoperability#CA1400;-Microsoft.Interoperability#CA1401;-Microsoft.Mobility#CA1600;-Microsoft.Mobility#CA1601;-Microsoft.Performance#CA1812;-Microsoft.Performance#CA1824;-Microsoft.Portability#CA1901;-Microsoft.Portability#CA1900;-Microsoft.Security#CA2116;-Microsoft.Security#CA2117;-Microsoft.Security#CA2115;-Microsoft.Security#CA2102;-Microsoft.Security#CA2122;-Microsoft.Security#CA2114;-Microsoft.Security#CA2123;-Microsoft.Security#CA2108;-Microsoft.Security#CA2107;-Microsoft.Security#CA2103;-Microsoft.Security#CA2118;-Microsoft.Security#CA2109;-Microsoft.Security#CA2119;-Microsoft.Security#CA2106;-Microsoft.Security#CA2112;-Microsoft.Security#CA2120;-Microsoft.Security#CA2126;-Microsoft.Security#CA2124;-Microsoft.Security#CA2127;-Microsoft.Security#CA2128;-Microsoft.Security#CA2129;-Microsoft.Usage#CA2227;-Microsoft.Usage#CA2212;-Microsoft.Usage#CA2219;-Microsoft.Usage#CA2228;-Microsoft.Usage#CA2240;-Microsoft.Usage#CA2229;-Microsoft.Usage#CA2238;-Microsoft.Usage#CA2239;-Microsoft.Usage#CA2242;-Microsoft.Usage#CA2230</CodeAnalysisRules>

<PropertyGroup>

Load the projects again in a batch.

Undo the .sln file if the solution file has been checked out by visual studio.

Tuesday, December 22, 2009

To-do list in TFS Project Migration

I can think of at least two reasons why project migration is not avoidable in TFS 2008.

  1. You want to rename your project. For complicated reasons, renaming is not supported in TFS. So the only you can achieve this is to create a new project then migrate everything.
  2. You want to change the process template you used in TFS project. Changing the template is not supported in TFS 2008 either.

Migrating the team project, you can easily think of three parts.

  1. Source control code
  2. Work Items
  3. SharePoint Documents

However there are other things you need to consider too.

  1. TFS groups and membership
  2. TFS security settings
  3. TFS queries

Some of these items are manual processes.

  • Like work items migration, you need to use TFS query to get the work items you need, then export to excel then import to the new TFS project.
  • SharePoint Documents.
  • TFS queries
  • TFS security settings.

Some of these items you can accomplish using scripts.

  • Group membership migration. I found one good tool you can utilize to migrate group membership in CodePlex
  • Source code migration. You can simply use TF.EXE to compose a batch file.

Before the migration you should consider to stop TFS SQL server's transaction log jobs. Then migrate. Restart the SQL transaction log job. Re-index the database to achieve the ultimate performance.

Tuesday, October 20, 2009

Manual Remove Visual Studio 2005

I have problem to remove the Visual Studio 2005. It complains about the
vs_setup.msi could not be found in c:\program files\microsoft visual studio
8.

I also tried to remove it from DVD, which was not successful as well.

(1) Rename the Visual Studio directories to something else (ie. add REMOVE
to the folder name)

(2) rename the following Register entry using REGEDIT (use with care!)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0 (ie. change
\8.0 to \8.0REMOVE)

(3) Download the Windows Install Clean Up utility at:
http://support.microsoft.com/default.aspx/kb/290301

Use this software to 'clean up' anything with Visual Studio in the
name.

(4) Reinstall the Visual Studio software


You must install Windows Installer Cleanup Utility - msizap.exe.
http://support.microsoft.com/default.aspx/kb/290301

Friday, October 09, 2009

Team Build Tray

There are many ways to monitor the team builds status. The greatest one I found is the Team Build Tray, which is pretty similar to the CruiseControl one I have used before. So far this tool is the most satisfied one I have used.
URL: http://teambuildtray.codeplex.com/

There are other tools other there in codeplex. But I just don't see how they will be used in a common development environment.

http://buildmonitor.codeplex.com/

is supporting Twitter and USB build light.

http://tfsalert.codeplex.com/

is not useful and I haven't seen any place to set where the TFS is.

Sunday, September 27, 2009

Conference - Houston TechFest 9/26/2009

The conference was held in University of Houston main campus. It was such a great free conference. Highly recommend it to other tech folks in Greater Houston Area. Below are the sessions I have attended to give some ideas to have the complete list, you can go to the following link.

http://houstontechfest.com/

Session 1: Preparing for Your Organization’s SharePoint Future in SharePoint 2010

by Erin O’Connor

  • Ribbon Styled
  • Visio 2010 Added
  • Silverlight
  • BDC changed to two-way BCS
  • Performance Point to bring BI
  • Firefox, Safari and IE compatible. No support IE 6 anymore
  • Offline workspace support
  • Only support 64 bits server
  • SPaaS

Session 2: Microsoft Dynamics xRM by Daniel Hunter

  • xRM 4.0 demo

Birds of a feather – Staying Alive: Social Media Tips for Techies

Session 3: What’s new in C# 4.0

  • Optional Parameters
  • Named Parameters
  • Dynamics (same as object, however it defer the binding in runtime).

Session 4: VSTS/TFS 2010 (Mike Azocar, and Mike Moles)

  • Best improvement: QA, Architecture, and Gated Check-in
  • Branch Visualization
  • Work Item Tracking
  • Work Item Hierarchy (even working in Excel)
  • Track change set across branches
  • Rolling tests, Test impacted test cases (Unit Tests Improvement)
  • QA: Historical Debugging – No repro
  • QA: Test and Lab Manager
  • Built on WPF
  • Catch a bug earlier will save cost by multiple times
  • Build Controller with WF

Session 5: Best practices on Developing and Customizing Web Parts

  • Recommend using built-in web parts such as DataForm and DataView
  • MVP – Model, View, and Presenter

Final Session: Prize Drawing

  • I won a Resharper license worthy of the market value $199.00.

Friday, September 25, 2009

Interesting Interview Code Question

My colleague sent me an interesting interview code question and it's pretty fun.

using System;

namespace SomeNamespaceName {

class A {

public void DoAStuff( ) { Console.WriteLine( "A::DoAStuff()" ); }

}

class B {

public void DoBStuff( ) { Console.WriteLine( "B::DoBStuff()" ); }

}

class C {

A _innerA = new A();

B _innerB = new B( );

public static implicit operator A (C c ) {

return c._innerA;

}

public static implicit operator B( C c ) {

return c._innerB;

}

public void DoAStuff( ) { ( ( A )this ).DoAStuff( ); }

public void DoBStuff( ) { ( ( B )this ).DoBStuff( ); }

}

class Program {

static void PassA( A a ) { a.DoAStuff( ); }

static void PassB( B b ) { b.DoBStuff( ); }

static void Main( string[ ] args ) {

C c = new C( );

PassA( c );

PassB( c );

c.DoAStuff( );

c.DoBStuff( );

}

}

}

Question:

1) What does the code print out?

A: A::DoAStuff()
B::DoBStuff()
A::DoAStuff()
B::DoBStuff()

2) Why does it work?

Op A: Operator Overloading

3) Why would I write code like this?

Mu A: Multiple Inheritance Workaround

4) Explain how it works?

A: Using operator overloading A and B to achieve the “type casting” A and B (not the same instance).

Upgraded my home PC from Vista to Windows 7

Finally I upgraded my Vista from home premium to ultimate. It took more than 3 hours to finish. The process was smooth. After I hit upgrade button then hands-off. I started the Windows 7 upgrade (in-system) it warned me that Vista will no longer available and a few programs or drivers will be no longer compatible. In deed, after the upgrading, my Visual Studio 2008 can't work and have to reinstall.

The upgrade process were divided into the following stages.
  • Copying files (fast)
  • Gathering files, settings, and programs (slow)
  • Expanding Windows
  • Installing features and updates
  • Transferring files, settings, and programs (slow)
So according to my colleague, the installation process is much faster if you are doing a fresh installation.

I am pretty happy with the speed of the operating system. The time of waiting has been significantly reduced comparing to Vista. Visual Studio seems much faster to launch now. IE works much faster and the frequency of hanging is significantly reduced. The interface is much easier to use.

Wednesday, February 11, 2009

Use Visual Studio 2008 SDK to customize TFS


Recently I got a chance to assist someone in the other project of my client to generate a report from TFS. He needed a report of all the details of the changeset in certain period of time. I managed to write some sample code for him with Visual Studio 2008 SDK 1.1 which provides API to query TFS history and get the change-set details.

The code is in C#. The test was very successful; I could query the history; then I got changeset list; then I used the changesetid to get all the objects (change instances). There are two main methods you can find in the attached solution. –QueryHistory [1] and GetChangeset[2].

[1]: http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.versioncontrolserver.queryhistory(VS.80).aspx
[2]: http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.versioncontrolserver.getchangeset(VS.80).aspx

Sample code:

        private static IEnumerable QueryHistory()
{
TeamFoundationServer tfs = new TeamFoundationServer(tfsName);

// Get a reference to Version Control.
VersionControlServer versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
string path = @"$/YOUR-TEAM-PROJECT-NAME";
VersionSpec version = VersionSpec.Latest;
int deletionId = 0;
RecursionType recursion = RecursionType.Full;

string user = "YOUR-USER-NAME";
// VersionSpec versionFrom = VersionSpec.ParseSingleSpec("115894", "mahesh_lambe");
//keep it 'null' for first version
VersionSpec versionFrom = null;

// VersionSpec versionTo = VersionSpec.ParseSingleSpec("109014", "mahesh_lambe");
//keep it 'null' for latest version
VersionSpec versionTo = null;

int maxCount = Int32.MaxValue;

bool includeChanges = true;

bool slotMode = true;

bool includeDownloadInfo = true;

IEnumerable enumerable = versionControl.QueryHistory(path, version, deletionId, recursion, user, versionFrom, versionTo, maxCount, includeChanges, slotMode, includeDownloadInfo);

return enumerable;
}


        // Get a reference to our Team Foundation Server.              
private static String tfsName = @"http://YOUR-TFS-SERVER-NAME:8080/";

internal static Changeset GetChangeset(int _changesetNumber)
{
TeamFoundationServer tfs = new TeamFoundationServer(tfsName);

// Get a reference to Version Control.
VersionControlServer versionControl = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
Changeset ch = versionControl.GetChangeset(_changesetNumber, true, true);

Console.WriteLine(ch.ToString());
return ch;
}

Be A Developer That Uses AI

Developers will not be replaced by AI, they'll be replaced by developers that use AI. Generative AI tools are revolutionizing the way de...