TechnicalArchitectureWorx

The (Unofficial) ITWorx Technical Architecture Blog

Archive for the ‘VS 2005’ Category

MsTest working in CruiseControl.Net

Posted by archworx on June 6, 2007

I’ve trying to get MsTest, the unit tests generated by Visual Studio 2005, to work with cruise control for a while now. So finally I was able to get it to work following these steps below 

Let’s say we have a solution called ITT in the following path c:/ITT, first we’ll look at the ccnet config file, after you compile using the msbuild task, you have to call an exec task to execute the MsTests, but before that you have to delete the test results file because MsTest won’t run if the file is already there, we are doing this by calling a batch file to delete this test results file and also delete the temp folders created by MsTest. After that you have to merge the results file with build output so I can be displayed in the dashbaord.

 <project name=”ITT”>
    <webURL>http://localhost/ccnet</webURL&gt;
    <triggers>
      <intervalTrigger seconds=”100″ />
    </triggers>
    <modificationDelaySeconds>120</modificationDelaySeconds>

    <!– here you do the task to get the project from the source control –>
    <!–sourcecontrol type=”vss” autoGetSource=”true” applyLabel=”false”>
    </sourcecontrol–>

    <tasks>
      <!– task to build the solution–> 
      <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\MSBuild.exe</executable>
        <workingDirectory>c:\ITT</workingDirectory>
        <projectFile>ITT.sln</projectFile>
        <targets>Build</targets>
        <timeout>60</timeout>
        <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
      </msbuild>

      <exec>
        <!– call a batch file that deletes results.trx –>
        <!– this is required as MsTest will not create the file if it exists–>
        <!– the batch file also deletes the temp folders created by MsTest –> 
        <executable>delTestLog.bat</executable>
        <baseDirectory>c:\ITT</baseDirectory>
        <buildArgs></buildArgs>
        <buildTimeoutSeconds>30</buildTimeoutSeconds>
      </exec>
     
      <exec>
        <!– the exec task to execute the MsTest task –>
        <executable>C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\MSTest.exe</executable>
        <baseDirectory>c:\ITT</baseDirectory>
        <buildArgs>/testcontainer:\ITT\AnalysisLibTests\bin\Debug\AnalysisLibTests.dll /runconfig:localtestrun.testrunconfig /resultsfile:results.trx</buildArgs>
        <buildTimeoutSeconds>600</buildTimeoutSeconds>
      </exec>

    </tasks>
    <publishers>
      <!–to get the test results in the dashboard we have to merge the results XML file –>
      <merge>
        <files>
          <file>c:\ITT\results.trx</file>
        </files>
      </merge>
      <xmllogger />
      <email from=”CruiseControl” mailhost=”mail” includeDetails=”TRUE”>

      </email>
    </publishers>
</project>

The next step is to modify the dashboard config file to display the test results, first we update the dashboard.config file to include the MsTests details menu item and then we add the MsTest results summary to the main build page. The required xsl files are already included with ccnet, you can customize the xsl to fit your needs

<buildReportBuildPlugin>
  <xslFileNames>
    <xslFile>xsl\header.xsl</xslFile>
    <xslFile>xsl\modifications.xsl</xslFile>
    <xslFile>xsl\compile.xsl</xslFile>
    <xslFile>xsl\MsTestSummary.xsl</xslFile> <!– MsTest results summary in main page–>
    <xslFile>xsl\unittests.xsl</xslFile> <!– Nunit test results, can be removed if not required any more –>
    <xslFile>xsl\fxcop-summary.xsl</xslFile>
    <xslFile>xsl\NCoverSummary.xsl</xslFile>
    <xslFile>xsl\SimianSummary.xsl</xslFile>
    <xslFile>xsl\fitnesse.xsl</xslFile>
  </xslFileNames>
 </buildReportBuildPlugin>
 <buildLogBuildPlugin />
   <xslReportBuildPlugin description=”NUnit Details” actionName=”NUnitDetailsBuildReport” xslFileName=”xsl\tests.xsl” />
   <xslReportBuildPlugin description=”NUnit Timings” actionName=”NUnitTimingsBuildReport” xslFileName=”xsl\timing.xsl” />
   <xslReportBuildPlugin description=”MSTest Report” actionName=”MSTESTReport” xslFileName=”xsl\MsTestReport.xsl”/> <!– menu item –>
   <xslReportBuildPlugin description=”NAnt Output” actionName=”NAntOutputBuildReport” xslFileName=”xsl\NAnt.xsl” />
   <xslReportBuildPlugin description=”NAnt Timings” actionName=”NAntTimingsBuildReport” xslFileName=”xsl\NAntTiming.xsl” />
   <xslReportBuildPlugin description=”FxCop Report” actionName=”FxCopBuildReport” xslFileName=”xsl\FxCopReport.xsl” />
   <xslReportBuildPlugin description=”NCover Report” actionName=”NCoverBuildReport” xslFileName=”xsl\NCover.xsl” />
   <xslReportBuildPlugin description=”Simian Report” actionName=”SimianBuildReport” xslFileName=”xsl\SimianReport.xsl”/> 

 That’s all

Posted in Continuous Integration, Nader, VS 2005 | 3 Comments »

