无法在 Visual Studio 2017 中构建我的单元测试项目

     2023-03-30     89

关键词:

【中文标题】无法在 Visual Studio 2017 中构建我的单元测试项目【英文标题】:Unable to build My Unit Test Project in Visual Studio 2017 【发布时间】:2018-10-25 07:31:38 【问题描述】:

我在构建解决方案(包括单元测试项目)时遇到此错误。

此项目引用了此项目中缺少的 NuGet 包 计算机。使用 NuGet 包还原下载它们。更多 信息,请参阅http://go.microsoft.com/fwlink/?LinkID=322105。这 丢失的文件是 ..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets。

.csproj 文件

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>77FE5641-248D-4D82-850A-1B53495CB9A9</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>UnitTest</RootNamespace>
    <AssemblyName>UnitTest</AssemblyName>
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <ProjectTypeGuids>3AC096D0-A1C2-E12C-1390-A8335801FDAB;FAE04EC0-301F-11D3-BF4B-00C04F79EFBC</ProjectTypeGuids>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
    <ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
    <IsCodedUITest>False</IsCodedUITest>
    <TestProjectType>UnitTest</TestProjectType>
    <NuGetPackageImportStamp>
    </NuGetPackageImportStamp>
    <TargetFrameworkProfile />
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\MSTest.TestFramework.1.1.11\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..\packages\MSTest.TestFramework.1.1.11\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
    </Reference>
    <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
      <HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
    </Reference>
    <Reference Include="System" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Core" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.3\lib\net45\System.Net.Http.Formatting.dll</HintPath>
    </Reference>
    <Reference Include="System.Web.Extensions" />
    <Reference Include="System.Web.Http, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
      <HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.3\lib\net45\System.Web.Http.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="GenerateConceptService\GenerateConceptServiceUnitTest.cs" />
    <Compile Include="SocialMedia\SocialMediaServiceTest.cs" />
    <Compile Include="SocialMedia\TwitterActionsTest.cs" />
    <Compile Include="UnitTest1.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config">
      <SubType>Designer</SubType>
    </None>
    <None Include="packages.config" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Core.WindowsServices\Core.GenerateConcept\Core.GenerateConcept.csproj">
      <Project>767FA3B9-55C4-4C3D-AEB8-7912A09AF868</Project>
      <Name>Core.GenerateConcept</Name>
    </ProjectReference>
    <ProjectReference Include="..\CoreApi2\CoreApi2.Api\CoreApi2.Api.csproj">
      <Project>55466732-A2A7-479D-B4A1-99FB2732DCE6</Project>
      <Name>CoreApi2.Api</Name>
    </ProjectReference>
    <ProjectReference Include="..\CoreApi2\CoreApi2.Model\CoreApi2.Model.csproj">
      <Project>24fba440-a133-4024-87c9-a77d0b7af659</Project>
      <Name>CoreApi2.Model</Name>
    </ProjectReference>
    <ProjectReference Include="..\CoreApi2\CoreApi2.Services\CoreApi2.Services.csproj">
      <Project>d2a117bf-d7e5-4483-bb35-71336b8e8404</Project>
      <Name>CoreApi2.Services</Name>
    </ProjectReference>
    <ProjectReference Include="..\Infrastructure\Informanagement.Infrastructure\Informanagement.Infrastructure.csproj">
      <Project>92C12E85-209B-4F16-BB1E-B1E120EFB4EB</Project>
      <Name>Informanagement.Infrastructure</Name>
    </ProjectReference>
  </ItemGroup>
  <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is 0.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.props'))" />
    <Error Condition="!Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets'))" />
  </Target>
  <Import Project="..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.1.1.11\build\net45\MSTest.TestAdapter.targets')" />
</Project>

我已经破坏了参考:

【问题讨论】:

您是否使用过“NuGet 包还原”?他们甚至提供了如何做到这一点的链接。 NuGet Packages are missing的可能重复 是的,我做了“NuGet 包还原”,但错误仍然存​​在 检查你的 nuget 源 【参考方案1】:

我解决了这个错误,实际上我的包文件夹中有不同版本的 MSTest.TestAdapter(1.3.2) 并且 .csproj 文件引用指向 MSTest.TestAdapter(1.1.0)。 我已将所有 MSTest.TestAdapter(1.1.0) 替换为 MSTest.TestAdapter(1.3.2),这解​​决了我的问题。

【讨论】:

我在维护 c# executable 中 MSTest.TestAdapter 的参考时遇到问题。当我在 VS 中看到该项目时,参考就在那里,但当我查看从该项目创建的可执行文件时,它就丢失了。我开了一个 SO Question 。您上面使用的版本是runtime version 或只是version

无法在 Visual Studio 2017 之外运行 UWP 发布可执行文件

】无法在VisualStudio2017之外运行UWP发布可执行文件【英文标题】:Can\'trunUWPreleaseexecutableoutsideofVisualStudio2017【发布时间】:2018-09-1820:14:26【问题描述】:我在Windows10上使用带有官方UWP示例代码的VisualStudio2017。有一个名为basicinput的... 查看详情

Visual Studio 2017 无法打开现有文件

】VisualStudio2017无法打开现有文件【英文标题】:VisualStudio2017cannotopenexistingfile【发布时间】:2019-03-1818:54:38【问题描述】:所以我有一个vcxproj文件。在那里的某个地方,有这个:<ItemGroup><ClCompileInclude="CMakeCCompilerId.c"/>&l... 查看详情

无法在 Visual Studio 2017 中更改程序集的默认语言

】无法在VisualStudio2017中更改程序集的默认语言【英文标题】:Can\'tchangedefaultlanguageofanassemblyinVisualStudio2017【发布时间】:2017-06-1820:12:06【问题描述】:我的应用程序支持三种语言:en、es和fr。当我构建(干净,从模板)UWP应用... 查看详情

