Nuget cannot restore Microsoft.Net.Compilers.1.0.0
In my case I had downloaded a project from GitHub which did not include the full sln, but was just a single folder with .csproj and packages folder on the same level.
In this case I simply had to replace "..\packages\" with ".\packages\" in the .csproj file. I assume the owner of the GitHub repo decided to only upload the project folder, but didn't recompile to test before uploading... maybe?
@LP13's answer got me pointed into the correct direction. Although I had to do something different.
My .csproj file have 2 references to Microsoft.Net.Compliers. One for 2.9.0 (current one I'm using) and 1.2.1 (old version).
At the top of the file I commented out the 2 Import Project lines that referenced:
Import Project=".\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1 ...
Import Project=".\packages\Microsoft.Net.Compilers.1.2.1 ...
At the bottom of the file, do the same in the Error Condition entries for the same refrences:
- Error Condition="!Exists('.\packages\Microsoft.Net.Compilers.1.2.1...
- Error Condition="!Exists('.\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.1' ...
Since setting the Package Management Format to PackageReference installs the packages to global nuger folder that is C:\Users\{username}\.nuget\packages
i had to edit csproj file update the following lines
top of csproj
<Import Project="$(UserProfile)\.nuget\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform\1.0.7\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('$(UserProfile)\.nuget\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform\1.0.7\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="$(UserProfile)\.nuget\packages\Microsoft.Net.Compilers\2.1.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.1.0\build\Microsoft.Net.Compilers.props')" />
and then update the following lines at the bottom of csproj
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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 {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(UserProfile)\.nuget\packages\Microsoft.Net.Compilers\2.1.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '$(UserProfile)\.nuget\packages\Microsoft.Net.Compilers\2.1.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('$(UserProfile)\.nuget\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform\1.0.7\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '$(UserProfile)\.nuget\packages\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform\1.0.7\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>
All of this is just to reference NET Standard 1.4
project into .NET 4.6.2. very annoying!!