79

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>
Pang
  • 9,564
  • 146
  • 81
  • 122
Paolo B
  • 3,026
  • 5
  • 21
  • 43
  • Please check the path of example.I18n.csproj on your local machine to make sure it exist in "C:\code\example\src\libs\example.I18n" first. And then please check the logs in Output window, whether there has any logs about package restore error. In addition, please clear your local NuGet package caches and restore again. – Weiwei Dec 08 '17 at 01:49

25 Answers25

97

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.

Alexandre Brisebois
  • 6,599
  • 12
  • 50
  • 69
  • 2
    My projects don't have a .vs folder, but closing and reopening VS worked. "Have you tried turning it off and on again?" – emery.noel Dec 20 '18 at 19:55
  • 2
    @emery.noel it's a hidden folder. Maybe you have you to enable the view setting for it and the extension view too. – Tito Leiva Mar 11 '19 at 07:23
  • 2
    @TitoLeiva - I can see the hidden folders. But the vs folder is at the solution level, not the project level (I was looking in the wrong place) – emery.noel Mar 14 '19 at 16:27
  • I had 2 csproj'es referencing different versions of a diamond dependency. Updated referenced version numbers to all be the same and voila! – user7817808 Jan 15 '21 at 19:01
30

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.

Matt
  • 25,467
  • 18
  • 120
  • 187
25

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.

Chris
  • 533
  • 12
  • 19
  • 1
    A too had LibraryB referencing LibraryA and the error was reported on *LibraryB*. Although it was reported as issue with nuget packages of LibraryB, I had to remove and add LibraryA to the solution. Neither project name, nor the problem was described correctly in the error message. – Liero Jan 10 '18 at 11:06
  • 1
    Worked for me. More info on this fix, and related problems, here: https://github.com/NuGet/Home/issues/5350 . – crimbo Jan 16 '18 at 23:47
18

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.

Tyson Williams
  • 1,630
  • 15
  • 35
  • 1
    In the project that does not build, expand the Projects section under Dependencies. In my case to the problem was due to a project that was not present in the solution but still being referenced there. The error message could be a bit more explicit though. Thx – pasx Jun 30 '20 at 13:39
7

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.

Pang
  • 9,564
  • 146
  • 81
  • 122
Adam
  • 4,180
  • 2
  • 27
  • 31
  • 1
    Solved my issue. Especially in Rider this can occur also if a DLL containing a Shrared Project is referenced and the Shared Project itself is listed too, which is inconsistent but Visual Studio doesn't complain – Kay Jul 30 '19 at 09:22
5

What worked for me was to

  1. Remove the offending project
  2. Build the solution
  3. Re-add the project.
Kevin Brydon
  • 12,524
  • 8
  • 46
  • 76
4

Open powershell and running restore command solved my issue.

dotnet restore Sample.sln
Gokce Demir
  • 459
  • 4
  • 5
3

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

FindOutIslamNow
  • 1,169
  • 1
  • 14
  • 33
3

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>
Pang
  • 9,564
  • 146
  • 81
  • 122
itim
  • 377
  • 3
  • 9
  • Note that to add in pre-build commands without editing the csProj file directly, you can right click on the project in the solution exdlorer->properties->Build Events->enter command (e.g. dotnet resore) – Jack Jan 27 '20 at 01:34
2

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

2

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

Urmo
  • 21
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 23 '21 at 12:40
2

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

1

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.

Wil
  • 11
  • 1
1

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

As mentioned in the following link :

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

1

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

ed22
  • 1,127
  • 2
  • 14
  • 30
1

Just use: "dotnet restore MySolution.sln", Where MySolution.sln is your solution.

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 12 '22 at 16:40
1

I recently had this issue with the latest version of rider. I knew that the project reference was correct, because I have another solution pointing to it and that project is building just fine.

I ended up opening the console in rider and running 'dotnet build' manually. After that build succeeded, the rider ui-based build function stopped giving me this error.

1

In my case I needed a reference to another project that is not part of the module's solution (We're using the ABP Framework - so referencing the *.shared project in the host's solution)

Here's what worked for me:

  1. Clean your solution(s)
  2. Close Visual Studio and delete the .vs folder(s)
  3. Add the reference to the .csproj file
  4. Rebuild the referenced .csproj project first
  5. Then rebuild the project that contains the reference
  6. If you still get this error, I've also opened up a terminal and ran the dotnet build command.

I hope this helps someone.

  • opening the referenced project and building it first, and building the containing project afterwards worked for me. Thanks. Trying to build the referenced project from inside the containing project simply didnt work (even though the option is there, error nu1105 always occur) – TonyCruze Jun 16 '23 at 23:19
0

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.

Raj
  • 1
0

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.

user2948533
  • 1,143
  • 3
  • 13
  • 32
0

For me it was that there was a transitive dependency in Solution A from a shared project B to another shared project C which was not added to the solution. When the referenced project C was added to solution, the problem was fixed. The problem was not arising in Solution A before due to the fact that the library B had been always compiled in another solution D where the project C had been added. The problem had arisen because I cloned all projects fresh from git on new PC where none of these have been compiled before.

A: B -> C

D: B -> C

Short: make sure that the project which raises the error is added to the current solution.

user3625699
  • 147
  • 1
  • 9
0

I had same issue and tried suggestions posted here, if reloading the solution and then unload a project in a solution but didn't work. Then I tried removing Projects from .csprj, compiled one more time and added in dependencies as a assembly instead of Projects. Worked for me.

0

For me I had added wrong path in <ProjectReference Include=" for my *.csproj file. As I added correct path the problem was fixed.

muhammad tayyab
  • 727
  • 7
  • 18
0

Not mentioned in other answers:

I faced this issue with a project having <ProjectReference> items - but those projects were not compiled. Compiling them solved the issue.

  • Naturally, VS should have displayed an error indicating it can't find the dlls, but it instead displayed an error saying it can't find the csproj files, which is false.
OfirD
  • 9,442
  • 5
  • 47
  • 90
0

I fixed this by doing the following: -> Solution explorer -> right click on Solution -> Properties -> Configuration Properties:

  • In the list, search the project that is generating this error (the one that references not the one referenced)
  • Check the build box and click Apply (If it's checked already then uncheck & apply, then check & apply)
  • restart Visual Studio & Build