Author Archive

Using IDataErrorInfo for Validation

I read an article on CodeProject titled Total View Validation where the author complains that IDataErrorInfo is inadequate for WPF validation.  The assumption he makes is that all the validation code needs to go into the IDataErrorInfo.this[string] property as such:

publicstringthis[string name]
{
   get
    {
        string result = null;
        if (name == "Age")
        {
            if (this.age < 0 || this.age > 150)
            {
                result = "Age must not be less than 0 or greater than 150.";
            }
        }
        return result;
    }
}


This should not be the way that IDataErrorInfo is used as it puts business logic in the model, as the author points out.  His solution though was to create another mechanism to notifiy the user of validation errors and to not use IDataErrorInfo at all.

A solution I would propose though would be to follow how DataTables and DataTables use IDataErrorInfo by implementing methods to set and clear the objects error information:

public SomeClass() : IDataErrorInfo
    {
 
        publicstring Name { get; set; }
 
        publicstring Age { get; set; }
 
        #region Data Error Info
 
        private Dictionary<string, string> _propertyErrors;
 
        privatevoid InitDataErrorInfo()
        {
            var properties = this.GetType().GetProperties();
 
            _propertyErrors = new Dictionary<string, string>();
 
            // This will act as an overall error message for the entire object.
            _propertyErrors.Add(this.GetHashCode().ToString(), string.Empty);
 
            foreach (var propertyInfo in properties)
            {
                _propertyErrors.Add(propertyInfo.Name, string.Empty);
            }
        }
 
        publicvoid ClearDataErrorInfo()
        {
            foreach (var property in _propertyErrors.Keys)
            {
                _propertyErrors[property] = string.Empty;
            }
        }
 
        publicvoid ClearDataErrorInfo(string propertyName)
        {
            AssertThisHasPropertyWithName(propertyName);
            _propertyErrors[propertyName] = string.Empty;
        }
 
        publicvoid SetError(string error)
        {
            SetError(this.GetHashCode().ToString(), error);
        }
 
        publicvoid SetError(string propertyName, string error)
        {
            AssertThisHasPropertyWithName(propertyName);
            _propertyErrors[propertyName] = string.Format("{0}{1}{2}", _propertyErrors[propertyName]
                , Environment.NewLine,  error);
        }
 
        publicstringthis[string propertyName]
        {
            get
            {
                AssertThisHasPropertyWithName(propertyName);
                return _propertyErrors[propertyName];
            }
        }
 
        publicstring Error
        {
            get
            {
                var errors = new StringBuilder();
                foreach (var propertyError in _propertyErrors)
                {
                    if (string.IsNullOrEmpty(propertyError.Value)) continue;
 
                    errors.AppendLine(propertyError.Value);
                }
 
                return errors.ToString().Trim();
            }
        }
 
        protectedvoid AssertThisHasPropertyWithName(string propertyName)
        {
            if (!_propertyErrors.ContainsKey(propertyName))
            {
                thrownewArgumentException(string.Format("No property named {0} on {1}."
                    , propertyName, this.GetType().FullName));
            }
        }
 
        #endregion
    }



Note that there is no validation here, only reporting if the object has errors.  Using this takes advantage of the already existing validation notification built into WPF as well as WinForms.

No Comments


Y2K38

Eight seconds past 3:14 a.m., on January 19, 2038, most computers in the world will think it’s actually a quarter to 9 p.m. on December 13, 1901.

Oh Crap.

No Comments


Changing Typed DataSet Connection String

I was working on a WinForm app that connected to a MS Access database. Yeah, Access sucks but I didn’t have a choice in the matter.

The app itself is used to import a bunch of CSV files into the Access database. It is more of a utility program and it has going through several variations, from being a simple hand driven command line tool to being GUI driven.

The command line version was all hand controlled. I had to go in and update configuration files to point to the CSV files and the MDB database. That got old fast so I decided to make a GUI version that would allow me to pick the MDB file and each of the CSV files to import. Picking and using the CSV files was easy, it was changing the connection string for the MDB that proved to be the hardest.

