-6

I have a problem with visual studio 2010. It stopped building projects. I had a problem with error:

Error occurred while restoring NuGet packages

I did Solution properties -> Enable NuGet Package Restore And this result that build does not happen. If i click build or rebuild all I get is:

------ Rebuild All started: Project: MyProject, Configuration: Debug Any CPU ------ ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========

I have tried:
- cleaning, rebuilding
- restarting VS
- rebooting
- Tools -> Options -> Projects and Solutions -> Build and Run and set MSBuild project build output verbosity to Normal, Detail, Diagnostic each with zero results. The only output is the one above.

It also finishes immediately, usualy it took some time. What is wrong here? How can I fix it?

UPDATE

I have tried command line build and in the output i find:

D:\MyProject.nuget\NuGet.targets(100,9): error : Could not load type 'System.Runtime.CompilerServices.ExtensionAttribute' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, publicKeyToken=b77a5c561934e089'.

It looks like nuget issue.

f470071
  • 1,527
  • 3
  • 18
  • 30
  • Did you try to reinstall NuGet package? – Alexander Nov 05 '15 at 15:58
  • @Alexander Right now I am thinking about how to avoid nuget. But I did a package update. Some minor version update was offeres. But no change. Still no build. Ad if build does not even start. – f470071 Nov 05 '15 at 16:04
  • You can use [NuGet Package Manager](https://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c) or [Package Manager Console](https://docs.nuget.org/consume/package-manager-console) to uninstall\install packages – Alexander Nov 05 '15 at 16:45
  • What version of .NET are you targeting? Based on the updated error message you provided check out these link http://stackoverflow.com/questions/33565737/how-to-downgrade-nuget-from-2-8-6-to-2-8-5-or-remove-completely and http://stackoverflow.com/questions/20661943/build-on-tfs-2013-failed-but-okay-locally – SoftwareCarpenter Nov 09 '15 at 16:24
  • @SoftwareCarpenter That error in the update was related to NuGet and some mix-up resulting that it looked for ExtensionAttribute in 4.0 assembly, but expectiong it to be found where it is in 4.5 Assembly. This Nuget issue is now fixed. But visual studio still does not build. With no error or warning or any other output. – f470071 Nov 09 '15 at 21:04

2 Answers2

1

NuGet automatic package restore has changed in version 2.7+ see NuGet documentation for restoring packages and new approaches. Also take a look at common issues .

Without knowing all the information of your setup based on the documentation they advise to choose one approach to avoid problems.

Common issues with Automatic Package Restore If you have Nuget 2.7+ installed; it's important to pick one method for managing Automatic Package Restore in Visual Studio.

Two methods are available:

  1. (Nuget 2.7+): Visual Studio -> Tools -> Package Manager -> Package Manager Settings -> Enable Automatic Package Restore

  2. (Nuget 2.6 and below) Right clicking on a solution and clicking "Enable Package Restore for this solution". These are different methods; and have drastically different outcomes for developing with NuGet.

Otherwise look at not having NuGet perform an automatic package restore.


Update based on comment:

The error you are receiving does not give you a lot to work with except that their are known issues if you are using both approaches to restore packages.

Try a couple of things, so you can find the root cause of the problem and resume building your solution.

  • Delete your solution folder locally and get the latest from source control or last known good build. If this is not an option then back up your solution and related folders and look at free version control solutions.
  • The suggestion to delete the packages folder was because NuGet will not find the needed references and make an attempt to get the needed references. Perhaps by deleting the packages folder it will give the exact reference it cannot restore.
  • Verify the way your solution is using package restore and make sure you are only doing one or the other based on the NuGet documentation provided in the link above.
  • Test if you can build another solution that has NuGet or create a simple solution and add one to test.

  • If all else fails remove NuGet and add your references manually. Then start adding back NuGet packages one at a time.

Community
  • 1
  • 1
SoftwareCarpenter
  • 3,835
  • 3
  • 25
  • 37
  • If you cant explain the down vote it makes it hard to answer or help the OP and others. OP never stated he deleted the packages folder before building. – SoftwareCarpenter Nov 05 '15 at 17:37
  • I tried building as it was. I did not delete packages folder but I might try that in near future. At the moment I am totally lost. This turned up with no reason and i dont want to make hasty deletions or stuff. Tnx for your suggestion. – f470071 Nov 05 '15 at 20:23
  • I've upvoted, as the votes on this page look a bit odd, and this answer looks helpful (I don't know the subject area). The OP seems to have gotten a large block of downvotes, but there's no clear reason why. Did the page or the user feature on _Meta_? – halfer Nov 09 '15 at 08:11
  • 1
    @halfer thanks for the vote. I am not sure why others down voted question. I was confused as to why others and I where also getting down votes with reasonable answers just trying to help. The update the OP provided does shed more light into the problem now. – SoftwareCarpenter Nov 09 '15 at 15:33
0

Try to delete the packages folder and rebuild.

sjokkogutten
  • 2,005
  • 2
  • 21
  • 24