如何修复“无法找到或打开 PDB 文件”。在 Visual Studio 2017 中

】如何修复“无法找到或打开PDB文件”。在VisualStudio2017中【英文标题】:Howtofixthe"CannotfindoropenthePDBfile."inVisualStudio2017【发布时间】:2018-02-0416:07:47【问题描述】:每次我在VisualStudio2017中运行项目时,它都会加载所有dll... 查看详情

无法在 Visual Studio 2017 的共享项目中创建文件夹

】无法在VisualStudio2017的共享项目中创建文件夹【英文标题】:Can\'tcreatefolderinsideSharedprojectinVisualStudio2017【发布时间】:2017-05-3111:52:00【问题描述】:。在位置上下文菜单中,我只看到“新建过滤器”一般情况下是否可以-在这种... 查看详情

无法在 Visual Studio 2017 中构建我的单元测试项目

】无法在VisualStudio2017中构建我的单元测试项目【英文标题】:UnabletobuildMyUnitTestProjectinVisualStudio2017【发布时间】:2018-10-2507:31:38【问题描述】:我在构建解决方案(包括单元测试项目)时遇到此错误。此项目引用了此项目中缺... 查看详情

无法在 Visual Studio 2017 (Native c++) 中禁用数据断点

】无法在VisualStudio2017(Nativec++)中禁用数据断点【英文标题】:Cannotdisabledatabreakpointsinvisualstudio2017(Nativec++)【发布时间】:2018-07-1910:55:46【问题描述】:当我在“断点”窗口中取消选中数据断点时,写入内存时仍然会发生异常。但... 查看详情

无法在 Visual Studio 2017 RC 中添加全局 JavaScript Intellisense 引用

】无法在VisualStudio2017RC中添加全局JavaScriptIntellisense引用【英文标题】:CannotaddaglobalJavaScriptIntellisensereferenceinVisualStudio2017RC【发布时间】:2017-07-1010:19:47【问题描述】:我正在尝试尽可能轻松地从2015年迁移到2017年。我使用的代... 查看详情

无法在 Visual Studio 2017 中调试 Azure 计时器功能

】无法在VisualStudio2017中调试Azure计时器功能【英文标题】:NotabletoDebugAzureTimerFunctioninVisualStudio2017【发布时间】:2018-02-2821:55:35【问题描述】:当我调试定时器功能时,我收到消息(永远)并且无法继续调试...“主机启动的时间... 查看详情

无法在 Visual Studio 2017 中加载 SDK 信息 Android SDK 管理器

】无法在VisualStudio2017中加载SDK信息AndroidSDK管理器【英文标题】:UnabletoLoadSDKInformationAndroidSDKManagerinVisualStudio2017【发布时间】:2018-08-1704:31:31【问题描述】:我正在运行VisualStudioEnterprise2017(版本15.5.7)。我来自公司网络,当我... 查看详情

Visual Studio 2017 - 无法安装 WDK 扩展

】VisualStudio2017-无法安装WDK扩展【英文标题】:VisualStudio2017-Can\'tinstallWDKextension【发布时间】:2019-01-2400:51:02【问题描述】:我正在尝试在VisualStudio2017Enterprise上安装WDK,但我收到一条错误消息,声称它不支持我的版本。WDK本身... 查看详情

在 Visual Studio 2017 上无法使用调试模式 x64 进行 opencv3.2 编译

】在VisualStudio2017上无法使用调试模式x64进行opencv3.2编译【英文标题】:opencv3.2compilationwithdebugmodex64notpossibleonvisualstudio2017【发布时间】:2017-07-2915:38:06【问题描述】:在安装opencv3.2时,如thesesteps和答案here,在使用CMake正确生成op... 查看详情

Visual Studio 2017 无法创建或打开 .shproj(共享项目)文件

】VisualStudio2017无法创建或打开.shproj(共享项目)文件【英文标题】:VisualStudio2017cannotcreateoropen.shproj(sharedProject)files【发布时间】:2018-08-3104:36:30【问题描述】:我最近升级到VisualStudio2017版本15.6.3。这样做后(并修复了许多其... 查看详情

s-s-rS 自定义程序集无法在 Visual Studio 2017 下加载

】s-s-rS自定义程序集无法在VisualStudio2017下加载【英文标题】:s-s-rSCustomAssembliescouldnotbeloadedunderVisualStudio2017【发布时间】:2017-04-2013:05:59【问题描述】:我刚刚安装了VS2017,并将我的s-s-rS项目从VS2015移到了2017。我有一个自定义... 查看详情

无法更新 Visual Studio 安装程序

】无法更新VisualStudio安装程序【英文标题】:Unabletoupdatevisualstudioinstaller【发布时间】:2017-08-2312:06:02【问题描述】:想将此问题添加到池中,以防有人遇到同样的问题我无法在Windows7上更新VisualStudio2017并收到以下错误:无法将... 查看详情

Visual Studio 2017 不链接库

...nux上执行此操作时没有遇到任何问题,但由于某种原因它无法在Windows上运行。这是程序://CMakeProject1.cpp:Definestheentryp 查看详情

Visual Studio 2017 无法使用库构建

】VisualStudio2017无法使用库构建【英文标题】:VisualStudio2017cannotbuildwithalibrary【发布时间】:2017-04-2701:52:09【问题描述】:所以我使用了一个名为MilestoneSDK的库,并按照说明将这个基本库链接到我的程序中。了解图书馆本身并不... 查看详情

在 Visual Studio Express 2017 中运行 python

...它与Community(或更高版本)一起使用,而不是Express。我无法为社区进行更改,您知道是否有解 查看详情