I am using strongly typed datasets in VS2005. If you have ever worked with them you find out soon that the connection string gets saved with the project in the app.config file, even if it is a seperate DAL dll project. My guess is that Microsoft assumed that if you ever had a connection to one database then your strongly typed dataset would not have to change to another database, but if you did you could always just update the configuration file.

As my drill instructor was always fond of saying: “Wrong f***ing answer!”

I wanted, in the case, to use a strongly typed dataset. I also wanted to use different Access files, and I wanted to be able to select which Access file I used while the application was running. Why is that so hard?

I searched the web and found several not so useful suggestions. It appears that there are two camps of people for this issue: Those that understood what I wanted to do and were trying to do it also, and those that didn’t understand what the problem was.

Those in the latter camp always resorted to the same suggestion: Just update the configuration files to point to the new database. This doesn’t work in this case because I would then have to restart the app in order for the new setting to be picked up.

The other popular option was to completely re-write the Settings.Designer.cs file so that when the DataTables called to get the connection string it would call a method you created so you could pass anything into it you wanted. The problem with this approach is that if you changed any of the other settings then your code would get over-written by Visual Studio.

The least popular option was to go to each DataTable and create partial classes that override the InitConnection() method. This royally sucks if you have lots of DataTables.

In the Settings class, all Connection String types are application level and cannot be made into User Settings. This leads to the other issue, namely all Connection String settings are read-only. But this is true only for saving the connection string, which is not something I needed to do. I just need to be able to change it.

Also the Settings class is internal and sealed, which means it cannot be accessed from outside of the current project. So my GUI project cannot directly access my DAL project and update the Settings value. To get around that limitation I just created a proxy class. The resulting class is:

    1 using DC.Catalog.DAL.Properties;
    2 
    3 namespace DC.Catalog.DAL
    4 {
    5     public static classEquipmentConnectionSettings
    6     {
    7         public static void SetEquipmentToConnectToMdb(string MdbFilename)
    8         {
    9             // This only overrides the in-memory copy of the setting.  It is not perminate.
   10             Settings.Default["EquipmentConnectionString"] = string.Format(
   11                 Settings.Default.EquipmentConnectionStringTemplate
   12                 , MdbFilename);
   13         }
   14     }
   15 }

Notice that to update the setting value I had to use:

Settings.Default["EquipmentConnectionString"]

Since the setting Settings.Default.EquipmentConnectionString is readonly I had to use the other way to access the value. The EquipmentConnectionStringTemplate is simple:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}


Every time I change the Access file I am pointing at I call the SetEquipmentToConnectToMdb() method, magic happens in the Typed DataSet and it all just works.

5 Comments


DataSets – Love em Hate em

I have a love-hate relationship with DataSets.  On the one hand they are easy to use and contain lots of built in functionality.  On the other hand they are abused by almost everyone but at the same time severely under utilized, meaning that I rarely see anyone use most of the features available.

I get the feeling that the majority of developers that use DataSets have blinders on:  DataSets are only useful for reading and writing data to the database.  End of story.  If you are an ASP.NET developer you absolutely refuse to use them and use DataReaders only.  And in the last three years I have not seen too many applications that use the typed DataSets that can be created in Visual Studio 2005.

I don’t like using DataSets because I prefer to use NHibernate or ActiveRecord to interact with databases.  But lately I have been having a change of heart as I have been delving more and more into using DataSets in the application I am currently working on.  There is a lot of functionality baked into DataSets that I have been overlooking and since I have been working with the strongly typed DataSets generated by VS 2005 I have to ask myself why I need to recreate it with POCO’s.

The way I am looking at DataSets now is not as an in-memory relational database but as a highly versatile data structure that handles a lot of things I need it to handle:  Relationships, constraints, databinding, serializable and data error information.  Sometimes I see it as being nothing more than a collection of Hashtables, each Hashtable being another collection of Hashtables.  And the fact that there is a designer to work with it makes it better.

