如何在Visual Studio 2010中的不同解决方案中使用公共资源 [英] How to use Common Resources in different Solutions in Visual Studio 2010

查看:131
本文介绍了如何在Visual Studio 2010中的不同解决方案中使用公共资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我一直在两台PC上使用VS2010(一个是32位,另一个是64位),我们希望一次使用同一项目,但要在两台不同的PC上使用.因此,我们希望有两个共享相同资源的不同解决方案(sln).您的专家可以对它有任何想法吗?我们只想使用相同的资源(类,表单等).

提前谢谢.

贾德夫·哈特里(Jaidev Khatri)

[OP的答案移到了这里]
感谢SAKryukov,Amir Mahfoozi,Rahul Dhoble,

可能是我没有以正确的方式提出我的问题,但是我非常感谢您的答复,一定会使用您的资源.

更具体地说,我自己在x86处理器上,我准备了带有类的Business Logics,而另一个在64bit机器上的类在设计中使用了这些类.有时这些类存在一些错误和错误,我必须立即清除它们以消除错误.

这就是我一直在寻找的东西,无论是否要在两个处理器中构建.

而且,如果我不使用Team Foundation Server,那么还会有其他服务器.

再次感谢您的答复.

Jaidev Khatri

Hi,

I have been using VS2010 on two pcs (One is 32bit and other in 64bit), we like to use same project at a time but on two different pcs. So we look to have two different solutions (sln) sharing same resources. Can you experts have any idea for the same. We just like to use same resources (Classes, Forms etc).

Thanks in advance.

Jaidev Khatri

[OP''s answer moved to here]
Thanks SAKryukov, Amir Mahfoozi, Rahul Dhoble,

May be I have not asked my question in a right manner but I really appreciate your replies, will sure use your resources.

To be more specific, Myself on x86 processor, I prepare Business Logics with classes and another one at 64bit machine use these classes in design. Sometimes these classes have some bugs and errors which I have to clear it instantly to eliminate the error.

This is what I was looking for, no matter to build in two processors.

Moreover, If I don''t use team foundation server then is there any another too.

Thanks again for your replies.

Jaidev Khatri

推荐答案

通常的处理方式是创建一个公共库,并将其检入版本控制系统(SVN,Mercurial,Git等)中.您想使用).该库可以很简单,就像一个包含所有通用代码的目录(或目录集),甚至是一组包含通用代码的编译版本的dll一样简单.这两个选项中的每一个都有积极和消极的一面,由于时间有限,我现在不打算讨论这一点.

通过使您的库受版本控制,所有开发人员都可以通过更新其存储库的本地副本(使用现代版本控制软件进行简单/快速的操作)来保持同步.
The way that this is usually handled is that you create a common library and you check it into a version control system (SVN, Mercurial, Git, whatever you wish to use). This library can be as simple as just a directory (or set of directories) containing all your common code or even a set of dlls containing compiled versions of your common code. Each one of those two options has positives and negatives, I won''t get into that right now (for lack of time).

By keeping your libraries under version control, all developers can simply keep synchronized by updating their local copies of the repositories (a simple/fast operation using modern version control software).


