|
 Tuesday, January 08, 2008

TFS Build Not Publishing Web Applications

_PublishedWebsites does not exist?! WHAT?! Huh?

One of our TFS builds was succeeding and a fellow developer noticed that the Web App was not getting copied into the _PublishedWebsites folder of our drop location.

I took a look at our TFSBuild.Proj file and I didn't see anything that stood out. I took a look at a similar project who's output was being copied into the _PublishedWebsites directory and the .proj file matched that of the one that did not work.

Solution

The problem was not in the .proj file, but in the actual .csproj file for the Web Applicaiton Project.

.csproj files ARE MSBuild files and inside of that I saw this:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!--<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0WebApplications\Microsoft.WebApplication.targets" />-->

The second Build target file was not getting loaded.

This build target file contains a target by the name of "_CopyWebApplication" which takes the output of the web application and copies it to the _PublishedWebsites directory.

I uncommented this line, checked it back into TFS and re-ran my build and my _PublishedWebsites started showing up. :)

My file now looks like this:

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v8.0WebApplications\Microsoft.WebApplication.targets" />
#    Comments [3] |
 Friday, November 30, 2007

Cruise Control.NET & Visual Source Safe - SS.EXE Hangs

I recently help set up a CI (Continuous Integration) environment using CC.NET (Cruise Control.NET) at a client that I'm at. We're in the process of implementing TFS (Team Foundation Server) but until some red tape is cleared we're still stuck on VSS (Visual Source Safe).

While setting up the environment we were given a test VSS account to work with until everything worked as expected. Well the user they gave me had a blank password.

Example -

User: ccnet Pass: (no password)

The visual source safe source control block looked like this:

<sourcecontrol type="vss" autoGetSource="true" applyLabel="true">
   <executable>C:\Program Files\Microsoft Visual Studio\VSS\win32\SS.EXE</executable>
   <project>$/CCNET</project>
   <username>ccnet</username>
   <password> </password>
   <ssdir>c:\repos\</ssdir>
   <workingDirectory>c:\myBuild</workingDirectory>
   <culture>en-us</culture>
   <cleanCopy>false</cleanCopy>
</sourcecontrol>

When I fired up the CC.NET Service, everything started off fine. The project said "Checking For Modifications" and then it HUNG there, forever. It never stopped. I had to stop the service and then kill SS.exe (source safes process).

Solution

The reason this happened is because of this line:

   <password> </password>

The password was left as " ". It was a space. If I fired up VSS and typed in ccnet and put a space into the password, it would let me in, no problem. But if I did that with CC.NET SS.EXE would hang.

Pretty much, here's what's happening - Source Safe is firing up and its trying to log in and its giving an invalid password. SS.EXE is trying to raise a dialog box, but its running under the context of the Cruise Control.NET service, therefore it cannot open that dialog box.

I changed the password field to this:

   <password></password>

and then it worked flawlessly.

 

Simple solution to a simple mistake. :)

#    Comments [0] |
 Wednesday, June 20, 2007

.NET Scaffolding

Jeremy D. Miller has a great post on keeping source code where it belongs. The thought process behind this is that code should be where YOU would assume it would be. If its data access code, it should be in a project/namespace that is something like Data Access or DAL or Data or something that represents the lower layer of the architecture. If its the business rules/tasks the files should be in a project called Business Rules, or BLL, or Tasks, or something similar. It makes sense, just think about this -- if you walk into a business and are given a project that was created by another developer and you're getting a ADO.NET Exception, you'd expect to find the code Data Access code in a Data Access layer, NOT in the code behind. I should not have to hunt down where you put your data access code.

We're talking about basic separation of concerns. The thing is, many developers lack these concepts because they're under the assumption of "I can write this the correct way, and it will take me 2 weeks, or I can do it quickly and it will take me 2 days." This may not matter when the application is running for a few months, but when you are asked to change the data provider from SQL Server to Oracle, or remove the web service calls and replace them with RPC calls, you're going to find yourself in a world of hurt because you didn't set everything up correctly. At this point they have amounted a large amount of Technical Debt.

He also noted that a large number of people were now using Ruby On Rails (RoR) as their development platform and I won't deny that I also believe that Ruby/Rails is huge right now. Tons of shops are running RoR and even Martin Fowler said on Hansel Minutes that ThoughtWorks was doing about 40% (or more) of their business with Ruby. The key point Jeremy brought up is that "RoR forces web developers into a bit of a straight jacket, but that's a good thing in a way." I completely agree. RoR enforces a consistent source code tree layout which allows for developers to easily find there way around a project. "Developer A" can create a project with RoR and then "Developer B" can come along and take a look at it and be familiar with the code layout and structure. The RoR community has agreed that this is the basic way to organize a project and it seems to be working for them.

