In a large, heavy-bottomed pot, melt butter (or heat olive oil.) Add onions and cook until golden brown. Add sugar, balsamic vinegar, salt, and pepper. Continue cooking on medium heat, until onions soften and mixture thickens, about 20 minutes. Set aside and allow to cool while you prep the tart.
Pre-heat oven to 375-degrees. Lightly flour your work surface. Roll out an 8-ounce puff pastry sheet to about 16”. Transfer to a lightly greased baking sheet. Fold over edges of pastry sheet about 1”. Pierce sheet with a fork (which will prevent the tart from puffing up.)
In a small bowl, mix together egg and gruyere. Spread evenly across puff pastry. Then, spoon caramelized onion on top, reserving any excess onion. Finally, line asparagus spears vertically across. Brush with asparagus and pastry crust with olive oil, sprinkle with salt and pepper, and bake for 20-30 minutes, or until crust is golden brown.
Remove from oven and allow to cool for about 10 minutes. Cut tart into square pieces and serve with freshly grated gruyere or parmesan. It’s delightful when served warm, but also great cold or at room temperature.