从命令行执行msbuild:获取引用命名空间的错误';Microsoft.VisualStudio.TestTools';

从命令行执行msbuild:获取引用命名空间的错误';Microsoft.VisualStudio.TestTools';,msbuild,Msbuild,我正在使用msbuild编译.net 3.5解决方案,代码如下: msbuild.exe n:\temp\Thisnight.sln /p:Configuration=Debug /v:diag 这给了我一个错误: error CS0234: The type or namespace name 'UnitTesting' does not exist in the namespace 'Microsoft.VisualStudio.TestTools' (are you missing a

我正在使用msbuild编译.net 3.5解决方案,代码如下:

msbuild.exe n:\temp\Thisnight.sln /p:Configuration=Debug /v:diag
这给了我一个错误:

 error CS0234: The type or namespace name 'UnitTesting' does not exist in the namespace 'Microsoft.VisualStudio.TestTools' (are you missing an assembly reference?)
我已经得到了VS2010本身构建的最新源代码

似乎不知道我在这里错过了什么

编辑

在命令窗口的上方看到此消息:

  C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference.
 Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutra
l, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
我不认为我必须在我的项目中包含这个DLL(因为它是MS DLL?)

编辑 我现在看到的是:所有项目都是针对.NET3.5框架的,但是testproject(这是一个给我带来问题的项目)是针对.NET4.0框架的。 奇怪的是:我不能改变它


这是一个带有web的vs2010解决方案。webservice、winforms、dll、setup和testprojects是否在cmd shell中运行了vcvars32.bat?

如果查看Microsoft.Common.Targets文件,您将看到:

<!--
    The SearchPaths property is set to find assemblies in the following order:

        (1) Files from current project - indicated by {CandidateAssemblyFiles}
        (2) $(ReferencePath) - the reference path property, which comes from the .USER file.
        (3) The hintpath from the referenced item itself, indicated by {HintPathFromItem}.
        (4) The directory of MSBuild's "target" runtime from GetFrameworkPath.
            The "target" runtime folder is the folder of the runtime that MSBuild is a part of.
        (5) Registered assembly folders, indicated by {Registry:*,*,*}
        (6) Legacy registered assembly folders, indicated by {AssemblyFolders}
        (7) Resolve to the GAC.
        (8) Treat the reference's Include as if it were a real file name.
        (9) Look in the application's output folder (like bin\debug)
    -->

VS在自己的环境中运行MSBuild,我也不知道它们之间的区别,但是您是否尝试通过修改AssemblyFolders项在命令行中添加缺少的程序集路径。你这里有一首芭蕾舞曲:

希望这能有所帮助。

试试跑步:

msbuild/版本

确保它是3.5版本,而不是旧版本

确保MS dll位于此处或类似的位置:


C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblys\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

,我是否也可以从cruisecontrol中计划它(因为当我运行msbuild时,我想从cruisecontrol中运行它),或者我现在是否贪婪:)它是vs发行版的一部分,在Common7\Tools文件夹下。我在命令提示符下运行了批处理文件,并运行了msbuild任务,但它不起作用。还有其他建议吗?顺便说一下:它在一台开发机器上,所以我安装了VS2010.hmm。不确定。尝试在该计算机上的VS中打开解决方案,并查看IDE是否识别reference选项卡中的引用。您是如何引用此DLL的?您可以尝试删除引用并再次将其添加到项目中。VS运行msbuild来构建项目,因此它在流程启动的环境中一定会有细微的差别。另外-您确定它是同一类型的VS2010安装吗?测试环境在基本版本中不可用,只有在某些版本(如Professional和test)上才能详细说明解决方案的内容?使用当前信息尝试并重新编程有点困难。这是一个包含16个项目(web、webservice、winforms和dll)的vs2010解决方案。不确定是否可以在命令行中重写AssemblySearchPath。你有没有试着添加一个像图图中所示的自定义目标?或者你可以直接修改Microsoft.Common.Targets,但我认为这不是一个好的解决方案…它没有发挥作用,希望有一天有人会读到这篇文章并给我一个解决方案。没想到事先会这么难。已经工作了6个小时以上,但还不够重要,无法继续。我把这一题作为BB付出的努力的答案。我忘了这个问题。我目前面临同样的问题,我认为您无法在VS之外运行VS单元测试(即使用MsBuild)。缺少的dll位于VS10\Common7\IDE目录中,即使我很好地引用了它,我也无法使它在VS之外工作。可能它使用了MsTest或需要一些VS的东西来工作。我把这个问题标记为最喜欢的,看看是否有人有更好的答案。