Jakew
Consulting, hacking, and motorcycles

Getting started with PowerShell

Thursday, 13 November 2008 09:22 by jakew

Over the past few weeks I’ve been using Powershell as my command line. I’ve got a long way to go, but the little bit that I have learned makes me pretty excited. Having a shell that works with .NET objects instead of processing text is pretty cool.

What is really useful in my opinion is the ability to access features of the .NET framework from with in a script. For instance, right now I’m working on setting up scripts to deploy my projects to their development servers so we can do integration testing. One of the projects (solutions) has a service that needs to be stopped while we copy the new files in and then restarted when we are done. You can do it with a batch file easily enough, and power shell can do it too:

Get-WmiObject -computername serverName Win32_Service -Filter "Name='serviceName'").StopService()

Stops the service and:

Get-WmiObject -computername serverName Win32_Service -Filter "Name='serviceName'").StartService()

Starts the service. Inside my script I can get the service’s state with this:

Get-WmiObject -computername serverName Win32_Service -Filter "Name='serviceName'").State

Currently, I don’t really check the services state. I just stop it, copy the files and then restart it. If I was smart I’d check the service’s state to make sure it restarts and send out an alert if it fails to start.

I’ve barely even scratched the surface of what powershell can do. Hopefully another few weeks of work will get me comfortable enough so that I can really go mad with automating stuff.

Also – not well publicized but there is a decent getting started guide included with PowerShell. Look in system32\windowspowershell. There are also a number of examples to look at.

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Learning

Thursday, 13 November 2008 08:40 by jakew

Over the past three or four months I’ve read a ton of material on Internet Marketing (IM). I’ve read so much of it I clearly see patterns of stuff where authors are repeating each other. Along the way I’ve also begun collecting a small network of friends who are helping me move toward my goal of starting a successful business.

Right now I’m working on writing an e-book about IT contracting and consulting for software developers. I know a lot about it so I thought it would be pretty easy to write a book about it. Turns out that writing a book isn’t as easy as it first appeared. I’ve made a lot of progress and can see the road ahead pretty clearly. The really cool part of writing a book though is that It has made me go out and research stuff I thought I already knew everything about. Things like interviewing, working with head hunters and other areas. In general I already knew a lot of the stuff other people had to say about the topic. But in most cases I usually found something new. The new stuff often comes from people talking about the same stuff but from a different view point. For instance, reading Joel Spolsky’s blog enteries about interview was interesting because he was writing from the view point of a hiring manager looking to hire a full time employees.

The other area though that I’m learning from is the advice and coaching I’ve received from my friends. One friend is already a successful business owner who has recently started building Internet based business (one of his projects is PigTones). Others have their own successes and reasons that I should carefully listen to them. One of the suggestions I’ve received is to get my book in to people’s hands as soon as possible, even before it is complete.

The idea is that the feedback I’d receive will make the end product better and make the product easier to sell. It will also help build buzz because those early beta testers will tell people about my product. These actions all fall in the category of strategic marketing (at least that is how I see it). I really should be doing this, unfortunately, I’m not yet.

I don’t really have a great reason for not going out and finding a few beta testers other than fear. Finding say 10 people who will read over my stuff as I write it wouldn’t be hard. Even qualifying that they have to be complete strangers – 10 people really shouldn’t be too hard to find. My fear is that I won’t finish. The number of half baked ideas that I started developing and then stopped is huge.

It could be argued that having those 10 people kicking my ass would be a great safeguard against not completing. So as a compromise I will go out and find some testers starting December 1st. I’ve been making really good progress recently and I don’t want to mess that up. The risk in taking this strategy is that the feedback I receive may require big revisions to a nearly complete project. That is actually OK in my opinion.

Part of the exciting thing about writing a book is that the raw material used for the book can be repurposed for a lot of different things. The feedback I receive will be used to create additional content and improve the quality of the existing content. Nothing gets destroyed, you just keep adding. Part of the bigger overall strategy will be to release the book in December even as I’m rewriting parts based on feedback. I’ll make updates and releases as I go along. People who purchase the book earlier will receive the updates for free for some period of time. But the goal will be to treat the book no different than software – keep working on it and making it better.

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Setting up CI

Wednesday, 12 November 2008 14:16 by jakew

Notes:

1. Need to know your way around msbuild

a. Property groups organize variables for your build.

b. ItemGroups organize files for you

c. Targets are where you scripts run

d. Use the MSBuild task to run the VS sln file

e. Get the msbuild community tasks package

2. Cleaning up is a pain – deleting files or removing directories via msbuild caused problems. Had to revert to using Exec and calling RMDIR to make sure things got deleted. Problem seemed to come from Tortoise. Deleting files in the svn directories caused errors.

