为什么MSBuild在VS2008成功的命令行中失败? [英] Why does MSBuild fail from the command line where VS2008 succeeds?

查看:246
本文介绍了为什么MSBuild在VS2008成功的命令行中失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ASP.NET解决方案,可以从VS2008内部很好地构建.

I have an ASP.NET solution that builds just fine from within VS2008.

但是,当我这样做时它会失败:

However , it fails when i do this :

MSBUILD.exe c:\path-to-sln 

它失败,并显示CS0006错误(找不到元数据文件'dll_name'"). 当我尝试在解决方案中使用项目的.csproj时,也会失败.

It fails with a CS0006 error ("Metadata file 'dll_name' could not be found"). It also fails when I try with a .csproj of a project within the solution.

VS2008在做什么,MSBuild丢失了?据我了解,VS知道MSBuild无法解决的程序集间依赖关系.有什么办法可以将这些通知MSBuild吗?

What is VS2008 doing that MSBuild is missing ? It is my understanding that VS knows about inter assembly dependencies that MSBuild cant. Is there any way I can inform MSBuild of these?

(我需要从命令行运行MSBuild,因为我是从CruiseControl.Net的MSBuild-Task调用它的.)

(I need MSBuild to work from the command line because I am calling it from an MSBuild-Task from within CruiseControl.Net.)

在此先感谢. :3)

(我看过如何获取cmd VS解决方案的命令行生成命令?,但仍然无法得到它)

(I have looked at How to get cmd line build command for VS solution? , but still dont get it)

推荐答案

必须先设置环境变量,然后msbuild才能起作用.您发布的带有问题的链接实际上具有答案(请参阅第一个答案条目).

you have to set the environment variables first before msbuild can work. the link you posted with the question actually has the answer (see the first answer entry).

自动执行此操作的一种方法是,根据要为其构建可执行文件的平台,选择所需的vcvars * .bat文件.例如,如果要针对x86进行构建,则vcvarsall.bat文件说您将需要bin\vcvars32.bat.您可以复制该批处理文件,手动添加include,lib和libpaths,并在批处理文件的:end部分中添加构建步骤,如下所示:

one way you automate this is to choose which vcvars*.bat file you need, depending on which platform you wish to build an executable for. for example, if you want to build for x86, the vcvarsall.bat file says you would need bin\vcvars32.bat. you could copy this batch file, manually add your includes, lib and libpaths, and add the build step at the :end section of the batch file, like so:

...
(batch file contents go here)
:end
MSBUILD.exe c:\path-to-sln 

在那之后,您可以告诉要尝试从中构建的程序来运行刚刚创建的批处理文件.

after that, you can just tell whatever program you are trying to build from to run the batch file you just created.

这篇关于为什么MSBuild在VS2008成功的命令行中失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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