Search code examples
.netvisual-studionugetnuget-package-restore

Build error, This project references NuGet


When I try to build my solution, I get the following error message:

Severity Code Description Project File Line Suppression State Error 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 ..\packages\Microsoft.Net.Compilers.1.1.1\build\Microsoft.Net.Compilers.props. MusicKarma C:\Users\Bryan\Documents\Visual Studio 2015\Projects\MusicKarma\MusicKarma.csproj 268

When I look In my packages folder, I can find I file named Microsoft.Net.Compilers.props

I have tried to use Nuget Restore, but it keeps saying that I have all the packages.

This happens when I take this project from TFS to one of my computers.


Solution

  • First I would check if your MusicKarma project has Microsoft.Net.Compilers in its packages.config file. If not then you could remove everything to do with that NuGet package from your MusicKarma.csproj.

    If you are using the Microsoft.Net.Compilers NuGet package then my guess is that the path is incorrect. Looking at the directory name in the error message I would guess that the MusicKarma solution file (.sln) is in the same directory as the MusicKarma.csproj. If so then the packages directory is probably wrong since by default the packages directory would be inside the solution directory. So I am assuming that your packages directory is:

    C:\Users\Bryan\Documents\Visual Studio 2015\Projects\MusicKarma\packages
    

    Whilst your MusicKarma.csproj file is looking for the props file in:

    C:\Users\Bryan\Documents\Visual Studio 2015\Projects\packages\Microsoft.Net.Compilers.1.1.1\build
    

    So if that is the case then you can fix the problem by editing the path in your MusicKarma.csproj file or by reinstalling the NuGet package.