Okay, well I am just going to aun this for a 6 foot, 180 pound person with 17.5% BF (very average numbers for an athlete). Adjust it to fit your size and bodyfat %.
Alright, so the initial numbers would be:
148.5 of Lean Body Mass (LBM)
31.5 pound of fat
The goal end result would be around 12% BF and 200 pounds, which would be 176 pounds of LBM and 24 pounds of fat. So you would need to lose 7.5 pounds of fat and add 28 pounds of muscle. This is a lofty goal, but it can be done in 5 months.
As electro mentioned, there are cycles called cuts and bulks. Although you could cut down fat, then bulk up, this would take more time than you have. It would serve you better to do something called a “slow bulk” where you add muscle (as in a normal bulk) while still focusing on lowering your BF%. This is acheived through a caloric surplus diet and workout sessions which burn fat deposits. This way your body still has the calories needed to build new muscle (the body will burn carbs first, then fats to provide energy).
Alright, so our example person would burn around 3200 calories throughout the day, assuming that they were moderately active. If you wanted to gain weight, particularly muscle, you would need to take in a caloric surplus of 500-700 calories a day. That would be in order to gain one pound a week. That would probably be the max amount of weight you would want to gain per week, otherwise you would gain BF as well as muscle. So, your daily intake would be around 3500-4000 calories a day. I know it sounds like a lot, but there is really no other way to gain 20 pounds in five months. You have twenty weeks and you need to gain a pound a week to hit the goal. If you break it down to 6 meals a day, it is around 625 per meal. It’s not hard to eat that much.
When it comes out to the macronutrient makeup of your daily calories, you have a lot of different choices. Personally, I would go with a protein heavy, carb low diet. This will make your body more apt to burn fat, since there are no carbs to burn off beforehand. This would make your intake about 50% protein, 30% fat and 20% carbs. The downside is cost. Protein rich foods are expensive. Otherwise, this would be the best choice.
If you arent able to follow that diet, I would just go with a balanced diet- 35% protein, 35% carbs and 30% fats. This isnt ideal, but it will work. Your cardio sessions will need to be more intense to burn the extra carbs (or you could do fasted cardio in the morning before you eat).
In either case, it is important that you eat a lot of protein and dont go overboard on the carbs. If you do that you will be able to gain muscle and lose fat at the same time.
As with anything, you have to stick to the program for a little while, then step back and evaluate. If you are gaining weight too fast, or too slow, then you need to adjust the food intake accordingly. Same goes with cardio and lifting. Follow a program to the letter, then check the results.
Oh yeah, and one last thing- supplements. If I were in your shoes, I would get a multivitamin and whey protein; that is it. There are a lot of fancy pills that promise the world, but hard work is best. Whey helps especially if you follow the 50% protein diet, since each shake is 30g of protein. Way easier than eating a chicken breast or steak (and faster too). Optimum Nutrition is cheap and it is tasty.