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

27

92

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>
Chiton answered 7/12, 2017 at 12:47 Comment(1)
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.Vierra
O
26

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.

Obrien answered 10/12, 2017 at 23:18 Comment(2)
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.Stratagem
Worked for me. More info on this fix, and related problems, here: github.com/NuGet/Home/issues/5350 .Width
J
104

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.

Jobe answered 11/12, 2017 at 19:11 Comment(5)
My projects don't have a .vs folder, but closing and reopening VS worked. "Have you tried turning it off and on again?"Transpacific
@Transpacific it's a hidden folder. Maybe you have you to enable the view setting for it and the extension view too.According
@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)Transpacific
I had 2 csproj'es referencing different versions of a diamond dependency. Updated referenced version numbers to all be the same and voila!Subscript
Note: this will remove the details about all the debug points and opened files.Delocalize
T
46

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.

Troytroyer answered 27/1, 2021 at 18:29 Comment(1)
This did the job for me. Thank you very muchLeipzig
O
26

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.

Obrien answered 10/12, 2017 at 23:18 Comment(2)
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.Stratagem
Worked for me. More info on this fix, and related problems, here: github.com/NuGet/Home/issues/5350 .Width
N
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.

Nims answered 27/7, 2018 at 1:10 Comment(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. ThxAgraphia
C
13

Open powershell and running restore command solved my issue.

dotnet restore Sample.sln
Crosscountry answered 1/2, 2022 at 11:18 Comment(0)
R
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.

Raffinose answered 23/8, 2018 at 21:47 Comment(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 complainBoak
T
5

What worked for me was to

  1. Remove the offending project
  2. Build the solution
  3. Re-add the project.
Tetrastichous answered 6/9, 2018 at 22:46 Comment(0)
F
3

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

Faxun answered 11/7, 2018 at 10:56 Comment(0)
A
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>
Acquiescence answered 9/7, 2019 at 10:42 Comment(1)
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)Shiloh
B
2

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

Birr answered 19/10, 2020 at 13:31 Comment(1)
In my case, cleaning helped out, while "dotnet restore" did not.Varini
D
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

Durand answered 23/9, 2021 at 11:55 Comment(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.Aigneis
W
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

Waterworks answered 4/1, 2022 at 15:0 Comment(0)
R
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.

Razee answered 5/4, 2020 at 18:55 Comment(0)
H
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

Hwang answered 14/8, 2020 at 4:43 Comment(0)
B
1

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

Bernal answered 12/12, 2021 at 18:20 Comment(0)
H
1

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

Hartle answered 6/10, 2022 at 8:55 Comment(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.Aigneis
R
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.

Rhodarhodamine answered 25/2, 2023 at 15:59 Comment(0)
D
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.

Demonology answered 22/5, 2023 at 15:24 Comment(1)
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)Brendon
C
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.

Condensed answered 27/8, 2020 at 23:29 Comment(0)
H
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.

Haswell answered 11/11, 2021 at 6:11 Comment(0)
F
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.

Fuliginous answered 27/6, 2023 at 19:33 Comment(0)
H
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.

Honorarium answered 8/8, 2023 at 18:23 Comment(0)
E
0

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

Emelina answered 9/8, 2023 at 5:49 Comment(0)
O
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.
Offoffbroadway answered 22/8, 2023 at 8:45 Comment(0)
E
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
Earwig answered 1/9, 2023 at 21:45 Comment(0)
B
0

In my case, the .csproj file existed, but there was an error that it could not be found. I used an editor like Notepad++ to open up the .sln file and found the reference to the .csproj file and edited it to point to the file. Saved it and double clicked the .sln file and it worked.

Backstretch answered 10/10, 2023 at 18:57 Comment(0)
G
0

My fix, and note that I did not have to delete or restore anything:

  1. Closed/reopened Visual Studio and reopened the project.
  2. Build/Clean Solution.
  3. Build/Rebuild Solution.

That was it – error was gone.

Goggler answered 17/6 at 15:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.