用于版本控制系统和选择,请参阅此CodeProject讨论:版本控制系统,从中选择? [需要一些单词设置和/或使用服务器的明智之举 [制作不可点击的表单 [如何结构化安排源代码当我创建新解决方案时 [
For a revision control system and the choice, please see this CodeProject discussion: Revision control systems, which to choose from?[^].

See my advice in my answer in this discussion.

A lot more interesting and important detail in my past answers:
Needs some words of wisedom to set up and/or use a server[^],
Make an unclickable form[^],
How can i structured to arrange source code when i create a new solution[^].

—SA


64位和32位目标指令集平台中的资源是否相同?是的,情况非常不愉快.这里的主要问题是:您永远不能在同一过程中混合使用不同的指令集体系结构.它甚至可以在运行时编译位崩溃.

首先,我不了解您同时需要它们的情况.

因此,首先,让我在一个更常见的情况下进行解释.您的任务是确定您是否可以按照要求进行工作.让我们来看看.为什么我们需要不同的目标平台.通常,我们只能有一个项目.假设它是为目标任何CPU"开发的,应用程序的所有程序集都使用该目标.在这种情况下,您只需将产品部署到具有任何体系结构的系统中即可(当前,.NET支持其中三种体系结构:x86,I64(Itanium)和x86-64).即使它们不兼容,任何CPU"程序集也将在任何平台上运行,并且运行时指令集将由主机系统定义.这是因为程序集是JIT编译的.在这种模式下,资源问题将永远不会出现.如果您所有的代码都是纯.NET,且没有非托管组件,则它将以这种方式工作.

我希望上面的模式对您有用,因为下面是真正高级的东西.如果您仍然感兴趣,请继续阅读.

在某些情况下,您需要使用一些非托管组件来定义整个应用程序的指令集体系结构.这是相反的情况:您只能使用一种指令集体系结构.同样,不会出现不同资源的问题.

最后,在某些情况下,您需要根据目标指令集体系结构更改项目的结构.为此,您可以使用MSBuild的功能和通用项目格式来创建复杂的项目或主项目文件.

您甚至可以在构建过程中自动切换指令集体系结构.您不需要两个或多个不同的解决方案,这是不支持的,请参阅:
http://en.wikipedia. org/wiki/Don%27t_repeat_yourself [ ^ ].

相反,您只需要一种可以动态更改目标指令集体系结构的解决方案.为此,您将需要学习MSBuild的项目开发.请从这里开始:
http://msdn.microsoft.com/en-us/library/dd637714.aspx [ ^ ].

使用这种方法,您只能使用一种解决方案进行开发和测试.构建将是自动的.您将需要以MSBuild使用的格式手动编写一个主项目.它将采用您的开发解决方案或单独的项目作为输入,并将修改其属性(例如指令集体系结构,可选模块等),并将构建该解决方案的两个或多个编译并将它们放在每个目录的不同目录中.目标平台.开发过程将需要大量的学习和调试.我已经在相当短的时间内成功完成了此操作,并获得了非常稳定的一键构建所有过程.

另请参见:
http://en.wikipedia.org/wiki/Instruction_set [
Identical resources in 64-bit and 32-bit target instruction-set platforms? Yes, very unpleasant situation. Main problem here is: you can never mix different instruction-set architectures in the same process. It can even compile bit will crash during run-time.

First of all, I don'' understand the situation when you need them at the same time.

So first, let me explain it on a more usual case. You task is to identify if you can work in compliance with it. Let''s see. Why do we need different target platform. Normally, we can have just one project. Suppose it is developed for the target "Any CPU", with all assemblies of the application using this target. In this case, you simply deploy the product to the system with any of the architectures (currently .NET supports three of them: x86, I64 (Itanium) and x86-64). Even though they are incompatible, the "Any CPU" assemblies will run on any platform, and the run-time instruction set will be defined by the host system. This is because the assemblies are JIT-compiled. In this schema, the problem of resources will never appear. It will work this way if all your code is pure .NET, without unmanaged components.

I hope the above schema can work for you, because below it goes really advanced stuff. If you are still interested, keep reading.

There are situations where you have some unmanaged component which defines the instruction-set architecture of the whole application. This is the opposite situation: you can use only one instruction-set architecture. Again, the problem of different resource will not appear.

Finally, there are some more difficult situations when you need to change the structure of the projects depending on the target instruction-set architecture. For this purpose, you can create a sophisticated project or master project file using the features of MSBuild and common project format.

You can even automate switching the instruction-set architecture during build. You don''t need two or more different solution, this is not supportable, please see: http://en.wikipedia.org/wiki/Don%27t_repeat_yourself[^].

Instead, you need only one solution which dynamically changes the target instruction-set architecture. To achieve that, you will need to learn project development for MSBuild. Please start here:
http://msdn.microsoft.com/en-us/library/dd637714.aspx[^].

With this approach, you can have only one solution used for development and testing. The build will be automatic. You will need to have a master project written manually in the format used by MSBuild. It will take your development solution(s) or separate projects on input and will modify their properties (such as instruction-set architecture, optional modules, etc.) and will build two or more compilations of the solution and put them in different directories per target platform. It will take considerable learning and debugging of the development process. I''ve done this successfully in a reasonably short period of time and got a very stable one-click-builds-all process.

See also:
http://en.wikipedia.org/wiki/Instruction_set[^].

—SA


这篇关于如何在Visual Studio 2010中的不同解决方案中使用公共资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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