I have based my work on the post of Jeff Wilcox. The solution for WP7 is almost the same as he describes, but there is a small trick.
So I have created the following folders in the project’s lib collection:
- lib\Silverlight\v4.0\Reference Assemblies – with the content of “C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0”, except the Profile folder. This can be also reused for normal SL4 projects.
- lib\Silverlight for Phone\v7.0\MSBuild – with the content of “C:\Program Files (x86)\MSBuild\Microsoft\Silverlight for Phone\v4.0”.
- lib\Silverlight for Phone\v7.0\Libraries – with the content of “C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Libraries\Silverlight”.
- lib\Silverlight for Phone\v7.0\Reference Assemblies – with the content of “C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v4.0\Profile\WindowsPhone”.
Unfortunately there is a special step in the WP7 Microsoft.Silverlight.Common.targets file that sets the reference paths without any condition. Because of this, you cannot specify the paths explicitly. I have duplicated this target (GetFrameworkPaths) and decorated it with a condition. This I’ve saved to a separate targets file inside lib\Silverlight for Phone\v7.0\MSBuild called Microsoft.Silverlight.Common.OverridesForBuild.targets. You can download the entire file from here, but the actual change is really just a condition:
After this preparation, you can change your project file to use the dependencies from the lib folder. For this you need to open the project file in an XML editor and change the Import sections to the following:
You might need to change the lib folder reference in the first two properties according to your setup.
With these I was able to build our solution on the build server.