From my experience you simply cant, which really sucks!!! So much for compile once, run everywhere.
In any case, one solution I found is:
- Code your project in a CF class library or a Win32 library, it doesn't matter which (Project1).
- Add a new project of the other type (Project2).
- Duplicate the folder structure under Project2 so that it mirrors Project1.
- Right click on Project2 and select Add --> Existing Item...
- Navigate to the Project1's folder and select all the files that you are interested in (remember to selectively avoid .designer.cs files, such as the .designer.cs for .resx).
- To the right of the Add button (Add |V) you will see a downward pointing arrow, click it.
- Add as Link.
- Repeat the same process for all the folders under Project2.
The point is that even though you now have two assemblies, any changes to a cs file are reflected in all of them. This is how XNA GameStudio does things, and how I have grappled with the CF for phones in the past.
Once you have done the initial 'port' things go pretty quickly. The CF project should have a debug symbol (POCKETPC or SMARTPHONE IIRC), but I recommend you add MOBILE so that you can share CF code between PocketPC and SmartPhone projects.
I am thinking of writing a tool to mirror projects, if you are interested say so in the comment and I will make time to do it (right now I am not working on any CF stuff).
It should be possible to automate this with an MSBUILD task as well. But unfortunately by generating a csproj file at build time, one looses intellisense at code time.