Should I continue to work on a project I'm less interested in for publications? I'm going to be entering my second year of a PhD program, which I entered straight from undergrad.  I haven't published anything yet, neither since I started my PhD program or as an undergrad.

I'm currently working on a project that, should I choose to continue with, should go on for a year a two.  It has only the slightest relation to the area I'd ultimately want to do my research in, if at all.  That said, I'm doing well, and I think this could lead to publications if I continue down my current path.  There may not be funding available for the exact type of research I'd like to be doing in the immediate future, but this project may be a one or two year commitment.

My question is, am I better off continuing with the project to get some publications, or waiting an indeterminate amount of time for something closer to my original interest to come along?  If that's too vague, then are there any general guidelines for me to follow?

If it matters, my field is CS.

Thanks in advance for any help.
Continue with your current focus, publish as much as possible for the next 1-2 years, and once you are more established with publications under your belt, pursue your passion subject full-time. It's best to view your current research focus as a "day-job", meanwhile developing your skills and reputation which will strengthen your ability to pursue the topics you find interesting.