That's a tricky situation. Normally I'd suggest your "doggy treat" be made of fast moving lead. However in a bug-out situation shooting a farmer's dog, even if it's attacking you, could lead to much more severe retailiation from said farmer than under normal circumstances.
Maybe a can of "bear spray"? The downside of any Mace/pepper spray is the risk of it hitting you, too.
How about a speartip on your walking stick? It'd probably quietly work against one dog but it seems most farmers/ranchers have more than one dog.
One of those pistol crossbows?
This is a very good question.
-Blast