Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight 4, RIA Services & TFS 2010 Build Server

I have a Visual Studio 2010 solution file with a number of projects in it. There is a mix of Silverlight projects (acting as modules), the Silverlight Shell project and a number of RIA services.

When using TFS 2010 to perform the build, it always fails because the proxy classes generated by the RIA services have not been built first. The only solution I have seen so far is to manually change the build order in my .sln file. No thanks, there are loads of projects.

Rather than break the solution up in to client side and server side solution, I'd like to find a better solution.

Apparently MSBuild 4 ignores the build order in the .sln file.

Does anyone have any ideas/suggestions?

Thank you,

like image 334
Carl Avatar asked Mar 17 '11 09:03

Carl


People also ask

What is RIA Services?

RIA stands for Rich Internet Applications. It must be noted here that Silverlight is a framework offered by Microsoft, ideal for rich internet applications and is available for use as a browser plug-in, just like Adobe Flash. WCF RIA Service is mainly based on the standard version of WCF service.

What is the use of WCF RIA Services?

WCF RIA Services simplifies the development of n-tier solutions for Rich Internet Applications (RIA), such as Silverlight applications. A common problem when developing n-tier RIA solutions is to coordinate the application logic between the middle tier and the presentation tier.


3 Answers

The simplest way I've found is to declare explicitly the dependency between Silverlight project and the project that is hosting RIA service.

You have to open in a text editor your Silverlight project file and add a fragment to it:

<ItemGroup>
  <ProjectReference Include="..\Path\Your.Hosting.Project\Your.Hosting.Project.csproj">
    <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
  </ProjectReference>
</ItemGroup>

This will tell msbuild to build your web service before building your Silverlight app. And it will work only when building with msbuild, VS will throw an error.

To get it built in Visual Studio also, you have to wrap this fragment in a Target and add it to InitialTargets in Project node:

<Target Name="MySpecialReferences">
  <ItemGroup>
    <ProjectReference Include="..\Path\Your.Hosting.Project\Your.Hosting.Project.csproj">
      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
    </ProjectReference>
  </ItemGroup>
</Target>

<Project ... InitialTargets="MySpecialReferences" ... >

Visual Studio 2010 will skip this target now but msbuild will use to change built order of projects.

like image 74
Valeriu Caraulean Avatar answered Nov 05 '22 17:11

Valeriu Caraulean


This definitely doesn't seem to be the "proper" solution, but as an interim option what about checking in the generated Generated_Code\*.g.cs files for your RIA services present in your Silverlight projects? If people check in the up-to-date version along with the matching updates to their DomainService classes, all should build as expected.

like image 1
Jedidja Avatar answered Nov 05 '22 15:11

Jedidja


Below is a sample from an MS Build script that we're using in our project. Basically, we've labelled our web project (containing the RIA services) as a priority project and are building it first.

Please note that the 1st XML tag should be located somewhere in the environment setup stage.

<ItemGroup>
    <!-- use this collection to control project build order, projects listed in this array are removed from the current build queue and pushed in the front before compilation-->
    <InitialBuildProjects Include="MyProject.Web.RiaServices" />
</ItemGroup>

<ItemGroup>
        <PriorityProjects               Include="$(ProjectRootDirPath)\Sources\%(InitialBuildProjects.Identity)\%(InitialBuildProjects.Identity).csproj" />
        <RemainingSourceProjects        Include="$(ProjectRootDirPath)\Sources\**\*.csproj"
                                        Exclude="@(PriorityProjects)" />
        <SLTestProjects                 Include="$(ProjectRootDirPath)\Tests\*.Web\*.Web.csproj" />
        <BuildQueue             Include="@(PriorityProjects);@(RemainingSourceProjects);@(SLTestProjects)" />
    </ItemGroup>

Works for us in private builds + on our TeamCity server.

Does this help ?

like image 1
Maciek Avatar answered Nov 05 '22 15:11

Maciek