So what about .NET? Enter Tree Surgeon. Right now, its a stand alone application, but in its near future it should be implemented as a template in Visual Studio 2005/2008. So what is it? It's a application that will create that straight jacket that Jeremy spoke of. It gives the developer a basic set up of layers, unit tests, code coverage and build script. It builds the entire source code directory and allows you to build on top of it. The source code layout follows a white paper written by Mike Roberts. I've been using it for quite awhile and I'm one of the developers on the project. I recently updated the source to allow creation of Visual Studio 2005 projects. Please note, this is only on the source and has not been reflected on the production release. Download the source, run it and then choose a application name, and generate the project source directory tree. Open the solution file and your application is ready to go.

The best part is that its easy to integrate existing projects into this format. I've done it quite a few times to allow for easy integration into my clients CI environment.

If you have any requests for Tree Surgeon, please visit the Issue Tracker page and submit and issue.

Enjoy!

#    Comments [0] |
 Thursday, June 07, 2007

Teamprise Explorer Client vs. Visual Studio Team Explorer

Over the weekend I had the time to work with Teamprise Explorer and Visual Studio Team Explorer while working on an open source project that I'm a part of. This was the first time I've worked with Teamprise explorer and Visual Studio Team Explorer. Since Codeplex houses its source on Team Foundation Server (TFS) I was required to use one of these options. This is a little look into my experience.

First off let me start by saying that I'm a Subversion junkie. I keep all of my own personal source code in Subversion and I've helped many clients implement Subversion in my time. I'm an avid user of TortoiseSVN because of its ease of use within Windows Explorer. Working with TFS was very similar to that of Subversion but the terminology was different and in my opinion Teamprise was a little more difficult to use. I originally wanted to use the Visual Studio Plug-in but I didn't want to wait for the 246 MB file to download so I could install a plug-in. :\ Therefore, I went with Teamprise first. They will give you a free license to work with Codeplex if you're working on a project, so that was a win/win for me.

Teamprise Explorer Client will allow you to connect to a Team Foundation Server to access source code (its user interface reminds of me of WinCvs quite a bit, yet  a lot more polished than that of WinCvs). The only problem that I had with Teamprise is that when I went needed to edit the code I had to "Checkout for Edit". If I did this on the entire directory tree such as my "src" directory it would log everything in edit mode. Therefore, when I went to upload the changes the entire source tree was being uploaded. NO BUENO. I know that on average I like to see what I've edited (yes, I'm used to TortoiseSVN) in some type of explorer window. This didn't happen on Teamprise (maybe there is a way to see if a file has changed other than the Pending Changes window, if so, someone please let me know). In the end, I got frustrated, ended up clicking some button on Teamprise explorer and overwrote all my changes somehow. THAT SUCKS. I got frustrated and decided to download the plug-in and start working that way.

Visual Studio Team Explorer Plug-in was great. Its interface reminded me of the old days when I use to personally use Source Safe 6.0. The icons were similar and it was familiar ground. I think we may have a winner. After making my changes again I was able to easily see what changed through simple icon's changing colors and I checked everything in really easily. It was very seamless. The only downside to Visual Studio Team Explorer is the install process. First you have download an IMG file, then download an install an IMG extractor and then open the IMG, then install. Only then did I get the full Visual Studio Integration. Very nice.

One downside that I see is that the Express SKU's don't allow plug-ins so this kind of sucks for those guys. How can you have an open source hosting site that doesn't allow its users to easily get the source. Don't get me wrong, they can use Teamprise but they have to know there is a learning curve with that. I didn't have the patience for it this time around.

There is hope on the horizon though...

TortoiseSVN

CodePlex will be offering TortoiseSVN Support to Team Foundation Server. Therefore you will be able to use a tool such as TortoiseSVN to access Team Foundation Server. Supposedly this is to be released on or around June 18th of this month. In a nutshell there will be a bridge built between SVN Commands and TFS commands. I would assume this is a good place for the Adapter pattern to be put to work.

Hopefully this comes to fruition, I can see a lot of people possibly moving their projects to CodePlex if that's the case.

#    Comments [1] |
 Wednesday, May 02, 2007

Looks like I missed the boat (CruiseControl.NET 1.2 Released)

Well, it looks like I missed the boat on this release of CruiseControl.NET 1.2.x back in January of 07. Oops. It looks like its fairly simple to upgrade, no breaking changes from what I can see.

The new feature that got me excited is that the Subversion provider now supports checking out the source. I had normally solved this by performing an svn-update (or svn-checkout) through the NAnt Contrib tasks. Its nice that I can now have CruiseControl.NET doing this for me instead of my tasks doing it for me.

 

