Neighbours noticed flames coming from a barn on the farm and alerted the fire brigade before starting to rescue the cows housed in the burning building, cantonal police said in a statement.
Around 80 firefighters and emergency workers attended the scene.
They managed to rescue 13 of the cows from the barn, but the animals subsequently had to be put down due to smoke inhalation, said police.
The other 15 perished in the fire.
As yet the cause of the fire has not been established.