3. ToolPath is important – I had trouble getting NUnit task to work. Added toolpath to point to the version of NUnit I’m using and then things worked fine.

4. Configuration of unit tests can be a pain because sometimes there is a fair amount of setup. While working in VS you don’t think about it because you have already gotten things work. When you move to an automated build in a separate environment you forget about all that setup work you did. In my case it was a separate configuration file that app settings referenced. I ended up having to run the project in the debugger and step in to see what the problem was. Seeing the problem was like “doh!”.

Usually I’m pretty good about making sure my projects have an automated build, but lately I’ve been pretty lazy. No excuses. I generally have found that projects are more successful when we have been disciplined about maintaining an automated build (doing continuous integration) . The investment in time has usually more than paid for itself.

In the past I pretty much hand rolled the build system using NANT and task scheduler. This go around I’m using MSBUILD and CruiseControl. A big bonus today is that there is a ton of good information and plenty of examples already available. Check these out:

What follows is my personal experience getting one of my projects set up and how I solved a few of the problems I encountered.

First, MSBuild is pretty easy and similar to nant with some nice extra features. The nicest feature of all is that Visual Studio will do 90% of the job for you. All CSProj files are already MSBuild files. Further, MsBuild will read VisualStudio’s sln files so the actual build step in your build just involves calling whatever VisualStudio provides you. You could do that with nant but you had to have VS installed on your build server (something I usually try to avoid).

Even with the VS provided project and solution files you’ll still want to do a little work in MSBuild to give yourself some control over the build process. For instance:

1. Cleanup from the last build

2. Create directories for the build

3. Get the latest code from your repository (SVN in my case)

4. Do the actual build

5. Run unit tests

6. Run FXCop

Visual studio gives you #4 and #7, the rest are up to you. In writing my script here are the problems I ran in to:

First, cleaning up my source code directory had problems. The Msbuild tasks all seemed to have problems. Deleting all the files caused errors when it went in to the svn directories inside the source code. My solution was to just use the Exec task and call RMDIR with the /s and /q parameters. That simply removed the directory trees specified and let me get on with the build.

The next issue was with the SVNCheckout task. Even though I use tortoise to talk to SVN for some reason my system didn’t have svn.exe where msbuild could find it. I ended up installing slik svn and using the ToolPath parameter to tell the msbuild SvnCheckout task where to find svn.exe.

The ToolPath parameter seems pretty important sense it looks like a lot of the MSBuild Contrib tasks have stuff hardcoded. Which also brings up a small complaint – when you install the msbuild contrib. tasks it doesn’t put anything in your start menu. Initially I couldn’t find any documentation because I assumed it would all be on the web-site. Nope. A friend clued me in and told me to look in the program files directory under MSBuild. There is a chm help file with some documentation. It is good enough, it answers some questions well enough to allow you to figure it out.

The next issue had to do with bit rot. I’m good about unit testing and one of my requirement for the build is to execute all of the unite tests. Only problem was that the unit tests needed some configuration files. These particular configuration files aren’t stored in SVN because they have passwords. What to do? I have encrypt/decrypt wrappers in my library so I did some quick coding to store the passwords as encrypted strings in the configuration file and then added them to the repository. The user is a test user with very limited rights, but being the paranoid type I don’t like the idea of leaving passwords around. Encrypted or not.

FxCop was the next problem. The fxcop task included in the contrib. packaged is hard coded to call an old version of fxcop. Gheysels’ weblog suggested just calling fxcop via the Exec command and that worked quite nicely.

At this point I have enough to begin moving my build script in to cruise control so and getting it configured to run every whenever somebody commits a change to the repository. However, I’m far from done. We’ll also want a build script that also deploys the finished product to the test server. I’d also like to add features like code coverage and other code analysis stuff so we can get more details about what we are doing.

Also, I really need to spend some time with FxCop because the way I’m running the policies now is insane. It complains about too much stuff. A lot of the things it complains about can be safely ignored. The only problem is that while you are busy ignoring the safe stuff you might also ignore the important stuff.

I still have a ton of work to do to get my build where I want it. Here is a list of things I’m going to add:

1. NCover – I want code coverage reports so I can see how well we are unit testing out code. I strong suspect an obvious inverse correlation between the number of bugs the get reported in test and production and how much code is actually tested by unit tests.

2. WIX – I want to generate MSIs for my projects so that we can have better control over deployment. Too many projects go to production expecting system admins to copy and configure things correctly. I’ve experienced enough all night deployments using the manual approach. Every time we switched to an automated process the deployment process magically became less painful.

3. Test and Staging build – All the build stuff to this point happens in development for development. I want to add additional builds that will handle taking the build results and putting them on to servers. This will require additional scripting and work but I think the effort will pay for itself in saved time. Just go to CC and force a test build and when you come back the test environment will be setup and ready with your latest and greatest code. Who wouldn’t like that?