#    Comments [1] |
 Thursday, April 26, 2007

Forcing users to provide a message in SVN/TortoiseSVN (Including HOWTO)

I use Subversion (SVN) for my source control and I access SVN through TortoiseSVN so that its integrated into the Windows shell. The past few companies I've worked at have all utilized SVN in one way or another, but we've always had a problem with developers submitting code without attaching a message to the commit.

Why does this matter? If you, as a developer, check in 20 files that are related to project trunk X, without a message, how am I suppossed to know why you checked those into the repository? Did you fix a bug? Did you implement a new feature? Did you complete a task? Did you add a new project to the system? What did you do? Thats the problem if you do not provide a message for each commit, others have no idea of knowing what you did

By not providing the message we're not keeping track of what we did and why we did it. This comes heavily into play when you need to revert back to a certain revision, but you're not sure which revision to go back to. The only thing you remember is "I know it was when we implemented feature 'ABC' into the system." If I provided a comment, I could see in the Tortoise Log that on MM/DD/YYYY at XX:XX time developer "Bob" implemented the feature. Knowing that, I could find the version number and revert back to that revision. Without this information I might spend HOURS UPON HOURS searching through lines of code looking for a key piece that helps me decide if this is the version I want. This could have been avoided if a simple message was provided.

HOWTO: Requiring Messages

By default SVN does not require a message when committing. You can tap into the hooks of SVN and provide some custom code to force your developers to provide a message. The script to do this is below. Note: I cannot take credit for creating this script, as it was found on the net and I dont have the source. So, if you wrote this script, please let me know and I'll add your name here as the author. :) 

Steps:

  1. Create Script
  2. Save as pre-commit.bat
  3. Drop it into the hooks directory of your repository.
  4. DONE

The Script (also provided at the bottom of this post as a download)


@echo off
::
:: Stops commits that have empty log messages.
::

setlocal

set "REPOS=%~1"
set "TXN=%~2"
set "SVNLOOK=c:\progra~1\subversion\bin\svnlook.exe"

:: Make sure that the log message contains some text.
for /f "tokens=*" %%i in ('%SVNLOOK% log -t "%TXN%" "%REPOS%"') do set "LOGMSG=%%i"
if not "%LOGMSG%"=="" exit 0

echo. 1>&2
echo Your commit has been blocked because you didn't give any log message! 1>&2
echo Please write a log message describing the purpose of your changes and 1>&2
echo then try committing again. -- Thank you 1>&2
exit 1


Please note: This assumes that you have Subversion installed in the C:\Program Files\

Save this script as "pre-commit.bat".

Now drop this into your hooks directory of your actual repository. SVN will now execute this batch file each time a commit is taking place. It will check that a message exists. If one does not, it will throw an error message that is highlighted in dark red (above, in the script).

If you are using TortoiseSVN, this is what you will see:

Thats it. Now users cannot commit without a message. :)

 

Good Message Recommendations

Even if messages are required it still does not prevent a user from typing some garbage into the screen. Here's what I recommened to my team...

SVN Messages should contain:

  1. What you did. Give a quick explanation "altered file processing routine" or "created new project library" 
  2. Why you did it. This could be as simple as stating "Fixed Bug 456" or "added new library to handle file conversions."

Example messages:

"Fixed bug 456 by altering file processing routine"

"Added new library to project XYZ to handle file conversions".

There are also many other plug-ins that have been built for TortoiseSVN and SVN in general. Just search for them and you should be able to find something that matches your bug tracking system (such as Gemini).

Conclusion

Forcing the developers to provide a message has enabled the team to communicate better. No longer are members constantly asking the question of "when was this fix applied?" or "What version did this happen in?" The messages make the respository easier to manage and a respository thats easy to manage means we have a healthier code base. :)

Download

pre-commit.zip (.48 KB)

kick it on DotNetKicks.com

#    Comments [12] |
 Monday, April 16, 2007

Tree Surgeon Development

As of a couple weeks ago, I joined the Tree Surgeon open source project. Recently, Bil Simser took over the project and opened it up on CodePlex. The development team will be adding many new features to the application to help in the setup of the development tree structure and build integration process. Keep your eyes peeled!

#    Comments [0] |
 Monday, March 05, 2007

Tree Surgeon - .NET 2.0 Reference Incorrect

Problem

The .NET Framework reference in the most recent release of Tree Surgeon has an old reference to .NET 2.0 Beta 1. This is in the NAnt.exe.config file.

This will produce results that will not compile when using the <msbuild> task of the NAntContrib Tasks.

Fix

Open the file located in "ProjectName/Tools/nant/NAnt.exe.config" file.

Find this:

