Sushi Shift is out of Beta!

I know it’s been a long time since i’ve posted here, and to be honest, i sort of forgot i had this blog.

We’ve recently gotten our game out of beta and we’ve been trying to get the word out. We’ve submitted the app to blogs and review sites, but nothing seems to be helping right now.

So maybe I can use this blog and its limited traffic to maybe give our game some extra needed exposure.

Our game is a puzzle game with unique twist — gravity. ย The link to the game is below ๐Ÿ™‚

http://goo.gl/nAdaf — Sushi Shift on Google Play.

Stop Internet Censorship!

I’ve censored the following, in protest of a bill that gives any corporation and the US government the power to censor the internet–a bill that could pass THIS WEEK. To see the uncensored text, and to stop internet censorship, visit:
http://americancensorship.org/posts/739/uncensor

โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ of any โ–ˆโ–ˆโ–ˆโ–ˆ is โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ and โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ the โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ of โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ!

โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ is our โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ, โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ is our โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ. Don’t let โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ it โ–ˆโ–ˆโ–ˆโ–ˆ โ–ˆโ–ˆโ–ˆโ–ˆ us!

We need to fix it, we need to do something!

At the time of this posting, i’m only about half-way done watching this video, but i feel that I need to post this now and share it with everyone i know. What he says sums up what is wrong with our government and makes me want to go to Capitol Hill and kick every politician out of Congress and force change to happen.

Now if you’re more to the Left or more to the Right doesn’t really matter here. No matter what your beliefs in how government works are, they clearly don’t line up with what reality is. Even if you’re not very political and have no interest in politics, what happens in our government DOES affect you.

I’d really like to see some real change happen. Some of the ideas like elections funded from public small amounts only or the ways to reform our government.

Give yourself an hour and a half and watch this.

Deploying Windows Services from TFS

As part of our initiative to automate code deployments, we needed to move windows services from TFS to our test servers. The way we did this before was to have a build stage all the files and then either stop the services on the destination machine manually, copy files, and restart the services, or use a homebrewed application to deploy the service; which is fine and dandy, except that the original developer isn’t with the company anymore and the application is limited in certain ways.

So to solve this, I went ahead and created a new build template that would deploy our windows services from a TFS build.

Some prerequisites:

  • PsExec must be on the build machine
  • Your build service must be an admin on the machine you’re deploying to (to be able to stop and start services)

First, we’ll set up a new Code Activity, it’s very similar to the DeployFiles class i wrote about before

