Clearing all bin and obj folders using SlightlyPosher and PowerShell

 

Sometimes an msbuild.exe /t:Clear doesn’t remove everything and it can be a little slow on larger solutions. Within the SlightlyPosher environment you’ll find a Module called VS.psm1, and this contains a handy little script when you need to do some house keeping.

function Clear-Assemblies($directory)
{
    Get-ChildItem $directory -include bin,obj -Recurse | foreach ($_) { 
        "Cleaning: " + $_.fullname
        remove-item $_.fullname -Force -Recurse 
    }
}

 

It’s pretty simply and to the point, just navigate to the root directory of the solution you want to clear down, and run this command.

Clear-Assemblies

It will recursively remove all bin and obj folders, and let you know what it deleted.

image

Great for when you need to copy source code without the added bulk of these folders or just purge any old bits for a clean build.

SlightlyPosher now supports 64bit PowerShell

 

When trying to write some scripts to automate IIS, I was getting some strange COM errors which were down to trying to run cmdlets targeted at a 64bit process.

It turns out Console2 as a 32bit process can only host a 32bit command prompt, which is unfortunate. Luckily Console2 does have a beta 64bit version, and I’m shipping this side by side with the 32bit version to satisfy everyone.

When you run update.bat you will find a new folder in your root.

image

Running [intptr]::size against the original shell yields:

image

And running it against the new shell:

image

I can now automate my 64bit IIS without errors. If everything is running fine you won’t need the new shell, but at least its there for the day you do need it.

Optimising Visual Studio Build Times

 

At my current workplace we have 203 projects in a single tanged web of a solution. This unfortunately means the majority of projects need to be built for any of the services or sites to function, thus breaking down the solution is not a viable solution at the moment. So I took a look at reducing those build times, and here are my results:

Rebuilding your solution

Running a rebuild in visual studio 2008 takes… 

7:42 minutes

*Sigh* Let’s try the same thing in the Visual Studio 2008 Command prompt:

Msbuild.exe mysolution.sln /t:rebuild

2:39 minutes

*Wow* Let’s add some tweaks, first up is the multicore build tweak.

Msbuild.exe mysolution.sln /t:rebuild /m

1:25 minutes

*Pretty cool* There’s a strange bug in the normal command line which slows down execution of running programs. So let’s use a filelogger instead of a console logger.

Msbuild.exe mysolution.sln /t:rebuild /m /noconsolelogger /fl

Try it out and see if you get a decent benefits!

Building your solution

Running a normal build inside Visual Studio takes:

3:10 minutes

And using the command line:

Msbuild.exe mysolution.sln /t:build

27 Seconds

Now with the multicore tweak:

Msbuild.exe mysolution.sln /t:build /m

12 Seconds

So all in all not a bad way to manage a solution with 203 projects in it!

Happy deving…

If you can’t change the people, change the culture…

 

There’s a number of these quotes flying around:

If you can’t change the people, change the people.

If you can’t change the people, change yourself.

None of these are satisfactory, if we change the people, I feel like I would have failed in my approach to improve existing peoples approach in the workplace.

If I change myself, then its simply lowering my expectations of what it means to do your job to the best of your ability, not a good approach in my eyes.

So, piece by piece, perhaps we can change the culture…

Getting the Balance right

Part of changing the culture is getting the balance between change and comfort right. There is already a predetermined way of doing things which your colleagues are used to, and changing this fast makes people uncomfortable. There are a number of psychological tools we can employ to begin change:

  1. Present the benefits of the change clearly.
  2. Approach them in such a manner that at the end of the discussion it feels like their idea.
  3. Show the negative impacts of not making the move to gain sympathy.

If one of the above has been successful, then the idea has been planted in someone who isn’t yourself, you are recruiting an army.

Finding like minded people

There is a good change that you are not the only person who wishes a particular process or behaviour could be improved. Raise support through email lists and water cooler conversations. You may even strike up a conversation with someone who can make your life in initiating the change much easier.

Be relentless

Blasé workers and procrastinators and two major blockers you might find in your quest to apply improvements in the work place. You could bypass them and try a manager if they are in the way, but it would be better for everyone to involve them in the process. There can be a few strategies here:

  1. Include them in the need for change, and allow them to take credit for applying it. After all the main reason its being done is to make your work life better.
  2. Take over any work they would otherwise have to do themselves, including responsibility so all they need to do is sign and the work is done.

Don’t make any enemies

This one should go without saying, but its inevitable that there will be a strong character in your way, and the best way to get your changes pushed through is to swallow your pride and befriend them. You would be surprised how often an unpleasant veneer dissipates after minutes of friendly conversation.

Little by little

Your encounters with people, bit by bit has hopefully improved the workplace and the culture. Before you know it, you’ve changed the people as a by product.

Most of all, good luck and don’t give up!

Newer Posts Older Posts