我可以使用MSBUILD脚本替换SLN文件吗? [英] Can I use MSBUILD scripts to replace SLN files?

查看:108
本文介绍了我可以使用MSBUILD脚本替换SLN文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将构建从使用Visual Studio SLN文件转移到使用MSBUILD附件(我们正在处理SLN文件中的100个项目),但是我不想在需要时双重维护SLN文件.重新在Visual Studio中编辑代码.

I would like to move my builds from using Visual Studio SLN files to using MSBUILD sripts (we're approaching 100 projects in the SLN file), but I don't want to dual-maintain the SLN files for when we're editing code within Visual Studio.

我想创建一个MSBUILD脚本的依赖树,然后能够从Visual Studio中选择任何一个MSBUILD脚本,就好像它是SLN文件一样使用-自动包括所有依赖项目.

What I would like is to create a dependency-tree of MSBUILD scripts, and then be able to select any one MSBUILD script from Visual Studio to use as if it were the SLN file - including all dependent projects automatically.

Visual Studio可以这样做吗? 是否有任何现有工具可以根据MSBUILD脚本动态创建SLN文件? 有没有人试图写一个工具来做到这一点?

Can Visual Studio do this? Are there any existing tools that can dynamically create SLN files from MSBUILD scripts? Has anybody tried to write a tool to do this?

推荐答案

我在2011年12月编写了一个可动态生成* .sln文件的工具.不幸的是,由于工作中的政治因素,我无法部署它.我们为构建系统维护了600多个项目文件,对于解决方案而言,这个文件太大了.至少您实际上会尝试在IDE中加载的解决方案.

I wrote a tool that dynamically generates a *.sln file back in Dec 2011. Unfortunately due to politics here at work, I wasn't able to deploy it. We maintain over 600 project files for our build system, which is insanely too big for a solution. Well at least a solution you would actually try to load in the IDE.

尽管如此,我们仍使用由MSBuild(不是Devenv.exe)加载的动态生成的解决方案文件.据我所知,没有人试图在IDE中加载该解决方案文件.

Despite that, we do use a dynamically generated solution file that is loaded by MSBuild (Not Devenv.exe). No one ever tries to load that solution file in the IDE as far as I know.

无论如何,所以我编写的工具将包含我们的源代码的目录作为参数.它以递归方式搜索并找到其中的所有* .vcxproj和* .csproj文件.然后,对于每个项目文件,它使用MSBuild API解析文件.解析每个文件时,它会寻找其他项目文件之间的依存关系.查找* .lib文件的本机依赖关系足够聪明.找到托管c ++/CLI的依赖关系非常聪明,该依赖关系通过以下代码在代码文件本身中指定依赖关系:#using.它也足够聪明,可以使用程序集引用查找正常的托管依赖项.它还可以通过其他几种方式找到依赖关系.

Anyways, so the tool I wrote takes as a parameter the directory that contains our source code. It recursively searches and finds all the *.vcxproj and *.csproj files in it. Then for each project file it parses the file using the MSBuild API's. When it parses each file it looks for dependencies among the other project files. It is smart enough to find native dependencies for *.lib files. It is smart enough to find dependencies for managed c++/CLI which specify dependencies in the code file itself with something like: #using . It is also smart enough to find normal managed dependencies using assembly references. It also finds dependencies in a few other ways.

然后它将获取所有这些依赖项并生成一个解决方案文件.如果您有任何疑问,请随时与我联系,我们可以谈谈.

It then takes all those dependencies and generates a solution file. If you have questions feel free to ping me, and we can talk.

这篇关于我可以使用MSBUILD脚本替换SLN文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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