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.
Quick solution that worked like a charm for me and others:
If you are using VS 2015+, just remove the following lines from the .csproj file of your project:
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> </Target>
In VS 2015+ Solution Explorer:
This problem appeared for me when I was creating folders in the filesystem (not in my solution) and moved some projects around.
Turns out that the package paths are relative from the csproj files. So I had to change the "HintPath" of my references:
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> <HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath> <Private>True</Private> </Reference>
To:
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> <HintPath>..\..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath> <Private>True</Private> </Reference>
Notice the double "..\" in 'HintPath'.
I also had to change my error conditions, for example I had to change:
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.1.1\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.1.1\build\Microsoft.Net.Compilers.props'))" />
To:
<Error Condition="!Exists('..\..\packages\Microsoft.Net.Compilers.1.1.1\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Net.Compilers.1.1.1\build\Microsoft.Net.Compilers.props'))" />
Again, notice the double "..\".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With