Generating Documentation for .NET assemblies using SandCastle

Posted by archworx on June 4, 2007

I was developing a Control Library for .NET 2.0 and wanted to generate neat looking documentation from XML tags that I had written in code. So I googled around for a bit until I found that you can use a tool called SandCastle to generate HTML documentation that could be transformed into CHM and HxS formats. Here are the steps you have to do:

1- Inside VS2005 right click your project in the Solution Explorer and choose ”Properties”.

2- Click “Build” tab, under “Ouput” make sure that you check the “XML documentation file” checkbox. Once you do so, you can fill in a textbox that specifies the path of where the XML file (that contains the tags you put in code) will be generated.

3- Download and Install HTML Help Workshop .

3- Download and Install SandCastle March 2007 CTP .

4- Download and Install SandCastle Help File Builder (A really cool project on CodePlex that provides a UI that utilizes Sandcastle to generate Help Files)

5- Use SandCastle Help file Builder to generate your documentation .

Voila, you’ve got a cool professional documentation for your .NET project

Posted in .NET 2.0, AFathalla, Documentation, VS 2005 | 5 Comments »

Edit and Continue

Posted by archworx on May 23, 2007

Source: http://msdn2.microsoft.com/en-us/library/bcew296c(VS.80).aspx

Edit and Continue is a time-saving feature that enables you to make changes to your source code while your program is in break mode. When you resume execution of the program by choosing an execution command like Continue or Step, Edit and Continue automatically applies the code changes with some limitations. This allows you to make changes to your code during a debugging session, instead of having to stop, recompile your entire program, and restart the debugging session.

Posted in .NET 2.0, El-Geish, Programming, VS 2005 | Leave a Comment »

‘My’ Namespace in VB.Net 2.0

Posted by archworx on May 23, 2007

For rapid development, Visual Basic .Net 2.0 introduced a namespace called My to access all the stuff that belongs to you like computer, network, printers, keyboard, forms, and others.

My Namespace 

For eaxmple, if you need to access the network, you just type: My.Computer.Network.

If My.Computer.Network.IsAvailable Then
    My.Computer.Network.DownloadFile("http://myserver.com/log.txt","c:\archives\serverlog.txt")
End If

Click here for more info.

Posted in .NET 2.0, El-Geish, Programming, VS 2005 | Leave a Comment »

ASP.NET Black Belt Tips and tricks

Posted by archworx on February 7, 2007

I was fortunate enough to attend this great session in the MDC by the great Patrick Hynds.

Here are some great tips I got:

1. The Page.SetFocus method that is used to set focus on a control. (A cool feature and somehow unknown by many including me 🙂 ).

2. If you want to maintain the scroll position in a page there is the “MaintainScrollPositionOnPostback” property which is here to replace the dreaded “smart navigation” feature in ASP.NET 1.1.

And then there was a really cool part on membership providers, Here are my notes on that:

Membership Providers

 

Why Custom providers?

  • If you need a different schema for the db other than the default schema,
  • If data is in another database MS doesn’t support.(Oracle- Informix).
  • If you need a new feature not implemented in the default provider.

 

Here are a few more ideas:

  • Minimum implementation of Custom provider is Validate User.
  • Location tag in web.config to set zones for anonymous access, others for authenticated users.
  • When inplementing a custom membership provider you will need to implement a custim roles provider as well.

 

Posted in .NET 2.0, MSamy, VS 2005 | 2 Comments »

Encrypting Web.Config Sections in .NET 2.0

Posted by archworx on October 18, 2006

Encrypting sections in your Web.config file that contain sensitive information (such as Connection Strings) is a security precaution that any decent ASP.NET developer should take care of, and in .NET 2.0 it couldn’t be any easier. You can encrypt any section of your Web.config file from the command line using the aspnet_regiis command or programatically from within your code. To do it from the command line you can open your Visual Studio Command Prompt and type

aspnet_regiis -pe "NAME OF YOUR WEB.CONFIG SECTION" -app "/YOUR WEBSITE NAME ON IIS"

Voila….the configuration section you typed in the command now is now encrypted, here are screenshots of a ConnectionStrings Section in a web.config file after it has been encrypted.

If you prefer to encrypt a Web.config section programatically, you can do it through the following code:

Configuration config = Configuration.GetWebConfig
uration(Request.ApplicationPath);
ConfigurationSection section = config.Sections["connectionStrings"];
section.ProtectSection ("DataProtectionConfigurationProvider");
config.Update();

You can use this technique if you don’t have full access to the Web Server.

References : http://www.developerfusion.co.uk/show/5263/ 

 

 

Posted in .NET 2.0, AFathalla, VS 2005 | 2 Comments »

MS faces some VS 2005 compatiblity issues with vista

Posted by archworx on October 10, 2006

As you will read in the blog posting below, MS is facing some compatibility issues between VS 2005 and Windows Vista, apparently, they have already release SP1 beta which is supposed to fix the problem. But from the post below, I’d weigh my options well before I develop an application for Windows Vista  on VS 2005, at least increase the risk factor in the project plan.

Check it out

Posted in MSamy, News, Vista, VS 2005 | 1 Comment »