Well, technically the solution is that you create a class library (.NET assembly) that contains all the shared code and use it from both roles projects. You'll have to set "copy local" to "true" on the reference to that assembly in each role project so that the assembly gets packed into role packages.
However in your case there might be a better solution. You might just use the web role for both purposes. I mean a web role is like a worker role, just has a bonus IIS installed. Unless you really (really-really) need to scale and update them separately you can save a lot of management and deployment pain and also some money just using the web role for everything.