Steve Coll has a long essay in Foreign Policy on the military dilemma:
By comparison to the challenges facing the Soviet Union after it began to "Afghanize" its strategy around 1985 and prepare for the withdrawal of its troops, the situation facing the United States and its allies today is much more favorable. Afghan public opinion remains much more favorably disposed toward international forces and cooperation with international governments than it ever was toward the Soviet Union.
The presence of international forces in Afghanistan today is recognized as legitimate and even righteous, whereas the Soviets never enjoyed such support and were unable to draw funds and credibility from international institutions. China today wants a stable Afghanistan; in the Soviet era, it armed the Islamic rebels. The Pakistani Army today is divided and uncertain in its relations with the Taliban, and beginning to turn against them; during the Soviet period, the Army was united in its effort to support Islamist rebels. And even if the number of active Taliban fighters today is on the high side of published estimates, those numbers pale in comparison to the number of Islamic guerrillas fighting the Soviet forces and their Afghan clients.
His bottom line:
America's record of policy failure in Afghanistan and Pakistan during the last 30 years should humble all of us. It should bring humility to the way we define our goals and realism about the means required to achieve them. It should lead us to choose political approaches over kinetic military ones, urban population security over provocative rural patrolling, and Afghan and Pakistani solutions over American blueprints. But it should not lead us to defeatism or to acquiescence in a violent or forcible Taliban takeover of either country. We have the means to prevent that, and it is in our interest to do so.