[csharp]
using System;
using System.Activities;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Build.Workflow.Activities;
using Microsoft.TeamFoundation.Build.Workflow.Tracking;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
namespace BuildProcess.Activities
{
[BuildActivity(HostEnvironmentOption.Agent)]
public sealed class DeployWindowsService : CodeActivity
{
//Source dir being deployed from
[RequiredArgument]
public InArgument<string> SourceDir { get; set; }
//Destination dir being copied from
[RequiredArgument]
public InArgument<string[]> DestinationDir { get; set; }
//Files to include
[RequiredArgument]
public InArgument<string> FileInclusions { get; set; }
//Folders to include
[RequiredArgument]
public InArgument<string> FolderInclusions { get; set; }
[RequiredArgument]
public InArgument<string> CollectionName { get; set; }
public InArgument<string> ConfigLocations { get; set; }
//globals
public string fileInclusionPattern = "";
public string folderInclusionPattern = "";
protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the Text input argument
string fileInclusions = context.GetValue(this.FileInclusions);
string folderInclusions = context.GetValue(this.FolderInclusions);
string configLocations = context.GetValue(this.ConfigLocations);
string[] destinations = context.GetValue(this.DestinationDir);
string collectionName = context.GetValue(this.CollectionName);
DirectoryInfo sourceDir = new DirectoryInfo(context.GetValue(this.SourceDir));
//parse exclusions, add them to regex patterns
if (!String.IsNullOrWhiteSpace(fileInclusions))
{
string[] fileinarr = fileInclusions.Split(‘,’);
fileInclusionPattern = "(";
foreach (string s in fileinarr)
{
fileInclusionPattern += s.ToUpper().Trim().Replace(".", @"\.").Replace("*", @"[a-zA-Z0-9]*") + "$|";
}
if (fileInclusionPattern.EndsWith("|"))
fileInclusionPattern = fileInclusionPattern.Substring(0, fileInclusionPattern.Length – 1);
fileInclusionPattern += ")";
}
if (!String.IsNullOrWhiteSpace(folderInclusions))
{
string[] folderinarr = folderInclusions.Split(‘,’);
folderInclusionPattern = "(";
foreach (string s in folderinarr)
{
folderInclusionPattern += s.ToUpper().Trim().Replace(".", @"\.").Replace("*", @"[a-zA-Z0-9]*") + "$|";
}
if (folderInclusionPattern.EndsWith("|"))
folderInclusionPattern = folderInclusionPattern.Substring(0, folderInclusionPattern.Length – 1);
folderInclusionPattern += ")";
}
foreach (string dir in destinations)
{
DirectoryInfo destDir = new DirectoryInfo(dir);
//Used for debugging, you don’t need this, unless you want to display something custom here.
context.Track(new BuildInformationRecord<BuildMessage>()
{
Value = new BuildMessage()
{
Importance = BuildMessageImportance.High,
Message = "Source: " + sourceDir.FullName +
"\r\nDestination: " + destDir.FullName +
"\r\nFolder Inclusion Pattern: " + folderInclusionPattern +
"\r\nFile Inclusion Pattern: " + fileInclusionPattern +
"\r\nFolder Inclusions String: " + folderInclusions +
"\r\nFile Inclusions String: " + fileInclusions,
},
});
CopyDir(sourceDir, destDir);
}
//copy config files
if (!String.IsNullOrWhiteSpace(configLocations))
{
string strTFSName = collectionName;
//set up TFS connectivity
Uri tfsName = new Uri(strTFSName);
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(tfsName);
VersionControlServer vcs = (VersionControlServer)tfs.GetService(typeof(VersionControlServer));
//copy config files to proper location
string timestamp = DateTime.Now.Ticks.ToString();
string workspacePath = @"C:\temp\TFSConfigDeployment_" + timestamp;
Workspace ws = vcs.CreateWorkspace("TFSConfigDeployment_" + timestamp, vcs.AuthorizedUser);
//get the workspace locally
ws.Map(configLocations, workspacePath);
ws.Get();
foreach (string configDir in destinations)
{
CopyDir(new DirectoryInfo(workspacePath), new DirectoryInfo(configDir));
}
RemoveWorkSpaceDirectory(workspacePath);
}
}
private void RemoveWorkSpaceDirectory(string workspacePath)
{
DirectoryInfo dir = new DirectoryInfo(workspacePath);
var files = dir.EnumerateFiles();
foreach (FileSystemInfo info in files)
{
string filePath = info.FullName;
if ((File.GetAttributes(filePath) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
File.SetAttributes(filePath, FileAttributes.Normal);
}
}
var subDirs = dir.EnumerateDirectories();
foreach (DirectoryInfo subDir in subDirs)
{
RemoveWorkSpaceDirectory(subDir.FullName);
}
dir.Delete(true);
}
private void CopyDir(DirectoryInfo sourceDir, DirectoryInfo destDir)
{
//create destination dir if it doesn’t exist
if (!destDir.Exists)
{
destDir.Create();
}
// get all files from current dir
FileInfo[] files = sourceDir.GetFiles();
//copy ze files!!
foreach (FileInfo file in files)
{
string destFilePath = Path.Combine(destDir.FullName, file.Name);
if (!String.IsNullOrWhiteSpace(fileInclusionPattern))
{
if (Regex.IsMatch(file.Name.ToUpper(), fileInclusionPattern))
{
if (File.Exists(destFilePath))
{
if ((File.GetAttributes(destFilePath) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
File.SetAttributes(destFilePath, FileAttributes.Normal);
}
File.Delete(destFilePath);
}
file.CopyTo(destFilePath);
if ((File.GetAttributes(destFilePath) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
{
File.SetAttributes(destFilePath, FileAttributes.Normal);
}
}
}
}
// get subdirectories.
DirectoryInfo[] dirs = sourceDir.GetDirectories();
foreach (DirectoryInfo dir in dirs)
{
// Get destination directory.
string destinationDir = Path.Combine(destDir.FullName, dir.Name);
if (!String.IsNullOrWhiteSpace(folderInclusionPattern))
{
if (Regex.IsMatch(dir.Name.ToUpper(), folderInclusionPattern))
{
// Call CopyDirectory() recursively.
CopyDir(dir, new DirectoryInfo(destinationDir));
}
}
}
}
}
}

[/csharp]

For the next step, you’ll also want to look at the previous post about deploying files from TFS. After you’ve opened up your ProcessTemplate, you’ll want to have the following arguements:

  • DeploymentDir – In – String[]
  • SourceRootDir – In – String
  • CollectionName – In – String
  • PsExecPath – In – String
  • ServiceName – In – String
  • ServerName – In – String
  • FileInclusions – In – String
  • FolderInclustions – In – String
  • RestartService – In – Boolean – True

Each of these you’ll probably want to add to the Metadata Argument so you can keep your build definitions organized.

And you’ll want to add the following Variable:

  • PsExecResult – Int32 – Revert Workspace and Copy Files…

Under Process > Sequence > Run On Agent > Try Compile, Test, and Associate Changesets and Work Items > Revert Workspace and Copy Files to Drop Location > If Deployment Location is Set you’ll want to place a new Sequence and call it Stop Service, Copy Files, Start Service.

Inside that Sequence you’ll want to place an Invoke Process activity, the new DeployWindowsServices code activity, and an If statement with another Invoke Process activity in the Then clause.

For the first Process Invocation:

Arguements: ย ServerName + ” -s -d net stop ” + ServiceName
DisplayName: Stop Service
FileName: PsExecPath
Result: PsExecResult

For the Deployment Activity:

CollectionName: CollectionName
DestinationDir: DeploymentDir
DisplayName: Deploy Windows Service
FileInclustions: FileInclusions
FolderInclustions: FolderInclusions
SourceDir: ย BinariesDirectory + “\” + SourceRootDir

For the If statement, just check to see if RestartService is set to True, and then enter the values for the second Process Invocation:

Arguements: ย ServerName + ” -s -d net start ” + ServiceName
DisplayName: Start Service
FileName: PsExecPath

*NOTE, THE FOLLOWING SECTION DOES NOT WORK PROPERLY YET*

After the If statement, you’ll want to add in another If, this will check to see if PsExec has failed or not.

Since this isn’t working properly yet, i just check to see if PsExecResult is ‘1’, which it hasn’t been as of this writing. In the Then block, add a Throw activity and have it throw an exception of:

[csharp]
New Exception("PsExecResult: " + PsExecResult.ToString())
[/csharp]

Optionally, you can also add WriteBuildMessage and WriteBuildWarning activities to your Invoke Process Activities, these are nice because you can see what the process you are invoking outputs.

New Camera and weekend exploits!

Ever since the trip to North Carolina I’ve been wanting to get a new camera, a DSLR to be precise. I’ve been looking at different cameras for the last week or so, trying to decide between a Canon T2i, a Nikon D90, and a Nikon D7000. Well, earlier this week i finally settled and got the D7000. And thanks to my friend Angela, who hooked me up with a Amazon Prime trial I was able to get 1-day shipping for 4 bucks! Order the camera, get it within the next two days, that was the plan anyway. The first day I get home from work and see a note on my door. The package required a signature on delivery, so they couldn’t just leave the camera on my door step. I guess that’s smart of Amazon to do, require the signature on expensive items. I’d never had that happen before, even on things i’d bought from Amazon. I decided that the second day i’d take a half-day from work so i could catch the delivery truck and get my precious new toy. No such luck. I get there 15 minutes too late and get another note stuck on my door. So, what i did was change the package to be held at the UPS Customer Center, so i could pick it up that day. I didn’t want to wait another day. I NEEDED MY PRECIOUS!

Saturday, after staying out a little late the night before after picking up my camera and going to judo, a few friends and I decided to go out for drinks and eat sushi for dinner, aka an awesome chance to try out my new camera ๐Ÿ˜€

Osaka Sushi Restaurant
Osaka is delicous, it’s actually one of my favorite places to get sushi at. But before we get to that we take a little detour. On the way up to Osaka, we get a phone call from Daphne, saying she has to work late. FOR AN ENTIRE HOUR!

 

DSC_0098
Sarah and I take this opportunity to get some delicious iced beverages at the Zen Tea House while we waited.
Abandoned house
After we ate at Osaka, we decided to take a little walk to help our food digest and to use up some time before heading out to Sergio’s World Beers. On the way, we saw this old house in very sad shape.
DSC_0110
After our walk we headed down to the bar where we partook in some delicious beverages. it was hot so a Radler was totally in order ๐Ÿ˜€
DSC_0123
Sarah found this adorable beer hidden in one of the fridges. It was quite good actually.
DSC_0118
Mary decided to take a shot and try one of the Fruit Ale’s on draft, it was a Strawberry Ale. Oh man, that was good! Very sweet!ย We stayed for a while chit chatting about this and that and eventually went home, I took a nap on the drive back :3

Sunday. Mary and I decided to meet up at Berheim Forest to practice with our cameras (Mary has a D90). We walked around taking pictures of all sorts of things.
DSC_0152
These geese were protecting their goslings from other geese trying to steal the food people were throwing at them. Geese can be VICIOUS!

 

DSC_0142
Typical, insect doing something with a plant picture. Also, <insert camera talk about blurriness and focus point here>.
DSC_0254
Mary. I don’t care what she says, I like this picture ๐Ÿ™‚ After Bernheim we went and ate at Saigon Cafe, which was delicious! I’m really glad i got introduced to Vietnamese food, it’s so good! Then it was off to Heine Bros for some coffee before the trip home.

Once i got to my parents that evening I played with my camera some more, mainly taking pictures of the dogs.
DSC_0277
Nero begging for food. Can’t you tell? He hasn’t eaten in minutes!

DSC_0276
Papa just wanting attention. Who can resist those eyes?

One thing i’ve noticed is that Nero and Papa are very photo conscious. They’re quite good at looking at the camera and being adorable.
DSC_0329
Homer on the other hand, couldn’t give two licks about cameras being pointed at him. He’s too busy making sure there aren’t things that need to be sniffed or chased in the yard.

Duck, NC

I took a trip to Duck, NC last month. The trip was great! I thought i’d update here with some video and pictures! The group consisted of friends who all play Left 4 Dead together. We were all looking forward to an epic week!

On the first day we got there i was so exicted! So i made this video ๐Ÿ˜€ I was pretty out of breath at the end of it from running around the house, lol.

Day two was pretty much chilling at the beach, I made another video to rub it in everyone back home’s face ๐Ÿ˜› Chair made of sand, ocean waves, plenty of sun screen. All that was missing was the corona. You can also have fun on a whale watch from Newport Beach if that’s more convenient. Click whale watching dana point for more information.

The rest of the week was filled with beach, video and board games, and drinking all sorts of tasty beverages. We also did some touristy stuff, like checking out some of the local shops where we ended up doing some judo on a lawn of a restaurant, haha!

I threw Sean with Koshi Guruma!

We also went to see the Currituck Beach Lighthouse, that was really cool! The stair case seemed to go on forever! Higher and higher! But once you got to the top! What a view!

At the end of the week we went out Parasailing. I’d never gone before, and boy!, was it a fun experience! It was amazing how far you could see and how calm everything was up there.

Mary and I way up high

The week went by way too fast for me! I wish i could go on vacation all the time! I can’t wait to for Otakon to meet up with many of you guys again!

The whole group in Troll shirt attire ๐Ÿ˜€

I’d like to thank Tom and Mary for the pictures! You guys take some great shots!

The Wonderful World of Minecraft

I’ve been playing quite a lot of Minecraft lately, I even have my own server up and running. You’re welcome to join in on the fun! Just connect to krandor.dyndns.org. Our world isn’t very big right now, we’ve been mainly working on crafting stuff and playing with all the stuff you can make… and well, being on the quest to find lots of iron and diamond ๐Ÿ˜› But i do think we’ve made some pretty neat structures.

I love the sunrises ๐Ÿ™‚

Carnes has built a rock making machine, as well as a pretty sweet wheat garden, all on top of an elevated fortress surrounded by lava moats.

Our first tree fort

I’ve been mainly running around exploring the world and caverns. Those caverns can get dark, expansive, and SCARY!

Another project we’ve been working on is getting a rail system going, because walking across the world can take a long time!

I started this post quite a while ago, and since then have taken quite a big break from the game. But recently I’ve gotten back into it, and even have ย a few friends on the server regularly. There are also some mods installed on the server which allow us to specify certain areas as safe from monster spawns, set up our own shops to sell things, and even have a dynamically updated map that shows the live goings on of the server!

kinda had an accident with some flint and steel ๐Ÿ˜›

Carnes’ current project is to construct a quest for us to run at one point. He’s off somewhere on the map sculpting land and building stuff so we can all go and run the quest together! I can’t wait!

My house! ๐Ÿ˜€

If you want to check out what our world looks like, click here. This may not be the most up-to-date render, but it does have the most detail. If you’d like to check out our realtime map, check it out here!

Server Details:
For game connection — krandor.dyndns.org
For high quality map render — krandor.dyndns.org/mc/maps/map.html
For live dynamic map render — krandor.dyndns.org:8123

I loath creepers

Deploying to Multiple Locations in TFS 2010

This is just a forewarning, I am not an expert in the ways of TFS. I’ve only been working with TFS in general for about a year, and TFS 2010 for about 2 months or so. That being said, if anyone has recommendations on a better way to do this, please point me in the right direction ๐Ÿ™‚

Scenario:

We want to deploy our built code to different environments, but, we don’t want everything that’s dumped into the Release folder.

The Plan:

The plan is to create a custom build activity to copy files from one place to another checking each file against an exclusion list.

The Guts:

Referencing my previous post, Dependency Replication in TFS 2010, I will build upon the write-ups by Ewald Hofman.

You can grab the file here: DeployFiles.cs

Here’s the whole activity:

[csharp]
using System;
using System.Activities;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Build.Workflow.Activities;
using Microsoft.TeamFoundation.Build.Workflow.Tracking;

namespace BuildProcess.Activities
{
[BuildActivity(HostEnvironmentOption.Agent)]
public sealed class DeployFiles : CodeActivity
{
//Source dir being deployed from
[RequiredArgument]
public InArgument<string> SourceDir { get; set; }
//Destination dir being copied from
[RequiredArgument]
public InArgument<string[]> DestinationDir { get; set; }
//Files to exclude
[RequiredArgument]
public InArgument<string> FileExclusions { get; set; }
//Folders to exclude
[RequiredArgument]
public InArgument<string> FolderExclusions { get; set; }

//globals
public string fileExclusionPattern = "";
public string folderExclusionPattern = "";

protected override void Execute(CodeActivityContext context)
{
// Obtain the runtime value of the Text input argument
string fileExclusions = context.GetValue(this.FileExclusions);
string folderExclusions = context.GetValue(this.FolderExclusions);
string[] destinations = context.GetValue(this.DestinationDir);
DirectoryInfo sourceDir = new DirectoryInfo(context.GetValue(this.SourceDir));

//parse exclusions, add them to regex patterns
if (!String.IsNullOrWhiteSpace(fileExclusions))
{
string[] fileexarr = fileExclusions.Split(‘,’);
fileExclusionPattern = "(";
foreach (string s in fileexarr)
{
fileExclusionPattern += s.ToUpper().Trim().Replace(".", @"\.").Replace("*", @"[a-zA-Z0-9]*") + "|";
}

if(fileExclusionPattern.EndsWith("|"))
fileExclusionPattern = fileExclusionPattern.Substring(0, fileExclusionPattern.Length – 1);

fileExclusionPattern += ")";
}

if (!String.IsNullOrWhiteSpace(folderExclusions))
{
string[] folderexarr = folderExclusions.Split(‘,’);
folderExclusionPattern = "(";

foreach (string s in folderexarr)
{
folderExclusionPattern += s.ToUpper().Trim().Replace(".", @"\.").Replace("*", @"[a-zA-Z0-9]*") + "|";
}

if(folderExclusionPattern.EndsWith("|"))
folderExclusionPattern = folderExclusionPattern.Substring(0, folderExclusionPattern.Length – 1);

folderExclusionPattern += ")";
}

foreach (string dir in destinations)
{
DirectoryInfo destDir = new DirectoryInfo(dir);

context.Track(new BuildInformationRecord<BuildMessage>()
{
Value = new BuildMessage()
{
Importance = BuildMessageImportance.High,
Message = "Source: " + sourceDir.FullName + "\nDestination: " + destDir.FullName +
"\nFolder Exclusion Pattern: " + folderExclusionPattern +
"\nFile Exclusion Pattern: " + fileExclusionPattern,
},
});

CopyDir(sourceDir, destDir);
}
}

private void CopyDir(DirectoryInfo sourceDir, DirectoryInfo destDir)
{
//create destination dir if it doesn’t exist
if (!destDir.Exists)
{
destDir.Create();
}

// get all files from current dir
FileInfo[] files = sourceDir.GetFiles();

//copy ze files!!
foreach (FileInfo file in files)
{
if (!String.IsNullOrWhiteSpace(fileExclusionPattern))
{
if (!Regex.IsMatch(file.Name.ToUpper(), fileExclusionPattern))
{
if (File.Exists(Path.Combine(destDir.FullName, file.Name)))
{
File.Delete(Path.Combine(destDir.FullName, file.Name));
}
file.CopyTo(Path.Combine(destDir.FullName, file.Name));
}
}
else
{
if (File.Exists(Path.Combine(destDir.FullName, file.Name)))
{
File.Delete(Path.Combine(destDir.FullName, file.Name));
}
file.CopyTo(Path.Combine(destDir.FullName, file.Name),true);
}
}

// get subdirectories.
DirectoryInfo[] dirs = sourceDir.GetDirectories();

foreach (DirectoryInfo dir in dirs)
{
// Get destination directory.
string destinationDir = Path.Combine(destDir.FullName, dir.Name);

if (!String.IsNullOrWhiteSpace(folderExclusionPattern))
{
if (!Regex.IsMatch(dir.Name.ToUpper(), folderExclusionPattern))
{
// Call CopyDirectory() recursively.
CopyDir(dir, new DirectoryInfo(destinationDir));
}
}
else
{
// Call CopyDirectory() recursively.
CopyDir(dir, new DirectoryInfo(destinationDir));
}
}
}
}
}

[/csharp]

Explanation:

Now i’ll go section by section explaining exactly what’s going on. First up are the input requirements:

[csharp light=”true”]
//Source dir being deployed from
[RequiredArgument]
public InArgument<string> SourceDir { get; set; }
[/csharp]

The SourceDir is where the deployment starts from. This means what subdirectory from the BinariesDirectory gets deployed. This is important for Websites, since they get dropped in a _PublishedWebsites folder inside the BinariesDirectory.

[csharp light=”true”]
//Destination dir being copied from
[RequiredArgument]
public InArgument<string[]> DestinationDir { get; set; }
[/csharp]

The DestinationDir argument is a string array of paths being passed in (we use UNC network paths, ie: \\deploymentbox\websites\sitename)

[csharp light=”true”]
//Files to exclude
[RequiredArgument]
public InArgument<string> FileExclusions { get; set; }
[/csharp]

The FileExclusions argument is meant to be a comma delimited string of filenames and patterns you want to exclude. (ie: “web.config, *.pdb”)

[csharp light=”true”]
//Folders to exclude
[RequiredArgument]
public InArgument<string> FolderExclusions { get; set; }
[/csharp]

The FolderExclusions argument is similar to the FileExclusions, except that if there are certain folders you don’t want deployed, you can specify them here

[csharp light=”true”]
//globals
public string fileExclusionPattern = "";
public string folderExclusionPattern = "";
[/csharp]

These two variables will be used to build the Regex pattern which we will check files and folders against.

Now we’ll go into

[csharp light=”true”]protected override void Execute(CodeActivityContext context)[/csharp]

explaining each part in more detail.

[csharp light=”true”]
// Obtain the runtime value of the Text input argument
string fileExclusions = context.GetValue(this.FileExclusions);
string folderExclusions = context.GetValue(this.FolderExclusions);
string[] destinations = context.GetValue(this.DestinationDir);
DirectoryInfo sourceDir = new DirectoryInfo(context.GetValue(this.SourceDir));
[/csharp]

Here we get the values being passed in at execution time

[csharp light=”true”]
//parse exclusions, add them to regex patterns
if (!String.IsNullOrWhiteSpace(fileExclusions))
{
string[] fileexarr = fileExclusions.Split(‘,’);
fileExclusionPattern = "(";
foreach (string s in fileexarr)
{
fileExclusionPattern += s.ToUpper().Trim().Replace(".", @"\.").Replace("*", @"[a-zA-Z0-9]*") + "|";
}

if(fileExclusionPattern.EndsWith("|"))
fileExclusionPattern = fileExclusionPattern.Substring(0, fileExclusionPattern.Length – 1);

fileExclusionPattern += ")";
}

if (!String.IsNullOrWhiteSpace(folderExclusions))
{
string[] folderexarr = folderExclusions.Split(‘,’);
folderExclusionPattern = "(";

foreach (string s in folderexarr)
{
folderExclusionPattern += s.ToUpper().Trim().Replace(".", @"\.").Replace("*", @"[a-zA-Z0-9]*") + "|";
}

if(folderExclusionPattern.EndsWith("|"))
folderExclusionPattern = folderExclusionPattern.Substring(0, folderExclusionPattern.Length – 1);

folderExclusionPattern += ")";
}
[/csharp]

Here we check to see if anything was passed into the file or folder exclusion parameters. If something was passed in, we split the comma delimited string into an array and then iterate through it adding the exclusions to their appropriate Regex pattern.

[csharp light=”true”]
foreach (string dir in destinations)
{
DirectoryInfo destDir = new DirectoryInfo(dir);

context.Track(new BuildInformationRecord<BuildMessage>()
{
Value = new BuildMessage()
{
Importance = BuildMessageImportance.High,
Message = "Source: " + sourceDir.FullName + "\nDestination: " + destDir.FullName +
"\nFolder Exclusion Pattern: " + folderExclusionPattern +
"\nFile Exclusion Pattern: " + fileExclusionPattern,
},
});

CopyDir(sourceDir, destDir);
}
[/csharp]

Now we loop through all the destinations we need to deploy to, copying the files and folders.

Now lets take a look at

[csharp light=”true”]private void CopyDir(DirectoryInfo sourceDir, DirectoryInfo destDir)[/csharp]

[csharp light=”true”]
//create destination dir if it doesn’t exist
if (!destDir.Exists)
{
destDir.Create();
}
[/csharp]

Let’s make sure the destination directory exists, creating it if it doesn’t exist already.

[csharp light=”true”]
// get all files from current dir
FileInfo[] files = sourceDir.GetFiles();
[/csharp]

Here we get the all the files from the source directory

[csharp light=”true”]
//copy ze files!!
foreach (FileInfo file in files)
{
if (!String.IsNullOrWhiteSpace(fileExclusionPattern))
{
if (!Regex.IsMatch(file.Name.ToUpper(), fileExclusionPattern))
{
if (File.Exists(Path.Combine(destDir.FullName, file.Name)))
{
File.Delete(Path.Combine(destDir.FullName, file.Name));
}
file.CopyTo(Path.Combine(destDir.FullName, file.Name));
}
}
else
{
if (File.Exists(Path.Combine(destDir.FullName, file.Name)))
{
File.Delete(Path.Combine(destDir.FullName, file.Name));
}
file.CopyTo(Path.Combine(destDir.FullName, file.Name),true);
}
}
[/csharp]

Let’s copy some files! Check each file against the exclusion pattern, if one is set, and copy it if needed. If the file needs to be copied and it exists in the destination already, we’ll delete it and copy the file over.

[csharp light=”true”]
// get subdirectories.
DirectoryInfo[] dirs = sourceDir.GetDirectories();

foreach (DirectoryInfo dir in dirs)
{
// Get destination directory.
string destinationDir = Path.Combine(destDir.FullName, dir.Name);

if (!String.IsNullOrWhiteSpace(folderExclusionPattern))
{
if (!Regex.IsMatch(dir.Name.ToUpper(), folderExclusionPattern))
{
// Call CopyDirectory() recursively.
CopyDir(dir, new DirectoryInfo(destinationDir));
}
}
else
{
// Call CopyDirectory() recursively.
CopyDir(dir, new DirectoryInfo(destinationDir));
}
}
[/csharp]

Last we check to see if the directory has any sub-directories and we call CopyDir() recursively to copy all sub directories and files inside them, only of course if they aren’t on the folder exclusion list.

Dependency Replication in TFS 2010

I’m not sure exactly how many people do this, but it seems like there isn’t much documentation out there on how to do this exactly. So after lots of trial and error I’ve finally gotten dll replication to work for our TFS environment.

So, first i’ll go over the general overview of what needs to be done to enable TFS to replicate files during a build. Just a reminder, this is for TFS 2010, not any previous version of TFS.

1) You’ll need a custom build template
2) You’ll need a custom TFS Activity

Second, I’ll let you know i basically followed the tutorials by Ewald Hofman and then modified things to work the way I needed them to.

So our scenario is that we have multiple products that use dll’s from a core product. When that core product gets changed, we don’t want to have to copy the dll’s manually from the build location to the locations needed by the other products. Each one of our products have a folder called SharedBinaries, this is where those dll’s live.

Now the question is, how do we do this? If you’re using TFS 2008 or 2005, you can easily just acquire TFS Dependency Replicator, it will handle all that for you. For TFS 2010 however, this doesn’t work anymore. Or more precisely, I was unable to get it to work. So, time to learn how to use Windows Workflow. At first this seems very daunting, but after you take it a bit at a time, things start to make sense.

I would highly recommend you take a look at the tutorials i mentioned earlier, they will give you a good base to work from. And if i were to go through and document the whole process here, i would feel like i’m plagiarizing someone else’s work. Go at least as far as Part 4 – Creating your own activity, this is where i’ll start my documentation.

I created a new Code Activity and called it ‘ReplicateFiles.cs’. ย You can download it here.

You’ll want to add three Arguments to your custom template.


In the Metadata Argument, you’ll want to add those three Arguments as required fields.

In the custom template, I added the custom activity just before the gated check-in process.

Lastly, you’ll want to add the three Arguments into the appropriate fields on the custom activity properties, as well as specifying the BinariesDirectory as the SourceLocation to copy the files from.

While setting up your build, you’ll want to make sure you fill out those newly required fields in Build Editor Process Section.

Before you go wild and start running builds, go through this checklist.