I worked on a home grown messaging system project, the message object orginated as an XSD that got converted to C# classes using the xsd.exe tool.  The tool didn’t work to well (this was in .NET 1.1) so all the names and name spaces were so screwed that most of the classes had the name space in the class name.  Intellisense really sucked at times.  Me being who I am I started trying to figure out a simpler message object when it donned on me that a DataSet would have been a perfect fit for what they were doing.  A .NET 1.1 DataSet serialized to XML was ugly but in 2.0 it got a much needed face lift.   You should have seen them laugh at me when I suggested switching the message object out.  “You dummy, DataSets are for Databases!!  Ha Ha Ha, we’re writing SOAP messages!” 

Yeah, I left that place.

When it comes to data binding DataSets can’t be beat.  WinForms have been especially built for binding to DataSets.  One thing I wished that would be easy to do is to bind one DataSet to another without using  form.  Currently I have a form that has two user controls, each with its own DataSet that require data in one form to update data in the other.  I am working on a way to databind the two DataSets together, currently the form is manually updating the data in the other DataSet as it changes.  I want to pull all the code out of the forms and create a Database Synch Service.

A lot of the data validation I have seen in OPA’s (other peoples apps) has been in the form.  Typcially if an error occurs a nice little pop-up shows some nasty message then either won’t let the user save the data or reverts it back to a previous value.  DataSets have a way to set a Row and Column with a specific error message which can be used by the form to indicate there is an error.

As for the actual validation, I want to create a dictionary of methods  to validate the DataTables and DataColumns.  The validators would take the row, column and DataSet being validated and the validation errors will be entered using the rows SetColumnError method.

Still though, DataSets are going to become mute when Linq comes out.  Maybe.

No Comments


Value Objects as Measurement Objects

So I was reviewing PEAA looking to see if Fowler had come up with the idea of Measurment Objects, that horse I’ve been kicking around lately.  I found that he has a couple of close patterns:  Value Object and Money.

Value Object:  A small simple object, like money or a date range, whose equality isn’t based on identity.

Money: Represents a monetary value.

According to Fowler Value Objects are light weight and almost primative types.  They should also me immutable since they have no identity.  He also suggests that in .NET structs could be used as Value Objects.

The money pattern looks like a special case of a Measurement Object with the UnitOfMeasure being set to currency (currency being USD or Euro).

I see the usefulness of using structs but there is the boxing issue if we implement them with interfaces.

I will have to ponder on this.

No Comments


Measurement Objects

In my previous post I described setting up a database to track measurements.  I ran into problems quickly with the data model and I could see that it was going to become a convoluted mess pretty quick.  So I want to take a step back and look at it from an application point of view.

What I want is a way to track an objects measurements.  I need a system that is easy to understand, any one looking at an object should readily understand what each measurement property is and what units it is in.  The system should accommodate almost any existing system of measurement but at the same time it needs to be simple.  Brain dead simple.

Measurement Object Diagram
What I am thinking is to start out with a abstract base class for our Measurement Object.  It has an ID that can be an int, string or Guid, take your pick.  The Text property is the string representation of the Value, Value being in an abstract class that extends MeasurementBase.

I think that it is important to seperate the actual Value into another class of Type T.  This allows us to create collections of MeasurementBase objects and add MeasurementBase<T> objects to it.  I am still struggling with this idea as it totally blows apart expectations on what a Value is (is it an int?  a DateTime?), but this is the reason I stuck the Text property on the MeasrumentBase.  The Text property takes care of the conversion of the string representation to the actual Value.

Already this is getting complicated.  What is it I’m trying to do here?

My ultimate goal is to have the means to convert a measurment from one system to another.  The objects themselves should take care of the conversion.  The way I have seen it in the past is to have conversion code scattered throughout the entire application layer, including the UI and the data access layer.

This is one of those ideas that is on the tip of my neurons, I know it has been solved before but I haven’t found it.  And every time I start working on it I naturally want to drop into the Database thinking frame of mind.

