错误 NU1105 无法找到项目信息 - 项目文件可能无效或缺少还原所需的目标 [英] Error NU1105 Unable to find project information - The project file may be invalid or missing targets required for restore

查看:26
本文介绍了错误 NU1105 无法找到项目信息 - 项目文件可能无效或缺少还原所需的目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

突然间,我在一个解决方案中收到了 3 个项目的以下错误:

All of a sudden, I am getting the following errors for 3 projects in a solution:

Error NU1105 Unable to find project information for 'C:\code\example\src\libs\example.I18n\example.I18n.csproj'. 
The project file may be invalid or missing targets required for restore.

项目中唯一改变的是一些数据库更改,但我过去从未遇到任何问题.唯一的另一件事是我更新到了 Visual Studio 2017 15.5.这会导致问题吗?

The only thing that has changed in the project is a couple of DB changes, but I never had any issues in the past. The only other thing is that I updated to Visual Studio 2017 15.5. Could that cause issues?

我尝试从源代码管理中删除并重新克隆解决方案,但仍然出现错误.我同事的机器没有问题,所以肯定是本地的.

I have tried removing and recloning the solution from source control, but still getting errors. No problems on my colleagues' machines, so it must be something local.

.csproj 文件之一的示例(如果有帮助):

Example of one of the .csproj files if this helps:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net452</TargetFramework>
    <AssemblyName>Example.I18n</AssemblyName>
    <PackageId>Example.I18n</PackageId>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="1.1.2" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
    <PackageReference Include="MessageFormat" Version="1.0.1" />
  </ItemGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
    <Reference Include="System" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>

</Project>

推荐答案

对我来说,磁盘上项目文件的大小写与解决方案文件中的大小写不匹配.

For me, the casing of the project file on disk did not match the casing in the solution file.

假设我有一个使用 LibraryA.csprojLibraryB.csproj 的解决方案,其中 LibraryB.csproj 引用了 LibraryA.csproj.在构建 LibraryB.csproj 时,解决方案文件中 LibraryA.csproj 的大小写不正确会导致 NU1105:

Say I had a solution with LibraryA.csproj and LibraryB.csproj, where LibraryB.csproj has a reference to LibraryA.csproj. Having an incorrect casing for LibraryA.csproj in the solution file would cause NU1105 when building LibraryB.csproj:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibraryA", "LibraryA\Librarya.csproj", "{24DEBB3B-762A-491D-8B83-6D078C0B30C0}"

我在升级到 Visual Studio 2017 15.5 版本后开始看到这个问题.我在 15.4.5 版本中没有遇到这个问题.

I started seeing this problem after upgrading to version 15.5 of Visual Studio 2017. I did not encounter this problem with version 15.4.5.

这篇关于错误 NU1105 无法找到项目信息 - 项目文件可能无效或缺少还原所需的目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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