Error NU1105 Unable to find project information - The project file may be invalid or missing targets required for restore

Visual StudioNugetVisual Studio-2017CsprojNuget Package-Restore

Visual Studio Problem Overview


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.

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.

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>

Visual Studio Solutions


Solution 1 - Visual Studio

I also got the same after upgrading to version 15.6 of Visual Studio 2017.

Closing VS and deleting the .vs folder fixed it for me.

Solution 2 - Visual Studio

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

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}"

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.

Solution 3 - Visual Studio

This error message will also occur if a referenced project is not included in the solution. I encountered this problem today, and I found the fix here.

Solution 4 - Visual Studio

I had this problem and I just followed what the error message recommends inside VS:
to restore the solution.

So I opened a command line or package manager console, chdir into the directory with the solution (.sln) file and just issued

> C:> dotnet restore .\mySolution.sln

Problem was fixed.

Solution 5 - Visual Studio

I encountered this error when having a duplicate reference to a project.

<ProjectReference Include="..\ProjectA.csproj" />
<ProjectReference Include="..\ProjectA.csproj" />

Removing the duplicate reference resolved the error.

Solution 6 - Visual Studio

What worked for me was to

  1. Remove the offending project
  2. Build the solution
  3. Re-add the project.

Solution 7 - Visual Studio

Seems that some projects were removed from solution file (don't know why). Fixed by undoing these solution file changes

Solution 8 - Visual Studio

I have next project structure (.Net Core projects):

../classLib
../../../webProject1
../../../webProject2
../../myWebProjects.sln

webProject1 and webProject2 reference classLib as project itself (not as .dll). When I opened my solution in VS 2019 and tried to build I got identical error NU1105: Unable to find project information for '../classLib.csproj'. error.

Before build depended projects you need to restore there dependency. What I did, just add next Target to my webProject1.csproj and webProject2.csprojfiles.

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
    <Exec Command="dotnet restore" />
</Target>

Solution 9 - Visual Studio

I recently came across Error NU1105 while using JetBrains Rider on Linux. So this involves Mono and the MSBuild version that comes with it.

It turns out this was being caused by my solution files being in a directory that was a symbolic link to another directory. I believe MSBuild was dereferencing the linked directory and instead referencing the source directory. This makes some of the referenced paths completely different, even though they are the exact same files, case, everything else. Opening the solution from the original location works perfectly now for me.

Solution 10 - Visual Studio

Reload the project which causes the problem, this will fix the issue,

As mentioned in the following link :

https://docs.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu1105

Solution 11 - Visual Studio

I correct this error by simply running the clean solution option. Right click the solution in the solution explorer and choose clean solution.

Solution 12 - Visual Studio

This is insane, i tried all this: updated VS. manually deleted all bin folders, run dotnet restore, clean rebuild nothing works

solution: finally i unload all the projects and start reloading them into solution, one by one in the order they show dependency errors. then the last one just cascade fixes everything. No idea what was wrong

Solution 13 - Visual Studio

I was getting this error error NU1105: Unable to find project information for 'C:\folder2\project1.csproj'. but project1 that I had as part of the solution was located in C:\folder1\project1.csproj (it was also there in c:\folder2\project1.csproj too but not part of the solution, so it was confusing) Once I changed the reference to the correct location of the project it worked.

Solution 14 - Visual Studio

After spending 3 hours, trying out numerous solutions, what worked for me is that I had to undo my root solution sln file...some of the project references were removed..not sure how.

Solution 15 - Visual Studio

This happend to me when I had files with names exceeding OS's max path limit. Check your names ;)

Solution 16 - Visual Studio

In my case I did it and it worked for me

  1. goto Tools/CommandLine/Developer Command Prompt or Developer Powershell
  2. type this command and Enter "dotnet restore".
  3. Build your solution

That's all

Solution 17 - Visual Studio

Open powershell and running restore command solved my issue.

dotnet restore Sample.sln

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPaolo BView Question on Stackoverflow
Solution 1 - Visual StudioAlexandre BriseboisView Answer on Stackoverflow
Solution 2 - Visual StudioChrisView Answer on Stackoverflow
Solution 3 - Visual StudioTyson WilliamsView Answer on Stackoverflow
Solution 4 - Visual StudioAlberto TrentadueView Answer on Stackoverflow
Solution 5 - Visual StudioAdamView Answer on Stackoverflow
Solution 6 - Visual StudioKevin BrydonView Answer on Stackoverflow
Solution 7 - Visual StudioFindOutIslamNowView Answer on Stackoverflow
Solution 8 - Visual StudioitimView Answer on Stackoverflow
Solution 9 - Visual StudioWilView Answer on Stackoverflow
Solution 10 - Visual StudioAlexander Immanuel DView Answer on Stackoverflow
Solution 11 - Visual StudioJessica Downum View Answer on Stackoverflow
Solution 12 - Visual StudioUrmoView Answer on Stackoverflow
Solution 13 - Visual StudioRajView Answer on Stackoverflow
Solution 14 - Visual Studiouser2948533View Answer on Stackoverflow
Solution 15 - Visual Studioed22View Answer on Stackoverflow
Solution 16 - Visual StudioMohammad RajabiView Answer on Stackoverflow
Solution 17 - Visual StudioGokce DemirView Answer on Stackoverflow