Silverlight 4,RIA服务和TFS 2010 Build Server

| 我有一个包含多个项目的Visual Studio 2010解决方案文件。 Silverlight项目(作为模块),Silverlight Shell项目和许多RIA服务混合在一起。 使用TFS 2010执行构建时,由于未先构建RIA服务生成的代理类,它总是会失败。到目前为止,我看到的唯一解决方案是手动更改.sln文件中的生成顺序。不用了,有很多项目。 我希望找到一个更好的解决方案,而不是将解决方案分解为客户端和服务器端解决方案。 显然,MSBuild 4忽略了.sln文件中的生成顺序。 有人有任何想法/建议吗? 谢谢,     
已邀请:
我找到的最简单的方法是显式声明Silverlight项目与承载RIA服务的项目之间的依赖关系。 您必须在文本编辑器中打开Silverlight项目文件,并向其中添加一个片段:
<ItemGroup>
  <ProjectReference Include=\"..\\Path\\Your.Hosting.Project\\Your.Hosting.Project.csproj\">
    <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
  </ProjectReference>
</ItemGroup>
这将告诉msbuild在构建Silverlight应用程序之前先构建Web服务。而且它仅在使用msbuild构建时才有效,VS会抛出错误。 要同时在Visual Studio中构建它,您必须将此片段包装在Target中并将其添加到Project节点中的InitialTargets中:
<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现在将跳过此目标,但msbuild将用于更改项目的生成顺序。     
这绝对不是“正确”的解决方案,但是作为一个临时选项,为您的Silverlight项目中存在的RIA服务检入生成的
Generated_Code\\*.g.cs
文件怎么样?如果人们检入最新版本以及对他们的
DomainService
类的匹配更新,则所有对象都应按预期构建。     
以下是我们在项目中使用的MS Build脚本的示例。基本上,我们已经将我们的Web项目(包含RIA服务)标记为优先项目,并且正在首先进行构建。 请注意,第一个XML标签应位于环境设置阶段中的某个位置。
<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>
在TeamCity服务器上以私有版本+为我们工作。 这有帮助吗?     

要回复问题请先登录注册