Silverlight 4, RIA Services & TFS 2010 Build Server
Asked Answered
C

3

7

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,

Centenary answered 17/3, 2011 at 9:49 Comment(0)
L
9

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.

Legitimacy answered 26/9, 2011 at 17:3 Comment(3)
Thanx for the hint. Works for me to resolve MSBuild + RIA Services build order.Mischief
Thanks! It works :) In VS2010, after adding the item group, VS won't even load the projects. Wrapping the group in the target made it work.Puritanical
Worth mentioning, this issue is still present in TFS 2013. RIA is truly a second-class citizen at this point it seems.Heavily
S
1

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.

Spun answered 25/5, 2011 at 19:58 Comment(2)
and if there are no ria-generated files ? the build will fail, if the client code is going to try to use the ria code.Baerl
The original question states: "it always fails because the proxy classes generated by the RIA services have not been built first" - I assumed that meant the .g.cs files. Are there other generated files for RIA services? I'm quite new to this area :)Spun
B
1

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 ?

Baerl answered 25/5, 2011 at 20:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.