I need to review some of the Enterprise Patterns, see if it already exits.

No Comments


Databases Suck

I am sick of working with databases, they all suck.  I can generalize this to any type of data store, they all suck.

OK, they don’t really suck but I sure have seen a lot of database designs that do.  I am tired of working with applications that have lots and lots of large tables, tables with lots and lots of fields.  Of course all the fields but the primary key are nullable because you might not always need that extra address field but it is there, just in case.

And don’t get me started on compound primary keys.  If I see tables with compound primary keys then I am trying to get off of that project.

What if we have to change the database, add a field, remove a field or just plain rename a field?  Well that just broke the application, not just the code you own but the code in a module you never heard of that the reporting team is using.  Why can we not update schema’s without worrying about causing the build to fail?

And what about all the boiler plate code needed to communicate with your database?  We have to invest in code generators that get it about 80% right.  Then the databinding to the forms, after all a database does no good unless you can get data into it.

So how do we solve this problem?  Get ride of the database?  Use only CSV files?  Go back to pencils and paper?  Those are options but not necessarily good ones.  We have the technology so why not use it, only use it in a different way.

What are we trying to do with the database any way?  Store values so we can retrieve them later.

What about history?  How do we know when someone changed a value?  And what was the value before?

What is a value?  If we don’t know what it is we are storing then how are we going to know how to store it?

Based on the majority of the applications I have worked on values tend to be descriptions or measurements.  Descriptions are remarks, model numbers, serial numbers or some other form of text that has meaning to the object.  Measurements are attributes of an object that magnitude relative to some unit of measurement system.  Wikipeda has a better description of it than I do so check it out then come back.

Note that this is not a new idea, I read about measurement values somewhere but I can’t for the life of me find who actually came up with it orginally.  And if you really want to get technical about measurement values there are scalers (magnitude only) and vectors (magnitude and direction).

So how do we handle this in databases?  First we create a measurement table like such:

Measurement Table
This table is pretty basic:  You have your primary key Id, the magnitude of the measurement is the value and the system used is determined by the UnitOfMeasurement.  The CreatedBy and CreatedOn is for audit and historical purposes.  To maintain a history in the database we will not allow deletes from this table, only inserts.  This allows us to see all the changes made to this value when they were made and by who.  The value that was added last is the current value.

Now that we have the measurement what exactly are we measuring?  We need some properties of some kind.  So we need a Property table and a link to the Measurement table.

Property Measurement

We have the Id again which becomes the foreign key in the Measurement table.  The name is what the property is called and the TypeOfMeasurement is the attribute being measure.  This could be length, mass, weight, currency, velocity, acceleration, etc.  Note that it is the UnitOfMeasurement in the Measurement table that dictates if we use feet, meters, kilograms, pounds, US Dollars, Euros, meters per second, etc.

What do these properties apply to though?  We need an object that has properties:

Object Properties

Now this is just getting crazy.  Our object can have many properties but also our properties can belong to many objects.  We will have to work that little kink out but for now I think I will stop playing with pictures.

What is it I really am trying to do?  I want to reduce the pain of making changes to the database for an application.  What does that mean?

Let us say for example we create an app that needs to track squares.  Nothing fancy, just a square.  Our first instinct is to create a table such as:
Square

After building many forms and reports off of our square table management comes along and says we need to track cubes!  Those eF’ers!  You have to go back, change the name of the table, wait, no just leave the name the same, I’ll remember what it really should be.  Add the new column Height, modify all the data access code, forms and reports to use the new value and life goes on.

Till six months later when management comes back and says that some federal requirements mandate that all changes to the cubes be tracked for three years.  So you look for your cube table which doesn’t exist.  There is this square table with all the right fields, but squares don’t have height, they are flat!  Screw it just add a history table, copy the rows as they are changed, create some triggers, job done.

Except management finds out that Canada has been entering values in metric but in the states it is in feet.  Plus Canada has been updating some of the US’es cubes.  Now is the time to get the resume ready.

