如何使用MSBuild在单个应用程序套件中组合多个.NET可执行文件? [英] How to assemble multiple .NET executables in a single application suite package with MSBuild?

查看:107
本文介绍了如何使用MSBuild在单个应用程序套件中组合多个.NET可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个解决方案,每个解决方案都有多个项目.

I have multiple solutions each having multiple projects.

我想做的是将这些项目的子集(可能来自不同的解决方案)组装到一个程序包"中,并像这样进行部署.

What I want to do is to assemble a subset of these projects from possibly different solutions into a single "package" and deploy it as such.

我可以编辑每个项目并更改其输出文件夹,但这会适得其反,尤其是其中一些项目在不同目标包之间是共享依赖项.这会造成麻烦,而且很容易出错.

I could edit each project and change it`s output folder but this would be counter productive, espacially that some of these projects are shared dependency amongst the different target packages. This would make a tedious mess and very error prone.

理想情况下,我也希望在最终程序包中如何组装这些程序时有一些自由,也许此应用程序位于程序包的根文件夹中,但另一个可执行文件可能位于最终程序包的子文件夹中.

Ideally also I would like some freedom as to how these are assembled in the final package, perhaps this application goes in the root folder of the package but perhaps this other executable will go in a subfolder of the final package.

最后,与我合作的团队对MSBuild并不熟悉,因此最终的解决方案应该可以在VisualStudio中使用.

Finally the team I work with are not familiar with MSBuild so the final solution should be usable from VisualStudio.

我当时正在考虑创建一个任务,该任务将扫描项目依赖项,并简单地将每个输出文件夹的内容复制到专门项目的输出文件夹中(其中将包含该任务).如有必要,可以通过属性文件微调最终目的地.

I was thinking to create a task that would scan the project dependencies and simply copy the content of each output folder in the output folder of a specialized project (that would contain the task). Final destinations could be fine tuned via a property file if necessary.

有更好的方法吗?

对于软件包,我只是表示包含所有工件的文件夹,它们可能是可执行文件,DLL,资源,配置文件等.不过,我仍然希望将它们保留为单独的实体.

By Package I simply mean a folder containing all the artifacts may them be executables, DLLs, resources, config files etc. I still want to keep them as seperate entities however.

推荐答案

我最终创建了一个新的输出文件夹,在其中复制了项目构建的输出.然后,其他依赖于第一个项目的项目将提取内容并与其合并,然后再应对自己的额外输出文件夹,以在依赖关系树下重复该过程.

I ended up creating a new output folder in which I copied the output of a project's build. Then other projects that depended on that first one would pull the content and merge with theirs before coping in their own extra output folder to repeat the process down the dependency tree.

这确保了所有伪像都可以遵循最终应用程序的构建,而不仅仅是DLL.

This ensured that all artefacts follow through to the final application's build not just DLLs.

当时我需要将整个内容打包到一次单击的存档中.

I needed that at the time to then package the whole thing in a click once archive.

它也可以在构建系统上使用,因为将额外的文件夹压缩为下游项目可以使用和合并的伪像.虽然不是很干净,但足以满足我的需求.事后看来,我可能可以利用nuget来以更清洁和可维护的方式实现相同的结果.

It worked also on the build system as that extra folder was zipped-up as an artefact that downstream projects could use and merge. Was not very clean though but worked good enough for my needs. With hindsight I could probably have leveraged nuget to achieve the same outcome in a much cleaner and maintainable way.

这篇关于如何使用MSBuild在单个应用程序套件中组合多个.NET可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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