从 Visual Studio 解决方案文件和项目文件生成 MSBUILD 项目文件 [英] Generating an MSBUILD project file from a visual studio solution file and project files

查看:21
本文介绍了从 Visual Studio 解决方案文件和项目文件生成 MSBUILD 项目文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以向 MSBuild 传递一个 VS 解决方案文件 (.sln),它会构建解决方案,但在我脑海中的某个地方,我记得使用了一个 MSBuild 命令行开关,它会获取一个解决方案文件(它是引用的项目文件)并从中生成单个 MSBuild 项目文件.但是,我现在找不到这个开关!这一切都是梦吗?

I know that I can pass MSBuild a VS solution file (.sln) and it will build the solution but somewhere in the back of my mind, I remember using a MSBuild command line switch that would take a solution file (and it's referenced project files) and generate a single MSBuild project file from them. However, I now can't find this switch! Was this all a dream?

我看到了 /preprocess 开关(短格式 /pp),但我不认为就是这样,因为这将包括所有导入的文件(包括Microsoft.*.targets),此外我似乎无法让这个开关工作.当我尝试以下命令行时,MSbuild 会生成 *.out 文件,但它是空的!

I see the /preprocess switch (short form /pp) but I don't think that this was it as this will include all of the imported files (including Microsoft.*.targets) and besides I can't seem to get this switch to work. I when I try the following command line, MSbuild generates the *.out file but its empty!

msbuild /target:rebuild /generate MSBuildCopyTargets.sln

推荐答案

最简单的方法是从命令行运行 MSBuild,并设置环境变量:

The easiest way to do this is to run MSBuild from the command line, with an environment variable set:

  Set MSBuildEmitSolution=1

输出格式为 SolutionName.metaproj

The output will be in the format SolutionName.metaproj

这篇关于从 Visual Studio 解决方案文件和项目文件生成 MSBUILD 项目文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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