The Johnson Blog

Ramblings of a geek with a few hobbies…

Tag: .Net

  • Vista and Visual Studio 2005

    I knew I was taking a slight risk installing Vista on my laptop, where I do quite a bit of my coding.  I’m having a big problem with the Chef solution in Vista – it compiles and runs just fine but in the Visual Studio IDE I cannot open the WinForm Designer for anything but the simple forms.  Scenarios I have that cause the designer to blow up:

    • System.Windows.Forms.Form derived form that references controls that reside in another, referenced assembly
    • UserControl that derives from another custom UserControl that resides in the same assembly, and which can be designed.

    I wonder how long this is going to take to get fixed.  I don’t see this issue on their “known issues” list, maybe I should dig around and find out how to submit it.

  • Strong Naming

    As a continuation of my last post, I thought some of you .net developers may be interested in hearing about some of the issues I ran into when strong naming.

    Admittedly, this is my first real attempt at using strong naming as it’s intended and therefore I just wasn’t aware of a few things when I was writing the code for Chef. Two days ago I created myself a strong name key (sn -k keyfile.snk) to sign my assemblies with. Due to the obfuscation step I need to do between compile and packaging, I need to delay sign the assemblies.

    In an exercise in curiosity I decided to sign the assemblies with the public key half of my keypair and keep the private key “secret”. Which really means just not kept inline with the sourcecode, but rather living in a key container in the machine store on the build box. This process was mostly problem-free, I used the sn.exe utility to: create a keypair; import the keypair into a key container; extract a public key from the key container; tell .NET to allow me to run partially signed assemblies with that public key token (sn -Vr *,) for debugging purposes. It all went well until I went into visual studio and told it to use the public key for signing – it kept telling me that it was password protected and prompting me for the password. I never put a password on it.

    So to get around that, I did the first step (creating the keypair) from Visual Studio and gave it a password, then it all worked just fine.

    One feature in Chef is the ability to create bookmarks. In my ignorance, I was simply using the BinaryFormatter in .NET and serializing to disk an array of these things for loading later. Little did I realize that all of the version information for the objects is written out – and if the objects live in a strong named assembly and the assembly version changes, it cannot deserialize! There’s supposed to be a way you can get around this, by setting AssemblyFormat on the formatter to Simple but it continued to write the version information. I also tried the route of using a custom Binder during deserialization and that didn’t work either.

    As a result, last night I rewrote that code to serialize/deserialize the information myself with XmlWriter and XPathDocument rather than rely on .NET. Version issues gone. That’ll definitely be something I’m not likely to forget anytime soon. I need to rewrite one other small area this weekend for a similar problem, then I can move on. All that’s standing between me and Beta 2 is some thorough testing, a website update, and a file upload. Should all happen this weekend.

  • Automated Builds

    Several hours today were spent advancing my automated build process for Chef. I’ve had CruiseControl.NET building the software for months now but I’ve had a gaping hole in the processes that has been staring at me since I started it.
    What is this hole you ask? Version numbering.

    Why is versioning so hard in this day and age? Seriously. With .NET there are all these really nice and easy attributes that all you have to do is type in the version string you want your assembly/binaries to have. That works really well, until you want those numbers to be dynamic – then it requires modifying a sourcecode file with a new hard coded string. But what about 1.0.*? you ask, referring to the ability to have the compiler generate parts of it for you. Well, what real good is it to have version numbers that you don’t control? If they get generated by the compiler it just makes everything difficult – like translating between a version label from CruiseControl to the state of source control at the time of the build. Maybe I’m missing something here, but I don’t think I am.

    Another versioning issue is setup projects. The setup projects created in Visual Studio have a version number, product code, and upgrade code. Counter to intuition, the upgrade code is the same across versions for a given product and it’s the product code that changes between versions. Sooo, if you bump the version number you also need to create a new Product Code guid. Again, there’s no way (that I know of) to do this via command-line. Microsoft thinks you should open the setup project and bump the version number manually. They even go as far as prompting you to create the new Product Code guid when you do this. Microsoft, the creator of the great tool that is Visual Studio, make it very hard to do the Right Thing and have automated builds. Tisk, tisk.
    And finally, the version string has implications on product keys – both generation and verification. For instance, if Suzie buys Chef 1.2, I need to have a way to have that license key work for 1.2.5, 1.4, and 1.9; but not 2.1. And I need to be able to forget about the details rather than think about it every single time I create a release. (Chef Beta 2 is days away, by the way).

    My solution to these problems required a little planning, a little coding, and a lot of time waiting for test builds to be created. My process is as follows.

    • I go to the CruiseControl.NET Dashboard website and click Force to initiate the build.
    • The last successful build label is incremented (from 0.9.2.2 to 0.9.2.3, for instance).
    • The latest sourcecode is retrieved from the Perforce depot
    • The code I wrote tonight gets executed on the sourcecode tree, passing in the newly incremented build number
    • A new product code guid is generated
    • Every AssemblyInfo.cs file is edited and all AssemblyVersion attributes are changed to use the new version number
    • The specified .vdproj files (Visual Studio setup projects) are edited to modify the ProductVersion with a trimmed version of the current build version/label. The new ProductCode is also inserted
    • Visual Studio is called upon to perform the compile.
    • CruiseControl puts the generated installation packages out on the network
    • A sourcecontrol Label is created in the Perforce depot, denoting the state of the sourcecode at the time of the build.

    And that’s it. With a single click I have installation packages created with no further involvement. The files included in the package all have a version number that I can trace back to a CruiseControl label (to view build logs and in the future unit test results) and then back to a Perforce label with the same name to view the sourcecode files at were a part of the build. I’ll then also be able to compare those file versions with the recorded version numbers of bug fixes in FogBugz – something that will surely save time once Chef is in the wild.

    Microsoft, please please please make this better in the future.

  • Chef Beta 1!

    Well it’s a week and two days later than desired, but it’s finally here.  The first beta of the new Chef!  For those of you that are going to be trying it out and providing your feedback, thank you very much – I really appreciate it.

    Details available at www.ejichef.com.

  • Build System

    Last night I put together a simple build system and got some of the application versioning in place for the future.  I’m running CruiseControl.NET for the builds but haven’t set it up for continuous integration since I’m the only one coding.  I’m also not running any build tasks other than a straight compile, although once I get some time that may change to include running my NUnit test cases.

    All-in-all, I didn’t spend a lot of time on Chef this weekend, but I got a few very important things done.

    In the very near future I need to really examine my source control system. I am using, and have been using, CVS at home for several years.  But I haven’t really used it for more than a simple version controlled file repository – few branches, few labels, etc.   At work I’m very comfortable with our source control system, but I’m just not with CVS.  On my list of possible replacements are SubVersion and SourceGear Vault.  All said, I’m still quite nervous about changing systems.

  • Registration Keys

    Over the weekend I finally spent some time to tackle the problem of registration keys.  Particularly, generating them.  The last piece of software I attempted this was WakeUp! Alarm Clock, with a very cheesy, homegrown routine for creating a key tied to the user’s name.  I never ran across any cracks/keygens for WakeUp! but I’m 99.999% sure that that’s because I charged a meager $5 for it.

    With Chef, however, I’m planning on a steeper price tag and don’t want to make the mistake of using an easily cracked scheme.  So, I turned my attention to the cryptographic services provided by .NET and now have a simple and, what should be, effective solution using public key cryptography.

    I haven’t integrated it into the application yet, but that shouldn’t take too long.  Once the code is in place, I’ll start strong naming the assemblies and even obfuscate them.  The obfuscation will prevent the casual snooper from using a tool such as Reflector to simply copy code and recompile it into a working replica of Chef.  The strong naming will then ensure that someone cannot release a cracked version of my assemblies with the registration limitations removed.  Pretty cool I think.

    Today I spent some time reviewing several payment processing options.  Currently, RegNow is the leading candidate.

  • Beta by Thanksgiving?

    A while back I tossed around the notion of having a beta of Chef available for testing by Thanksgiving.  So far I’m doing quite well with this goal.  Now that the setup situation has been resolved, I can work on a few other issues that have to be done before I add the few final features that will be in the 1.0 product.  It may not be too far-fetched to see the first beta available in the coming weeks, so if you’d like to give it a try I would be very appreciative.  Just shoot me an email or comment here.

  • Chef, Sql Express, and Installers

    Over the past week or so I have been reviewing the landscape of Installers that I can use to get Chef installed on people’s machines. The landscape has changed quite a bit since the last time I looked, with a lot more small install authoring tools available. Before, it was just InstallShield or Wise Installer – now there’s NSIS, InnoSetup (I know, not new..), AdvancedInstaller, and several other viable tools.

    And after carefully reviewing many of them, I’ve run into road blocks with my setup needs that can’t be fulfilled without spending upwords of $500. So I now have a setup using Visual Studio 2005’s deployment projects. It’s not quite what I wanted when I first started down the road but it’s not too bad either. In fact, I may actually end up liking this method a bit more. Read on for details.

    (more…)

  • Visual Studio Addin

    At work yesterday I created my first Visual Studio Addin.  Now that I know how to do it, I’m going to create one for something I’ve always wanted: launch windows explorer on a folder in the solution explorer.  There apparently used to be a powertoy for this feature, but that was for VS2003.

  • Icon update

    As I watched the Cardinals beat the Tigers tonight I sat and redid most of the toolbar icons for Chef. Every now and then it’s nice to take a break from coding, and for those times there is plenty of graphics and documentation work to be done. Here’s what the current toolbar looks like.

    New Toolbar Icons.png

    What do you think?