"Yesterday I spent the whole night writing the report."
Native speaker here. By saying 一个晚上的报告 instead of 晚上的报告，we imply that the action took the whole night (or that you did the action late into the night). If you say 昨天我写了晚上的报告，the meaning would become “I wrote the report of the night yesterday”. Changing your sentence to the meaning in the question will turn it to “昨天我整晚都在写报告。” The grammar rules you broke is that you put the duration in front of the verb, which is normally not used and considered gramatically incorrect.
In this sentence - “我昨天写了一个晚上的报告” there's “一个晚上” - “a (whole) night”. So it's implying that the action of writing the 报告 took one night.
Also，u would be right if the sentence used 一份 [yīfèn] - from the measure word 份 we know that it would refer to the 报告
我昨天写了一个晚上的报告。- Yesterday I spent a whole night on writing the report. 我昨天写了一份晚上的报告。 - Yesterday I wrote an evening report.
我昨天写了一个晚上的报告 For those who also got confused with this sentence, like me, here is a bit of grammar regarding duration of actions. I use V for the verb, O for the object, D for the duration phrase. [ ] for optional items that may be dropped. So, there are several ways to do the same thing:
verb without object: V[了]D. 我写了一个晚上。
verb with a preposition only object: V[了]OD. 我写了它一个晚上。(not sure if this example is totally ok, so let the natives correct it if it is not)
object phrase that is not a pronoun (that's the pattern used in our sentence): VD[的]O. 我写了一个晚上的报告。
move the object (not preposition or default object) to the front of the sentence as a topic: O, ...V[了]D. 报告，我写了一个晚上。