【问题标题】:Receiving CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' using MSBuild.exe接收 CS0234:使用 MSBuild.exe 的命名空间“Microsoft”中不存在类型或命名空间名称“VisualStudio”
【发布时间】:2019-12-04 23:15:25
【问题描述】:

我正在尝试使用以下命令构建 dotnet 解决方案,但出现错误

CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' using MSBuild.exe

命令:

bat "\"${tool 'MSBuild'}\" Test.sln  /t:Rebuild /p:Configuration=Release /p:VisualStudioVersion=14.0 /p:NoWarn=7035 /p:Platform=\"Any CPU\" "

代码存在于 Bitbucket 中,我正在从 Jenkins 触发构建。代码在windows server中运行。

bat "\"${tool 'MSBuild'}\" Test.sln  /t:Rebuild /p:Configuration=Release /p:VisualStudioVersion=14.0 /p:NoWarn=7035 /p:Platform=\"Any CPU\" "

error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?) 

error CS0246: The type or namespace name 'TestInitialize' could not be found (are you missing a using directive or an assembly reference?)

error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)

【问题讨论】:

    标签: jenkins-groovy msbuild-4.0


    【解决方案1】:

    我遇到了同样的问题,发现它是由使用 Microsoft.VisualStudio.QualityTools.UnitTestFramework 的旧版 Visual Studio 中创建的单元测试项目引起的。这应该改为使用Microsoft.VisualStudio.TestPlatform.TestFramework,这是以后单元测试项目中使用的默认值。修复步骤:

    1. 打开单元测试项目引用,删除对Microsoft.VisualStudio.QualityTools.UnitTestFramework的引用:
    2. 打开项目的管理 NuGet 包,并添加 MSTest.TestFramework 包。
    3. 在 Visual Studio 中重新运行单元测试(作为健全性检查),这些应该会通过。
    4. 从 Jenkins 提交更改、推送、重新运行构建。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-09
      • 2018-06-14
      相关资源
      最近更新 更多