I live in a county where Democrats dominate. In the last three elections, I don't think I've seen more than one or two Republicans running for local office. They know how difficult (or impossible) it would be to win. However, they're still trying to build the party.
Despite this, the county Republican group just opened an office in my town (people moving from a bordering state are making this area more friendly for them). The office was vandalized almost immediately, but they haven't given up. They show up at the local farmer's market, community festivals, and anywhere else where they can be visible. They aren't aggressive about their message -- they're just making their presence known. They sell cookies and offer literature. That's what we need to do in the heavily Republican areas. Even if a candidate only runs to pin down a Republican incumbent, it's still worth it.
Here's another (Republican) example: the Illinois Republican Party had an opportunity to showcase one of their up and coming people in the recent Senate race. They could have had someone run a clean, positive campaign. Their candidate wouldn't have won, but could have built name recognition and a reputation for being a decent person worthy of a vote in the future. They would also have pinned Barak Obama in Illinois. Of course, they didn't do that, and so Illinois ended up with Alan Keys (snicker). They could have started rebuilding the party, but they missed their chance.
Democrats can learn from these examples: start thinking beyond the next election, to laying the foundations for future growth. Contesting every election (even if it's hopeless) is one way to do this.