I usually dress with jeans and a polo shirt, socks and black "trainer" walking shoes, and usually have my Tilley hat with me. Never shorts or sandals, occasionally t-shirts or button-down short sleeves. My bosses understand that ties double my hourly rates.
I'm fortunate in that for the most part, the people who might care about my appearance both appreciate my ability to get things done and understand the job's potential for having to go digging around in dirty and unpleasant places; if appearance is super important for a particular function, they usually give me the heads up and I'll either make myself scarce or dress up for the function.
Once I had a customer insist on a particular dress code, and I expensed the resulting dry-cleaning bill back to him. When he challenged the expense, I just showed him the particular area I'd been working in, and told him that unless he wanted building maintenance to keep this area a lot cleaner, the cleaning expenses were directly tied to my observance of the dress code.