Databases suck.  Working with databases is a pain but it really shouldn’t be.  This extends beyond databases, it applies to objects as well.  How to stop the pain?  Stop adding values directly to the table.  Granted this is not a 100% solution, I mean really if I had a square object I wouldn’t worry a lot about keeping track of two fields.

But if I had some complicated object that had many properties, and I was still in the development cycle where all of the properties still had not been identified, I think I would take the Measurement table approach.

Technorati Tags    

No Comments


Blogging from Zoho

So I decided to give Zoho a spin to see if it is better than Google Docs. So far it seems pretty impressive, more document like. Google Docs feels like I have little or no control over the final document.

But the one thing that suprised me: I can post my document to my blog! Man that just made my whole life eaiser! I was wanting something to use for TechShorts but did not really like using the available Blogger editor. I could use BlogJet or Live Writer but I want to be able to blog from my eee PC, which is Linux based.

Zoho to the rescue.

No Comments


Get this party started

Do you want this party started Right?
Or do you want this party started Quickly!?

Where to begin? How about trying to figure out what this blog is for, that is always a good thing to start with.

It is about Technical stuff. Short technical stuff. I want a place that I can brain dump techie ideas and brain storms. I have other blogs where I tried to do this but this time it is different, I have a mission.

Not a big mission just a small one. I want to write about the one off coding things I’m working on. About the ideas I have had. Review patterns and processes.

But mainly I just want to write. I’ll keep the personal items out and in my personal blog so no mushie stuff.

For now that is all. Come back often.

No Comments


Need Tape


Those are the words spoken to me by my son. He was playing with his GI Joe (one of the fake all plastic ones) when he accidentally pulled off its head. Oops!

This sucks because now I have to retape the head on evy time it falls off.

Of course the real GI Joe’s head wouldn’t have come off so easy. Growing up we used to regularly abuse them by dropping them off of roofs, blowing them up with fire works, running them over with the car, etc. and they always survived. These cheap plastic ripe offs, well they just suck.

No Comments


Moving back…

After much thought I am moving back to blogger. I think it is easier than trying to maintain my own blog site.

We shall see. The real push though will be with the TechShorts. That is what I want to really take off.

No Comments


ExcelPackage

I've been reviewing the ExcelPackage project on CodePlex. It is a useful project but one thing I was wondering is why does it directly interact with the XML?

I think it is a performance and a code maintenance hit to work directly with the XML for the workbook and worksheets. In my oh so humble opinion I think it would be easier to create plain old C# objects to work with the cells, rows, sheets, etc. and then serialize and de-serialize as needed. I say this because in the XML for a worksheet the cells are stored in XML nodes that have the row number and individual cell addresses in them:

XML:
  1. <sheetdata>
  2. <row r="1" spans="2:13" ht="12" customHeight="1"/>
  3. <row r="2" spans="2:13" ht="17.25" hidden="1" customHeight="1">
  4. <c r="B2" s="3"/>
  5. <c r="C2" s="3"/>
  6. <c r="D2" s="13"/>
  7. <c r="E2" s="13"/>
  8. <c r="F2" s="13"/>
  9. <c r="G2" s="13"/>
  10. <c r="H2" s="13"/>
  11. <c r="I2" s="13"/>
  12. <c r="J2" s="13"/>
  13. <c r="K2" s="13"/>
  14. <c r="L2" s="13"/>
  15. <c r="M2" s="13"/>
  16. </row>
  17. </sheetdata>

So if we work directly with the XML what has to happen when we insert a row? We have to loop through all of the XML nodes and update the row values. Note that I am not even talking about how to deal with merge cells or ranges (which the ExcelPackage does not work with).

I think that creating a Attribute-value system would be a better approach. Rows and Columns could be a linked list, Cells could be in an indexed cache or hashtable. And the collections and individual objects would handle where they were in the domain of the spreadsheet.

Guess I should get busy and prove my point.

No Comments


Crappy Apps

Why is it that so many crappy apps are out there in the wild?