Here is a list of sites I visited while ramping up on building my first scripts:

http://fgheysels.blogspot.com/2008/06/setting-up-continuous-integration.html

great two part article. The scripts he put together are simple and easy to understand. Not a lot of extra bells and whistles, but I see that as a feature not a bug. One annoyance is that his scripts are all jpegs so no copy paste action. I also couldn’t find a link so I could download a copy to look at.

http://weblogs.asp.net/omarzabir/archive/2008/10/06/asp-net-website-continuous-integration-deployment-using-cruisecontrol-net-subversion-msbuild-and-robocopy.aspx

Another great one. Little more thorough with more details. He also provides a copy of his script which is great because you can use it as the starting point for your own.

http://dotnet.org.za/cjlotz/archive/2007/04/04/part-1-continuous-integration-using-msbuild-cruisecontrol-net-fxcop-nunit-ncover-subversion.aspx

This has got to be the best one I found. It is actually too much but he covers everything you could want to do in an automated build system. He also does you a favor by offering the series of blog posts as a standalone PDF file and the actual build files he used

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Make your RSS link real obvious - please

Wednesday, 12 November 2008 12:27 by jakew

Followed a link from InstaPundit to the Speculist.  I've been over there a number of times in the past so I decided that I'd add their feed to my google reader.  Where is the link?  I'm looking around for that stupid Orange box or something telling me 'RSS here!'.  I knew it would be over on the margin.  Eventually I found it in small type in among all the other crap.  What a pain.

I know there is a lot of stuff going on about how Twitter is killing blogging - but seriously - RSS still rewls.  I rarely actually go to web-sites any more.  I read their stuff via the feed.

I don't mind ads placed in your RSS feed.  I do mind RSS feeds with partial posts though - SEO Book's RSS feed is only partial, guess whose blog doesnt get read by me?

Anyway - for such an important feature of blogging - it really ought to be made easy to find on your blog so people can subscribe.  Just make it a big orange square so they'll know where to click.

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Getting back up

Wednesday, 12 November 2008 08:27 by jakew

The cool part about being a software developer is that you’re a walking product, talking product factory. The crappy part of it is that you generally stay really focused on making products and rarely stick your head up to look at other parts of what makes a business run. At least that describes me.

I took my first shot and created a product. Got it far enough along to be ready to go find some customers for it and then discovered that I knew nothing about getting customers. Having my legs kicked out from under me I sort of just stopped. What I should have done is pressed on and tried some really stupid things that wouldn’t have worked, but if I kept trying stuff eventually I would have found something that worked well enough to get enough customers using my product to allow me to really focus on it and make it really great. Instead I just stopped.

Not completely, but effectively. What I did was decide to do what I do really well and go learn way more about sales, marketing, and promotions than I really needed to know. I’ve read a ton of internet marketing crap. I’ve read books like “Guerilla Marketing”. I’ve read books on strategic marketing (good, not immediately useful). Basically, I spend a ton of time reading and not actually doing.

During this time I also did a lot of introspection about what I really want. I can tell you all about the things I don’t want. As it happens I can also tell you fairly specifically what I do want. A lot of people can’t really tell you that. Sure, somewhere they’ll mention that they want to be wealthy, but they won’t really tell you what wealth will do for them. Buying a bunch of material crap is nice and all, but after a while it won’t really be satisfying. So I know what I want. I’ve written about it before and in general it hasn’t changed much. Perhaps it has gotten a little less selfish and includes more stuff not directly for myself. But I still want to visit and ride on most of the great race tracks of the world.

Anyway, I’ve read a ton of Internet Marketing stuff. Enough that I clearly see the patterns. Does the stuff work? Are sales pages effective? Yes. Will you make $10,000 a month selling self help DVDs on line? Maybe, but its more work than these courses let on.

But where I was going before I went off on a tangent on internet marketing is that somehow I came across Chris Guillebeau and his blog. I read his little book “A Brief Guide to World Domination”, it is good – read it. I also went ahead a bought his book “The Unconventional Guide to Working for Yourself”. Again, not bad but because I’ve read so much stuff around Internet Marketing I’ve already seen much of the material.

However, if you’ve not read a ton of IM stuff Chris’s book is a good deal. It covers everything you need know, and is pretty well written. Chris has a good voice. I might have to go back and write a review guide of all the IM stuff I’ve seen. For me the value in Chris’s book was the idea to create an e-book.

As I said when I started this post, being a software developer give you the tools to create products. In my case what I lack is the other business stuff to make a product a success. My goal now is to create an e-book and use it to learn how to market, promote and sell products. My expectations are pretty low. My big goal though is to sell 5000 copies of my book next year. I think that if I can achieve that I will have learned enough to try other products.

Categories:  
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed