NuGet Package restore failed for project PROJECT: Unable to find version 2.0.0 of package ‘Microsoft.Net.Compilers’

Based on your error message looks like you are looking for a version that no longer exists and cannot tell which Package source you have selected. I feel like you are looking for version 2.0.0 which is not available in nuget.org repository. The latest one is 2.0.0-rc and it is pre release candidate.

Please try this command if you want to get the latest version

Install-Package -Id Microsoft.Net.Compilers -Version 2.0.0-rc -Source nuget.org

If you want the latest stable version (1.3.2), try this command

Install-Package -Id Microsoft.Net.Compilers -Version 1.3.2 -Source nuget.org

UPDATE
If the package still cannot be installed, then that package may be out of sync between packages.config, packages/ folder and .csproj file

Please follow these steps to perform manual cleanup

  1. Close visual studio.
  2. Open .csproj in a notepad or some text editor and manually remove all entries related to Microsoft.Net.Compilers
  3. Open packages.config in a notepad or some text editor and and remove entry for the Microsoft.Net.Compilers package
  4. Go to packages/ folder in windows explorer and delete the Microsoft.Net.Compilers folder
  5. Now start the visual studio and open the solution.
  6. Now try to install the package again.

Some of the entries that you may have to remove from .csproj as part of step 2 are these

<Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />

<NuGetPackageImportStamp></NuGetPackageImportStamp>

<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('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props'))" />
</Target>

Leave a Comment

tech