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

时间:2010-10-02 21:22:50

标签: 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 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?)

EDIT 我现在看到的:所有项目都是针对.Net 3.5框架的,但是testproject(给我问题的那个)是针对.Net 4.0框架的。 而奇怪的是:我无法改变它。

这是vs2010的网络解决方案。 webservice,winforms,dll,setup和testprojects

3 个答案:

答案 0 :(得分:2)

你在cmd shell中运行了vcvars32.bat吗?

答案 1 :(得分:1)

如果查看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项在命令行中添加缺少的程序集路径。你有一个tuto:http://www.beefycode.com/post/Resolving-Binary-References-in-MSBuild.aspx

希望这有帮助。

答案 2 :(得分:1)

尝试跑步:

msbuild / version

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

确保MS dll在这里或类似的地方:

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

相关问题