How to build SIlverlight V2 Apps with Silverlight Tools 3?

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

If you are Silverlight developer you might be probably happy to try Silverlight 3 BETA. The bad thing about this is that you will after installing of Silverlght tools 3 not be able to build Silverlight apps for V2. Unfortunately, this is a feuture which every professional developer needs for sure. So, I’m asking myself how could “we” forget to support this scenario at all?

Today I spend at least two hours with Andreas. For hobbies just two hours, but for people who are paid to build software, we spend 1/2 day of life. 

Here is the solution which will help you to spend less time.
We assume following constellation in your project:

a) You have a solution Abc.sln which references to N silverlight projetcs.
b) You have build the solution vor Silverlight V2 and then installed Silverlight V3 and toolkit.
c) When you build the solution the build is by defaut always done for V2.
d) You want to be able to make a build for both V2 and V3.

Here is you have to do:

0. Open V2 Solution and convert it to V3.

1. Copy form some machine which only have V2 installed following folder: C:\Program Files\Microsoft SDKs\Silverlight\v2.0 to your development machine:
This is result on your dev machine:
imageimage 

2. Copy also the content of C:\Program Files\Microsoft Silverlight\2.0.40115.0 to the development machine.

3. Now create a copy of all N-silverlight project files. For example SilvProject1.Proj into SilvProject1 V2.proj

3. Now create a ne solution called Abc V2.Sln and add all projects as in solution Abc.sln, but instead of original Silverlight projects add new Silverlight projects SilvProjK V2.proj.

4. Open each new SIlverlight project file and look for

“<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight\v3.0\Microsoft.Silverlight.CSharp.targets" Condition="" />”

5. Remove this line and insert following block:

<PropertyGroup>  
  <SilverlightBuildResources>C:\Program Files\MSBuild\Microsoft\Silverlight\v2.0\</SilverlightBuildResources> 
  <TargetFrameworkDirectory>C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\</TargetFrameworkDirectory> 
  <TargetFrameworkSDKDirectory>C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Libraries\Client\</TargetFrameworkSDKDirectory> 
  <SilverlightRuntimeVersion>2.0.31005.0</SilverlightRuntimeVersion> 
</PropertyGroup>

<Import Project="$(SilverlightBuildResources)Microsoft.Silverlight.CSharp.targets"/> 

6. Optional:
Note that Silverlight Tools 3 build the XAP file in root of Client bin folder and not in ClientBin\Debug or ClientBin\Release. If you have some references to ClientBin\Debug\xy.XAP in any of projects be sure that you have change them.

7. Optional: Open the new solution, go to properties of WebProject which you use as Silverlight Application host (if you have such project) and add new starting Silverlight Application with new name SilvProjectXy.Proj. After this step you will have some strange looking list of Silverligth Applications in project properties, but don’t care it will work :)
If in this list is one application which does not exist in the solution it will be just ignored and XAP file will not be build.
Depending on what solution Abc.Sln or Abc v2.sln you have opened one app will always be the right one.


Posted May 11 2009, 05:33 PM by Damir Dobric
developers.de is a .Net Community Blog powered by daenet GmbH.