The good news on this question is that reversing loss of appetite is relatively straightforward and tends to be successful in most people. However, a nutritional approach is not typically the most effective way to solve this problem. Rather, an energetic approach tends to be far more effective.
For anyone suffering from loss of appetite who is unable to gain weight, I strongly recommend they first visit a naturopathic physician to get a complete checkup and make sure there is nothing imbalanced in the endocrine system or digestive system. Assuming all of that checks out okay, visiting an acupuncturist is the next step. Through acupuncture, a person's appetite can often be rebalanced with a high degree of success. An acupuncturist will typically concentrate on the stomach and spleen meridians in order to rebalance a person's energy and help them regain a natural appetite.
Once this has taken place, there are some nutritional strategies that can help support the rebalancing of appetite hormones and weight gain. This includes consuming high-quality protein and foods with high caloric density such as nuts and seeds. High-quality protein foods include spirulina, which has the highest quality protein of any food available. Remember that spirulina has twelve times the amount of digestible protein as beef on an ounce by ounce basis. It also has far more calcium than milk.
You can also consume isolated soy protein or soy products, but be sure to get plenty of healthy fats into your diet through nuts, seeds, flax oil, and even extra-virgin coconut oil if that's something your naturopathic physician also supports.
Finally, regaining appetite should be supported by a regular exercise program. I don't recommend someone jumping into exercise right away if you're too thin -- wait until your digestion and hormone systems have been balanced, but once you are making progress in terms of weight gain, it's critical to start a lifelong exercise program.
Exercise should include both cardiovascular exercise and strength training. Only through strength training can a person increase their bone mass density and lean body mass. The very act of engaging in these forms of exercise should also increase a person's appetite. So, once a person has made progress through acupuncture or other therapies recommended by a naturopathic physician, combining exercise and strength training will normally accelerate their weight gain.
As always, work with a physician. There could be reasons for your lack of weight gain that fall outside the "normal" reasons experienced by most people.