TFS 2010的MSBuild会覆盖输出目录不同版本的参考库 [英] TFS 2010 msbuild overwrites different versions of referenced library in output directory

查看:298
本文介绍了TFS 2010的MSBuild会覆盖输出目录不同版本的参考库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立使用TFS 2010年该项目的Web项目包含Silverlight客户端和.NET / C#服务器端。这两个(客户端和服务器)都引用了我们有Silverlight和.NET版本的一个第三方库,但两个版本使用相同的名称。问题是,的MSBuild与OUTDIR属性指定将所有的库一个平面层次结构中的输出目录中,这样一个库将覆盖其他。

I'm building Web project using TFS 2010. The project contains Silverlight client and .NET/C# server side. Both of these (client and server) are referencing one 3rd party library for which we have Silverlight and .NET version, but both versions use the same name. The problem is that msbuild with outdir property specified puts all the libraries to one flat hierarchy in output directory so one library overwrites the other.

我知道,一个解决办法是将修改生成的模板,而不是指定OUTDIR,但这带来的问题与构建模板的其他部分(我有问题,单元测试,我读到具有把输出到_PublishedWebsites问题的人)。

I know that one solution would be to modify build template and not specify outdir, but this brings problems with other parts of the build template (I had problem with unit tests and I read about people having problems with putting output to _PublishedWebsites).

另一个解决办法就是重命名该库/库这样的名称将不会发生碰撞。但是,这不会是解决办法,如果有很多这样的库。

Another workaround would be to rename that library/libraries so the names will not collide. But this will not be solution if there is a lot of such libraries.

我想找到一些干净的解决方案。你知道一些优雅的方式如何解决此问题?

I'd like to find some clean solution. Do you know about some elegant way how to solve this?

推荐答案

据微软有(至少)引用的三种方法组件:

According to Microsoft there are (at least) three ways of referencing assemblies:


  • 程序集安装在GAC

  • 在应用程序配置中指定的程序集

  • 或使用AssemblyResolve事件

GAC是没有选择,在这里,你将有相同问题(同名)。

The GAC is no option here, as you would have the same problem (same names).

使用AssemblyResolve事件,然后使用Assembly.LoadFrom将可能是做这件事的方式,但更容易将恕我直言...

Using the AssemblyResolve Event and then use Assembly.LoadFrom would possibly a way of doing it, but easier would be imho ...

...做第二次提及的方法:在指定的应用程序配置集。在这里,你基本上编辑App.config中,像这样:

... to do it the second mentioned way: specify the assembly in the application configuration. Here you basically edit the App.config like so:

<configuration>
   <runtime>
       <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1″>
         <probing privatePath="bin;Silverlight;ParentFolder\SubFolder;"/>
      </assemblyBinding>
   </runtime>
</configuration>

和应用程序将在指定的目录中的组件进行搜索。

and the application will search for the assemblies in specified directories.

所以,你可以创建一个特定的文件夹(可能是NET和Silverlight的等),各组装复制到该文件夹​​和探头在上述适当的文件夹中的程序集。

So, you could create specific folders (possibly "NET" and "Silverlight" or the like), copy the respective assembly into that folder and probe for the assembly in the proper folder as described above.

考虑到在应用程序配置中的应用程序将被寻找到是同一个文件夹中引用组件的的与一个文件夹中没有指定的参考引用装配的名字,你也可以简单地创建2个文件夹具有相同的名称为各自的应用(比如客户和服务器,如果他们被称为Client.exe和SERVER.EXE),并复制适当的装配到该文件夹​​。在这种情况下,存在甚至不会任何必要改变该应用程序的配置文件

Considering that when no reference is specified in the application configuration the application will be looking into either the same folder as the referencing assembly or into a folder with the name of the referencing assembly, you could also simply create 2 folders with the same name as the respective application (say "Client" and "Server" if they are called "Client.exe" and "Server.exe") and copy the proper assembly into that folder. In that case there would not even be any need to change the application configuration file.

这篇关于TFS 2010的MSBuild会覆盖输出目录不同版本的参考库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