  • Does your build controller know the path to the custom binaries you’ve made (for the custom build activity). ย (reference)
  • Have you checked in the latest version of your custom template, as well as the custom activity dll
  • The required arguments in the ReplicateFiles.cs are what you pass into the class from the custom template you’ve created, make sure those are filled out in the build template.
  • Make sure you have the correct path to your TFS server for tfsName in ReplicateFiles.cs.
  • Make sure that the user you run your build service under has file system permissions for the location where you want to create your temporary workspaces.
  • I had this issue, and it almost drove me nuts! I kept getting access denied errors when trying to overwrite the files in the target branches. Make sure that the files being replicated ARE NOT checked out and locked!

If you have any corrections, feedback, or ideas! Please comment and let me know!

A few weeks in the making

Over the last few weeks i’ve been collecting links i think are neat or interesting or adorable or funny. So some of these links aren’t even current events (in Internet terms, when yesterday’s news is already old news and no one cares anymore), but I’d still like to share them. I think here in the future i’ll be posting some more stuff with actual content. Things have been kinda blah lately. I think we might go shoosting this weekend, I’ll be sure to take pictures if we do.

Benoรฎt Mandelbrot Has Passed Away
Honestly I don’t know much about Mandelbrot sets or Fractal geometry, but i do recognize that Mandelbrot was a genius. Enough so that he even has songs written about him (Mandelbrot Set).

Angry NES’s version of Cee Lo’s “F*ck You”


I like this song.

MySQL Fanboy’s GIS Articles
Not everyone is into GIS, but i think it could have some really neat applications in mobile development.

Raytheon XOS2 — Pretty cool
I think before long we’re going to have real life bipedal weapons platforms. Gundams and Evas and Dragonauts! ๐Ÿ˜›

Perceived Wealth Distribution and Reality
I found this interesting. It seems that people think the income gap is a lot smaller than it actually is..

Americans don’t know much about religion
This i found amusing, mainly because I know so many people who think themselves quite religious, but then when you want to have actual discussion or debate about theological issues they can’t seem to defend their positions.

Arduino UNO FAQ on LadyAda.net
For those of you who use Arduinos and are interested in how the new UNO’s differ from the older series. Take a look here.