Will an Ultegra 50/34 front crankset work with a Shimano XT M8000 Shadow+ 11 Speed Rear derailleur and 11-42t cassette?
In general 'road' cranks don't work on mountain bikes (I assume that's what you are trying to do here).
Road cranks have a shorter axle than MTB cranks to work with narrower bottom bracket shells.
Also, MTB chainstays are designed to accommodate smaller chainrings than road bikes. Larger chainrings will interfere with the drive side stay.
The long cage version (SGS) of XT M8000 derailleur has total capacity of 47 teeth, according to Shimanos own website: https://bike.shimano.com/en-EU/product/component/deorext-m8000/RD-M8000-SGS.html
They also state that the maximum low-end rear sprocket for setups containing two chainrings would be the same 42 teeth that you're planning to use.
Your desired cassette has 31 teeth difference from the biggest to the smallest, and the chainrings differ by 16, which means you'll be using all of the promised capacity, but not exceeding it.
As long as you use the SGS version instead of the GS (medium cage) version, you're good to go, but unless you're going for something really special, you might want to consider if you actually need all that range.