A sheriff having an order of attachment, or for the delivery of property, may enter any building or inclosure containing the property, to take it; and, if necessary for this purpose, may break the building or inclosure, having first publicly demanded the property.