Is it because of the visual tools available in the .Net realm that generate so much crap that the average programmer just does not have time to clean it up? Or are the developers just too lazy to clean up the mess as they go?

No Comments


EntLib Data Access Block and Excel

I need to be able to open an Excel workbook and grab the data from one of the worksheets. I don't want to use any Office InterOperability (as that sucks) and I know I can do it using ADO.Net. But since 1.) I hate writing all of that DataAdapter / Connection code because 2.) I am lazy I decided to see how hard it would be to use the EntLib DAB.

Turned out it was pretty easy.

Create your configuration as such:

Then call your code as such:

C#:
  1. public static DataSet GetWorksheet()
  2. {
  3. string sql = "SELECT * FROM [Sheet1$]";
  4. string connectionName = "Book1";
  5.  
  6. return DatabaseFactory.CreateDatabase(connectionName)
  7. .ExecuteDataSet(CommandType.Text, sql);
  8. }

And that is that. One DataSet ready to go.

No Comments


Nerd Test: Cool High Nerd

NerdTests.com says I'm a Cool High Nerd.  What are you?  Click here!

No Comments


CueCat vs the USB Keyboard

Ages ago I picked up one of the RadioShacks CueCats but I never used it.  Up until today it sat in a box of computer junk having survived several purges.  You know Purges:  You have so much junk you have to get ride of the old.

I never got ride of the CueCat because barcode scanners are not cheap, which I do not understand.

Any way, I came across Scott Hanselman's article on a .Net app for the CueCat, Coding4Fun Hardware Boneyard - Using the CueCat with .NET, and decided to break out the old dusty cat and give it a spin.

The code was no problem, getting my machine to read the CueCat was.  See, I have a Logitech wireless keyborard and mouse so Windows XPdid not load the PS/2 drivers.  I wound up having to dig up an old PS/2 keyboard (from the same junk box, you should always have PS/2 keyboard and mouse handy!) plugged it in, rebooted and vola, it worked.

Now I am off to inventory my CD collection.  And my books.  Maybe the comic books.  If I do the pantry my wife my smack me.... 

No Comments


Chevy Vega vs. TestDriven.Net

My Dad originally made a living as an auto machinic and working on cars is still his favorite pass time. Besides working on cars my Dad liked to swap cars. Swap cars, car parts, you name it he would swap it. The benefit of that to me was that I was exposed (read - drove) to a lot of different cars, some clunkers some not.

One of the cars he swapped for was a Chevy Vega with a 327 small block V8 in it. That little car was freaking FAST and I am surprised that he actually let me drive it at all. I recall that I broke at least three speed-odometers just from peeling out.

Now Chevy did not make a stock Vega with such a powerful motor. No, someone got the bright idea to take out the crappy four banger that was in it and replace it with a 327 small block V8 with a 3/4 inch racing cam and a Herts speed shifter. They even had to take out the cross bar member on the front end so that the motor would fit in the tiny Vega, which made the tires sit funny when it was parked.

And you know we never got any letters or phone calls from the Chevy folks telling us that our little hack was a violation of any agreement we made when we bought the car. None of their lawyers gave us a deadline to remove that 327 small block from that Little Ole' Vega because it was not designed to have it in there.

No, they were busy trying to design and build cars that people would buy. They let the hobbyist and users hack their cars however they saw fit. And if a hacked car was swapped or sold so be it, there were plenty of other people out there that wanted a brand new car. The car with the new car smell and show room shine.
So Microsoft has a cute little tool called Express and it is for the hobbyist. Doesn't Microsoft know that hobbyist like to ripe into things to see how they work? Haven't they been following the Make movement? Don't they know that the hobbyist really wants to put the big screaming fast race engine in that little car?

And isn't TestDriven.Net free to use for personal use? Like Express? So what is the harm? The harm in what Microsoft is doing is it is killing the community. If the hobbyist is afraid to use Express, or they feel that they are artificially limited in what they can do with Express then why would they want to use it?