<framework 
   name="net-2.0" 
   family="net" 
   version="2.0" 
   description="Microsoft .NET Framework 2.0 Beta 1" 
   runtimeengine=""
   sdkdirectory="${path::combine(sdkInstallRoot, 'bin')}" 
   frameworkdirectory="${path::combine(installRoot, 'v2.0.40607')}" 
   frameworkassemblydirectory="${path::combine(installRoot, 'v2.0.40607')}"
   clrversion="2.0.40607"
>

Then replace it with this:

<framework 
   name="net-2.0" 
   family="net" 
   version="2.0" 
   description="Microsoft .NET Framework 2.0" 
   runtimeengine=""
   sdkdirectory="${path::combine(sdkInstallRoot, 'bin')}" 
   frameworkdirectory="${path::combine(installRoot, 'v2.0.50727')}" 
   frameworkassemblydirectory="${path::combine(installRoot, 'v2.0.50727')}"
   clrversion="2.0.50727"
>

This will fix the issue and allow you to remove the <solution> task from the default build file that is included in each project generation.

You will now be able to utilize the <msbuild> task in the NAntContrib. See below:

<target name="compile" description="Compiles using the AutomatedDebug Configuration">
        <loadtasks assembly="tools/nantcontrib-0.85/bin/NAnt.Contrib.Tasks.dll" />
        <msbuild project="src\MyProject.sln">
            <property name="Configuration" value="AutomatedDebug" />
        </msbuild>
</target>

#    Comments [0] |
 Wednesday, February 28, 2007

Confluence Tree Surgeon

Mike Roberts over at ThoughWorks have a project to help with continuous integration.

The product is called "Tree Surgeon". Tree Surgeon solves the problem of how to set up a development tree.

"Tree Surgeon is a .NET development tree generator. Just give it the name of your project, and it will set up a development tree for you in seconds. More than that, your new tree has years worth of accumulated build engineering experience built right in."

What the product does is it allows you to specify a project name and the application will create a development tree for you (code generation). This tree includes a solution, the tools (NUnit, NCover, NAnt) and a build file and script to execute the build. It saves TONS of time when creating a new project and needing to add it to your build.

Example

Creating a new development tree:

This will generate this tree structure:

Inside of the "ExampleApplication Folder" we have the build and the go script. The "go" script compiles, runs NUnit and NCover. Its the workhorse of the system. Run this from the command line. If you want to see the results while in a command window, I'd advise editing the go.bat file and adding @pause at the end of the script so you can see the results before the window closes.

The solution for the project is located in the 'src' directory:

You can execute the go.bat file and it will complile, and run NUnit and NCover on your application.

The best part about this is that its all configurable. Edit the cs.vm files in the C:\Program Files\Tree Surgeon\Resources\Templates directory and you'll be able to affect the output of the code generation. Plus, its all open source, so you can get the code from the site.

This could help a lot of companies get up and running with a development tree in their source control.

*Note: Currently Tree Surgeon only exports C# files.

I'll be writing more about Source Control Management as time continues... stay tuned.

#    Comments [0] |
 Wednesday, February 07, 2007

Simian Upgrade

For those of you who use Simian, please be aware, they upgraded the product and the old "-recurse" option no longer works. Read below on how to fix it.

The Issue

I downloaded it last night to test it with my teams current continuous integration environment through Cruise Control .NET (CCNET).  I looked at some examples on the CCNET website on how to run this as a NAnt task and found that it should be fairly easy. I just needed to recurse through the directories and have it run on all C# files (*.cs). Unfortunately I was getting a "Invalid Option" each time I ran this code:

simian-2.2.13.exe -recurse=*.cs -formatter=xml:simian.xml

 

The Issue, Part 2

I finally figured out that the docutmentation on the CCNET site was incorrect. The new product removed the -recurse option and replaced it with -includes and -excludes options to resemble the file globbing method of retrieving files.

I then ran the command as they recommended on the site:

simian-2.2.13.exe -includes=**/*.cs -formatter=xml:simian.xml

I then got this error: "Error: Illegal characters in path."

 

The battle continues

I continue to battle this until I finally give up I try wrapping paths in quotes, executing using different syntax, passing in different wild cards. I combed the documentation with a fine tooth comb, only to find, NOTHING.

 

Resolution

I resorted to emailing support to ask for help.

To my amazement, I had a reply within 2 hours stating that I found a bug in the new release. They said they would fix it and upload a new version ASAP. 5 Hours later, the new version was live on the site.

I downloaded the new version, version 2.2.14, and ran the command

simian-2.2.14.exe -includes=**/*.cs -formatter=xml:simian.xml

I ran the command and the system placed my results into my requested XML File. I was now able to integrate it into my continuous integration system.

With it in place, I can now see my similiarity results.

Cruise Control .NET Website support link

#    Comments [0] |