开发者

Silverlight 4, RIA Services & TFS 2010 Build Server

开发者 https://www.devze.com 2023-02-17 14:43 出处:网络
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 Silverlig开发者_如何学编程ht Shell project and a number of RI

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 Silverlig开发者_如何学编程ht 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,


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.


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.


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 ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号