We investigate the fermionic condensate and the vacuum expectation value of the energymomentum tensor for a massive fermionic field in the geometry of two parallel plate on the background of Minkowski spacetime with an arbitrary number of toroidally compactified spatial dimensions, in the presence of a constant gauge field. Bag boundary conditions are imposed on the plates and periodicity conditions with arbitrary phases are considered along the compact dimensions. The nontrivial topology of the background spacetime leads to an Aharonov-Bohm effect for the vacuum expectation values induced by the gauge field. The fermionic condensate and the expectation value of the energy-momentum tensor are periodic functions of the magnetic flux with period equal to the flux quantum. The boundary induced parts in the fermionic condensate and the vacuum energy density are negative, with independence of the phases in the periodicity conditions and of the value of the gauge potential. Interaction forces between the plates are thus always attractive.However, in physical situations where the quantum field is confined to the region between the plates, the pure topological part contributes as well, and then the resulting force can be either attractive or repulsive, depending on the specific phases encoded in the periodicity conditions along the compact dimensions, and on the gauge potential, too. Applications of the general formulas to cylindrical carbon nanotubes are considered, within the framework of a Dirac-like theory for the electronic states in graphene. In the absence of a magnetic flux, the energy density for semiconducting nanotubes is always negative. For metallic nanotubes the energy density is positive for long tubes and negative for short ones. The resulting Casimir forces acting on the edges of the nanotube are attractive for short tubes with independence of the tube chirality. The sign of the force for long nanotubes can be controlled by tuning the magnetic flux. This opens the way to the design of efficient actuators driven by the Casimir force at the nanoscale.