We have a large number of projects within a solution mostly simple class libraries (which are later loaded through MEF) targetting .NET 4.0.
We would like to compile a large number of these for both .NET 4.0 and the Silverlight runtime without duplicating files.
Is there a way to create a new Silverlight class library and link the source files from the other projects so both the .NET 4.0 library and the Silverlight 4.0 library will be compiled?
I'm aware .NET 4.0 can load silverlight 4 assemblies, but I would like to compile both versions anyway instead of compiling everything for Silverlight.
Update: I saw a solution once where some of the projects contained links to other files in other projects, so when you changed a file in one project it would be updated in the other one as well. This is what I mean.
A screenshot of the solution, the Vialis.Led.Interfaces project contains the original files, in the silverlight project I want to create links to these files.
When you want to reuse code, you have basically three options:
Generally create all your basic class libraries as a Silverlight class library project, because it is the framework with the lowest set of features. Throw all references out except for mscorlib.dll, System.dll and System.Core.dll. You can then link such kind of Silverlight library in any full .NET project.
You can link individual code files from another project with the "Add as link" feature (Right click project -> Add Existing Item -> Change "Add" Button to "Add as link"). That way you can create a Silverlight project and link individual files from your full .NET project. However that can get tedious if you have a lot of files and you often add/remove files and folders in your source project.
To cure this problem, you may check out the Project Linker at http://msdn.microsoft.com/en-us/library/dd458870.aspx ... but I haven't tried it myself yet.
Just setup a second project for Silverlight, and then use Project->Add Existing Files...
to add each of the project files into the Silverlight project.
You can also use partial classes to separate out Silverlight-specific or .NET framework specific functionality. (This is the approach used by Prism, btw.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With