TFS构建向xap文件Microsoft.Practices.ServiceLocator添加不需要的代码块

时间:2011-09-23 11:13:36

标签: visual-studio-2010 silverlight-4.0 msbuild unity-container

以下是我在silverlight项目中的参考文献列表。

Microsoft.Practices.Unity.Silverlight<br/>
mscorelib<br/>
Prospector.ProviderMatching.LinkedDataObjects<br/>
Prospector.ProviderMatching.SLDataObjects<br/>
System<br/>
System.ComponentModel.DataAnnotations<br/>
System.Core<br/>
System.Net<br/>
System.ServiceModel<br/>
System.Windows<br/>
System.Windows.Browser<br/>
System.Windows.Controls<br/>
System.Windows.Controls.Data.Input<br/>
System.Windows.Controls.Toolkit<br/>
System.Windows.Data<br/>
System.Xml<br/>

当我构建项目localy时,我的xap文件的含义如下所示。

AppManifest.xaml
   Microsoft.Practices.Unity.Silverlight.dll
   Prospector.ProviderMatching.DataObjects.SL.dll
   Prospector.ProviderMatching.Silverlight.dll
   Prospector.ProviderMatching.SLDataObjects.dll
   ServiceReferences.ClientConfig
   System.ComponentModel.DataAnnotations.dll
   System.Windows.Controls.Data.dll
   System.Windows.Controls.Data.Input.dll
   System.Windows.Controls.dll
   System.Windows.Controls.Toolkit.dll
   System.Windows.Controls.Toolkit.Internals.dll
   System.Windows.Data.dll

当签入此命令并且构建服务器启动时,它会创建一个具有以下异议的xap文件。

AppManifest.xaml
   的 Microsoft.Practices.ServiceLocation.dll
   Microsoft.Practices.Unity.Silverlight.dll
   Prospector.ProviderMatching.DataObjects.SL.dll
   Prospector.ProviderMatching.Silverlight.dll
   Prospector.ProviderMatching.SLDataObjects.dll
   ServiceReferences.ClientConfig
   System.ComponentModel.DataAnnotations.dll
   System.Windows.Controls.Data.dll
   System.Windows.Controls.Data.Input.dll
   System.Windows.Controls.dll
   System.Windows.Controls.Toolkit.dll
   System.Windows.Controls.Toolkit.Internals.dll
   System.Windows.Data.dll

正如您所看到的,我在xap文件中获得了应用程序不使用的代码块。然而,这不仅浪费带宽,它实际上阻止了silverlight应用程序做任何事情,它被下载但不会运行。

如果我从xap文件和manifest.xml中删除有问题的Microsoft.Practices.ServiceLocator.dll,那么silvlight应用程序将按预期运行。

有没有人知道为什么构建服务器包含这个库以及如何阻止它这样做??

2 个答案:

答案 0 :(得分:0)

我认为Microsoft.Practices.ServiceLocation.dll会随着您对Microsoft.Practices.Unity.Silverlight.dll的引用而不断添加。我感觉它们彼此依赖。你需要使用Unity吗?至于当XAP中包含Microsoft.Practices.ServiceLocation.dll时您的应用程序失败的原因;我怀疑您可能使用的是错误版本的Microsoft.Practices.Servicelocation.dll(WPF版本?)

答案 1 :(得分:0)

迈尔斯确实已经解决了问题,我只是将其添加到我的特定问题的更多细节中。

问题是.net版本的ServiceLocator正在构建服务器上的xap中构建。

我认为它不是在本地构建的原因是因为它正由GAC解决。

我获取了Microsoft.Practices.Unity.silverlight.dll和Microsoft.Practices.ServiceLocator.dll的副本,并将它们添加到共享二进制文件夹中,该文件夹被检入到构建服务器可以引用的源代码管理中。然后,我从已安装的程序中卸载了Unity for Silverlight 2.0(我假设它已经取消了它)。我添加了对上面dll的引用,这些dll现在在我的二进制文件夹中并在本地构建我的解决方案。 Hay presto我现在在我的xap文件中包含了Microsoft.Practices.ServiceLocator.dll。

一旦将所有这些检入TFS,构建现在从共享binarys文件夹中选择了正确版本的Microsoft.Practices.ServiceLocator.dll并将其包含在xap中。任务完成。我认为这个问题的原因在于全局程序集缓存。

希望这可以帮助同样受挫的人。