Microsoft pays my mortgage and I really have no animosity towards them. But sometimes I just have to wonder.

No Comments


Learning TypeMock.Net

We need to implement a better unit testing strategy at work but unfortunately we have code that is not written to be unit tested. Our unit test rely on the state of our database and this has caused so many issues that I'm hesitant to even run them.

To fix the issue I have started working with TypeMock.Net an AOP mocking tool.  TypeMock will intercept calls to objects that are called by the code you are testing without actually creating or executing the object.  I'm still fuzzy on the details but I plan on using this tool to help me test some pretty untestable code.

No Comments


Scratch Programming

I have started doing more scratch programming, one off little bits of code that I use and throw away. I found that I am not coding as much at work as I need to be, or want to be for that matter. I am loosing my touch.

Like any thing else, if you don't use it you loose it.

When I create projects I like to follow a specific file structure. Nothing fancy, I use a solution folder with folders for lib, src and tests. So when I create my scratch solutions I want to create the same folder structure, but there is no easy way to do it with Visual Studio. I tried to create a project template, which would work if what I wanted was skeleton projects. But what I want are skeleton folders and the VS templates won't create those.

What I wound up doing was create an MSI using NSIS that would create the folder structure and copy core libraries that I like to use. So far it is working out pretty good and was surprisingly simple to create, not by hand of course but with HM NIS Edit, a free tool to create and edit NSIS scripts.

; Script generated by the HM NIS Edit Script Wizard.

; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Scratch Template"
!define PRODUCT_VERSION "1.0"
!define PRODUCT_PUBLISHER "HomeNet"
!define PRODUCT_WEB_SITE "http://blog.ddpruitt.net"
;!define PRODUCT_DIR_REGKEY "SoftwareMicrosoftWindowsCurrentVersionApp PathsMbUnit.Cons.exe"

; MUI 1.67 compatible ------
!include "MUI.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
;!insertmacro MUI_PAGE_LICENSE "............\path\to\licence\Your\SoftwareLicence.txt"
; Components page
!insertmacro MUI_PAGE_COMPONENTS
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH

; Language files
!insertmacro MUI_LANGUAGE "English"

; MUI end ------

Name "${PRODUCT_NAME} ${PRODUCT_VERSION}"
OutFile "ScratchSetup.exe"
InstallDir "$DOCUMENTSVisual Studio 2005ProjectsScratchNewSolution"
;InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
ShowInstDetails show

Section "MainSection" SEC01
SetOutPath "$INSTDIR"
SetOverwrite ifnewer
File "GenericSolution.sln"
CreateDirectory $INSTDIRlib
CreateDirectory $INSTDIRsrc
CreateDirectory $INSTDIRtest
SectionEnd

Section "MbUnit" SEC02
SetOutPath "$INSTDIR\lib\MbUnit"
SetOverwrite try
File "\lib\MbUnit\MbUnit.Framework.dll"
.
.
.
SectionEnd

Section "Log4Net" SEC03
SetOutPath "$INSTDIR\lib\log4net"
File "\lib\log4net\log4net.dll"
SectionEnd

Section "Enterprise Library (June 2006)" SEC04
SetOutPath "$INSTDIR\lib\EntLib.2006.01"
File "\lib\EnterpriseLibrary.2006.01\EntLibConfig.exe"
.
.
.
SectionEnd

;Section -Post
;  WriteRegStr HKLM "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\lib\MbUnit\MbUnit.Cons.exe"
;SectionEnd

; Section descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SEC01} ""
!insertmacro MUI_DESCRIPTION_TEXT ${SEC02} ""
!insertmacro MUI_DESCRIPTION_TEXT ${SEC03} ""
!insertmacro MUI_DESCRIPTION_TEXT ${SEC04} ""
!insertmacro MUI_FUNCTION_DESCRIPTION_END

Add the appropriate files to the Sections, compile and your ready.

No Comments


The Pruitt’s

Thomas, Darren, Dawn and Zoey

No Comments