in

CodePrairie .NET

South Dakota .NET User Group

chrisortman

  • Told ya so

    Most people I talk to know of my disdain for myspace, here's just another reason I don't like it http://www.newscientist.com/article/mg19025556.200?DCMP=NLC-nletter&nsref=mg19025556.200

  • a note on comments

    For some reason there are no links to add comments on the aggregate view, if you'd like to comment on something you need to goto http://www.codeprairie.net/blogs/chrisortman
  • Another MSBuild gotcha

    I came across an oddity last night when trying to setup a build….

     

    I’m going to go into a little more detail than is maybe necessary incase someone sees it and can say whoa back up your going about this all wrong

     

    I have the following root directory structure

     

    DependentFiles

    Source

    Vendor

    VendorLibs

    Vendor.proj

    Myproject.targets

     

    I use several open source projects which I need to build myself because they rely on each other but the distributed binaries don’t all have strong names or necessarily reference the correct version of some other tool, so in my Vendor folder I have put the source for these projects.  I don’t want to have to ProjectReference to these guys from my own code since I typically don’t want to have them all loaded in my solution and I wanted to make minimal changes to the Vendor code so I can take updates with less hassle. So I created a vendor.proj build file that basically will build all the code in \Vendor and copy the resulting dll’s and pdb’s to VendorLibs, my projects then reference these dll’s. One thing I found with this approach is that doing master-child builds sucks when it comes to path resolution if the child projects don’t reference paths using $(MSBuildProjectDirectory)\<some relative path>. After some toiling I did get vendor.proj to build correctly when executing from the root directory alo (msbuild vendor.proj /t:Build

     

    Here’s a typical target in my vendor.proj file:

      <ItemGroup>

        <DependentFiles Include="$(MSBuildProjectDirectory)\DependentFiles\**\*.dll" />

     

        <CastleDynProxyProjFiles Include="$(MSBuildProjectDirectory)\Vendor\Castle\Tools\DynamicProxy\Castle.DynamicProxy\Castle.DynamicProxy-2.0.csproj" />

       

        <CastleIOCProjFiles Include="$(MSBuildProjectDirectory)\Vendor\Castle\InversionOfControl\**\*-2-0.csproj" />

      </ItemGroup>

    <Target Name="build-castle-ioc" DependsOnTargets="build-dynamic-proxy">      

        <MSBuild Projects="@(CastleIOCProjFiles)" Properties="Configuration=$(Configuration)"

                 Targets="$(vstargets)">

          <Output TaskParameter="TargetOutputs" ItemName="CastleIOCOut"/>

        </MSBuild>

        <CreateItem Include="@(CastleIOCOut)" AdditionalMetadata="Project=CastleIOC">

          <Output TaskParameter="Include" ItemName="BuiltAssemblies"/>

        </CreateItem>

      </Target>

     

    Now onto my code under Source I have:

    Project1

    Project2

    Project3

    …etc….

    MyProject.sln

     

    Now when I build my code I want to ensure that the VendorLibs are up-to-date (I haven’t done up to date yet, I just make sure the files are there) and if not I need to rebuild the vendor code. I accomplish this in my MyProject.targets file using something like this:

     

      <PropertyGroup>

        <ResolveReferencesDependsOn>

          EnsureVendorLibs;

          $(ResolveReferencesDependsOn);

        </ResolveReferencesDependsOn>

      </PropertyGroup>

     

    <Target Name="EnsureVendorLibs">

           

        <MSBuild Projects="..\..\vendor.proj" Targets="Build"

                 Properties="Configuration=$(Configuration) "

                 Condition="!Exists('$(MSBuildProjectDirectory)\..\..\VendorLibs')"

                 />

      </Target>

     

    Now here’s what I ran into say from my Source folder I do

    Msbuild MyProject.sln /t:Build

    And it needs to build the VendorLibs ....

    Some of the projects under Vendor use project to project references which when called via msbuild vendor.proj /t:Build and being passed using an ItemGroup of the project files to an msbuild task will happily resolve….however when my build using MyProject.sln and call to EnsureVendorLibs the project references fail to resolve. Here’s why, in the Microsoft.common.targets file we have this task

     

    <Target

            Name="SplitProjectReferencesByType"

            Condition="'@(ProjectReference)'!=''">

     

            <!-- Assign a project configuration to each project reference if we're building a solution file. -->

            <AssignProjectConfiguration

                ProjectReferences="@(ProjectReference)"

                SolutionConfigurationContents="$(CurrentSolutionConfigurationContents)"

                Condition="'$(BuildingSolutionFile)'=='true'">

     

                <Output TaskParameter="AssignedProjects" ItemName="_ProjectReferenceWithConfiguration"/>

     

            </AssignProjectConfiguration>

     

    <!—rest of target ommitted for brevity sake -- >

        </Target>

     

    Well since I initially invoked MSBuild using msbuild MyProject.sln /t:Build the $(BuildingSolutionFile) property will evaluate to true which causes resolution to fail because the ProjectReferences are not defined in my solution (or any projects built by my solution)

    The workaround I used was to change my EnsureVendorLibs target like so

    <Target Name="EnsureVendorLibs">

           

        <MSBuild Projects="..\..\vendor.proj" Targets="Build"

                 Properties="Configuration=$(Configuration);BuildingSolutionFile=false"

                 Condition="!Exists('$(MSBuildProjectDirectory)\..\..\VendorLibs')"

                 />

     

        <Message Text="$(BuildingSolutionFile)" />

      </Target>

     

    Which now when I execute will build correctly and after the task completes the $(BuildingSolutionFile) will contain it’s original value.

     

     I posted this to the msdn forums also http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=464794&SiteID=1&mode=1

    Posted Jun 09 2006, 09:48 AM by chrisortman with no comments
    Filed under:
  • MSBuild Gotchas

    Here's a couple of MSBuild gotchas...

    When specifying paths to your Include / Exclude ItemGroups make sure to use backslashes (\) I've found that forward slashes (/) seem to make the exclusion not work...my guess is that they compare it against the current search using back slashes on the search item, but not on my include item....haven't dug into the code....just a guess.

    Second be careful that when you are overriding default MSFT targets using PropertyGroups as shown http://blogs.msdn.com/msbuild/archive/2006/02/10/528822.aspx that you do it at the bottom of your project file after the default imports. I was overriding the behavior in my common targets file, but had my import statment before the microsoft one...so of course it didn't work.

    Posted Jun 08 2006, 11:47 PM by chrisortman with no comments
    Filed under: ,
  • Dynamic languages on the CLR

    As I find myself cranking out a lot of code lately I am really yearning for a more wrist friendly way of doing things. I also think I'd see a lot of benefit from a dynamic language when writing unit tests since I want to crank them out quickly and not have language / compiler get in the way. I've also been looking into Ruby and Ruby on Rails and there is much to be desired there. The sheer power of the rails 10 minute video is staggering. Sure there are some for Asp.net also, but the difference is in my willingness to actually build an application using the practices in the Asp.Net side. The concepts behind rails are uber!

    So in my initial hunting I've managed to find a few options:

    RubyCLR -- this provides an interop layer between .NET and Ruby. I've used this a bit and really like what I see. My biggest complaint is that the only way I've been able to pass an object defined in ruby back to .NET is by implementing an interface....not a huge deal, just not ideal. This was created by Jon Lam, and if you're into blogging and aren't reading his...you're missing out. Check out http://www.iunknown.com

    IronRuby -- Is a Ruby interpreter for .NET. Since this runs inside the CLR you can do some things here (like inheritance) that you can't do using RubyCLR, however you also can't use all / any ruby syntax either. I haven't tried this yet, but it appears to be a bit less mature than RubyCLR at this point.

    IronPython -- Wow, kudos to you Microsoft. This is a python interpreter for the .NET framework. It is in the late beta stages and from what I have read is fairly stable and performs well. It also looks like it has visual studio integration. The only thing really keeping me from trying it out at this point is that I don't know python syntax very well and from what I've glanced at so far it doesn't look very inviting (especially after looking at Ruby code)....I see all kinds of _ and __ all over the place.

    Boo -- This is a new language with it's own compiler. It offers similar syntax to ruby and pythong (it actually seems like it is taking the better from both) and compiles natively to .NET code. It is very tempting in many regards, however I'm leary of moving to a non-standard custom language that may or may not last or stay supported.

    If anyone has any stories to share with any of these I'd love to hear about them.

    Posted Jun 07 2006, 09:35 AM by chrisortman with no comments
    Filed under:
  • ASP.Net 2.0 Gridview Gotcha

    Bumped into this little quirk today, glad I didn't have to do much research to find the answer, thanks Steve http://geekswithblogs.net/michelotti/archive/2006/02/25/70708.aspx

    Posted May 31 2006, 10:32 AM by chrisortman with no comments
    Filed under:
  • Does anyone have a towel I can borrow

    So I got home from work today and remembered that Dan had sent me an email saying there was a new trailer for superman returns....
    So, I watched it...
  • VS 2005 Web Application Project Release Candidate Now Available

    Released yesterday. This is a great tool if you are doing any kind of web development in VS2005.

    http://weblogs.asp.net/scottgu/archive/2006/04/05/442032.aspx

    Posted Apr 06 2006, 07:52 AM by chrisortman with no comments
    Filed under:
  • My first Atlas Adventure

    So I'm learning how to use Atlas at work right now, and so far my first lesson was to find an odd little bug. I'm not sure whether or not it is an atlas bug or some rule of HTML that I'm not familiar with, but in following this example .

    If I modify it slightly and add a new label (the bold is what I added):

    <span id="mySpan" />

    What is the definition of a <a id="hoverLink" class="hoverlabel">word</a>?

    <div id="popup" style="visibility:hidden;display:none;border:solid 1px black;background-color:Yellow;">

    A sound or a combination of sounds.

    </div>

    And add to the xml markup:

    <label id="mySpan" text="Hello World" />

    <control id="popup">

    <behaviors>

    <popupBehavior id="popupBehavior" parentElement="hoverLink" positioningMode="BottomLeft"/>

    </behaviors>

    </control>

    It breaks and says that it can not find the popup control. However if I declare the span element like:

    <span id="mySpan" ></span>

    Then everything is peachy.

     

    Posted Apr 05 2006, 04:50 PM by chrisortman with no comments
    Filed under: ,
  • Nifty Little Service from Amazon

    Amazon S3 is storage for the Internet. It is designed to make web-scale computing easier for developers.

    Amazon S3 provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web. It gives any developer access to the same highly scalable, reliable, fast, inexpensive data storage infrastructure that Amazon uses to run its own global network of web sites. The service aims to maximize benefits of scale and to pass those benefits on to developers.

    http://www.amazon.com/gp/browse.html/ref=sc_fe_c_1_3435361_1/102-6924280-7929762?%5Fencoding=UTF8&node=16427261&no=3435361&me=A36L942TSJ2AJA

    It's not free, but it is quite cheap.

  • home pwnerer

    Yeah, I finally closed on my new house this week. It has been a very interesting experience thus far. I've got some pictures of the outside posted. I'll had some inside too, but they didn't turn out.

    Photos

  • I must have one

    Thanks Chris Sells for pointing this out. Now if I could just manage to get the remote control to fly into my outstretched hand I'll be in business. Be sure to watch the demo video.
  • Combobox databinding with Null Values in WinForms 2.0

    I've been digging into the databinding features of winforms 2.0. One of the main things I've come to learn is that you do not adapt databinding to your object model, you adapt your object model to databinding /sigh. Oh well...the combo box for me has been a source of much frustration, as it seems to be for many people.

    Take this example, say you have an Address object that may or may not have a street assigned to it. On the dataside this means I have an address row with a nullable column for StreetID. So essentially address looks something like

    public class Address {
        private Street _street;

        public Street Street {
          get { return _street; }
          set { _street = value; }
       }
    }

    Fairly straight forward, and in this class _street may or may not be null. Now suppose in your interface you have a combo box with a list of valid streets. You would most likely bind this combo box with Datasource = BindingList DisplayMember = StreetName and ValueMember = StreetID. You might also be tempted to set the SelectedValue member, but I have had very little luck doing that when binding to objects. Instead you would bind your SelectedItem property to your AddressBindingSource.Street property. Doing it this way databinding will work as expected (you did override Object.Equals   in your Street class right?) except for when Address.Street is null, in that case the first item in the combo box will be selected...not what you want to happen.

    So my solution to this problem...a new type of list like this:

    class NullSafeBindingList : BindingList where T : new() {
          public NullSafeBindingList(IList list, string keyPropertyName, string displayPropertyName) : base
    (list) {
               T nullObj = new
    T();
              Type t = typeof
    (T);
              PropertyInfo
    idProp = t.GetProperty(keyPropertyName);
              PropertyInfo
    dispProp = t.GetProperty(displayPropertyName);
             idProp.SetValue(nullObj, -1, null
    );
            dispProp.SetValue(nullObj, "", null
    );
            this
    .Items.Insert(0,nullObj);
        }
    }

    So far, this seems to work well. You do have to make sure your Address class can handle (ignore) Streets that have an ID of -1 though.
    I only just came up with this today, so I haven't done a lot of testing in the wild with it yet, but I'd love any feedback or comments you might have...good approach, bad approach, did I eat paintchips as a kid etc...as well as how you may have solved this problem yourself.

    Happy Coding

  • Software patents are bad bad bad

    Software patents are wrong on so many levels, I hardly know where to begin. Which is why it really distresses me to see Microsoft playing the patent game so aggressively. Dan sent me an article where a guy from MSFT stated that they were hoping to up their patent filing to 3000 per year. But my favorite part of the article was this:

    “Patents are about maintaining market share and preventing others competing effectively,” he said.”

    Preventing competition...really isn't that kind of say a monopoly...

    I guess in my mind Microsoft you're being a bunch of pussies. If you are afraid of competition then do something about it. Make your products better and cheaper than anything out there. Don't go crying to the government to protect your business. But to be fair some remarkably innovative ideas have come out of MSFT that I can certainly see why they would want to protect them. Things such as displaying numbers using a bold font....what nonsense

  • This is a great idea

    The folks over at bluesecurity have come up with a nice way to strike back at spammers (which in my opinion bairly deserve to be called human). I'm definately getting in on the beta, check it out.
More Posts « Previous page - Next page »
Powered by Community Server (Commercial Edition), by Telligent Systems