跨多个 Visual Studio 版本的项目依赖性
我有 3 个 .net 项目。
Project1.dll是由VS2008项目生成的。
Project2.dll 由引用 Project1.dll 的 VS2005 项目生成。
Project3.dll 由引用 Project1.dll 和 Project2.dll 的 VS2008 项目生成。
现在,我构建 Project1.dll,并将其手动复制到 Project 2 可以获取它的位置。
然后我构建 Project2.dll 并手动将其和 Project1.dll 复制到 Project 3 可以拾取它们的位置。
显然我做错了什么(手动)。 使我的项目参考保持最新的正确方法是什么?
目前无法将 Project2 更新到 VS2008,然后创建一个包含所有 3 个项目的解决方案。 我们有一个 3rd 方 Visualstudio 插件,尚未在 VS2008 中运行。 Project2 必须保留在 VS2005
将 Project1 和 Project3 取消更新到 VS2005,然后创建一个解决方案也不是一种选择。 我们在这些项目中依赖 C# 3.0 和 .net 3.5 功能。
I have 3 .net projects.
Project1.dll is generated by a VS2008 project.
Project2.dll is generated by a VS2005 project that references Project1.dll.
Project3.dll is generated by a VS2008 project that references both Project1.dll and Project2.dll.
Right now, I build Project1.dll, and manually copy it to the place where Project 2 can pick it up.
Then I build Project2.dll and manually copy it and Project1.dll to the place where Project 3 can pick them up.
Obviously I'm doing something wrong (manual). What is the correct way to keep my projects' references up to date?
Updating Project2 to VS2008 and then creating one solution containing all 3 projects is not an option at this time. We have a 3rd party visualstudio plugin that does not yet work in VS2008. Project2 must stay in VS2005
De-updating Project1 and Project3 to VS2005 and then creating one solution is not an option either. We're relying on C# 3.0 and .net 3.5 features in those projects.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我们使用构建脚本来处理依赖项、构建 DLL 并手动执行您正在执行的操作。
We use a build script that handles the dependencies, builds the DLLs and does what you're doing manually.
我过去使用过的一个技巧是将所有内容移至 2008 年。然后我在 2005 年为项目二设置了一个特殊的解决方案,并使用它与插件一起工作。 能否让它发挥作用只取决于项目二在 2008 年的表现有多糟糕。
A trick I have used in the past is to move everything to 2008. Then I setup a special solution in 2005 for project two and use it to work with the addin. Getting this to work just depends on how bad project two behaves in 2008.
项目 3 的预构建事件怎么样,它出去并使用批处理文件构建项目 1,将其复制到项目 2 文件夹,然后构建项目 2 并将其复制到项目 3 文件夹。
How about a pre-build event for Project3, that goes out and uses a batch file to build Project1 copy it to Project2 folder and then build project2 and copy it to project3 folder.
我建议在解决方案之间共享 csproj/vbproj 文件。 项目文件的格式在两个版本的 studio 之间是兼容的(但是解决方案文件则不然),只要您的 VS2008 项目面向 2.0 运行时,您就可以毫无问题地编译它们。 这将允许您引用项目,这将处理依赖关系。
唯一让这个问题变得棘手的地方是,如果你有一个网络项目需要在两个版本的 studio 之间工作。 在这种情况下,会对项目文件进行一些修改,这些修改将指向正确的 MSBuild 目标文件。
I would recommend sharing the csproj/vbproj files between the solutions. The format of the project files is compatible between the two versions of studio (solution files are not, however), and as long as your VS2008 projects are targeting the 2.0 runtime you should have no trouble compiling them. This will allow you to reference the projects, which will take care of dependencies.
The only place where this gets hairy is if you have a web project that needs to work between the two versions of studio. In that case there are some modifications to the project files which will point to the correct MSBuild target files.
最好的选择可能是为所有三个项目提供一个通用的构建文件夹。 这可以在“项目属性”->“项目属性”中完成。 构建-> 输出路径。 然后将引用指向输出文件夹。 这样,每当您构建任何较低的项目时,较高的项目都将拥有最新版本。 您还可以设置每个配置(调试、发布)的路径,因此无需为每种类型的构建更改该路径。
Probably the best option would be to have a common build folder for all three projects. This can be done in the Project Properties-> Build -> Output path. Then point the references to the output folder. That way anytime you build any of the lower projects, the higher projects would have the latest versions. You can set the path per configurations (Debug, Release) as well, so you won't need to change that for each type of build.