All projects referencing sub-project must install NuGet package Microsoft.Bcl.Build (C#/Windows Phone 7)?

18,982

Solution 1

In case anyone else comes across this and @Swell's solution made you go "wtf":

I recently went through an older MVC project and updated it (updated razor, asp, http, etc. nuget packages). The project, independent of itself, built fine, but when i went to publish it failed with the OP's errors.

It turns out it's because I didn't update the *.Tests project associated with it (should have figured, though not sure why Tests is that closely tied to the project). So, to fix:

  1. Right-click the Solution and manage nuget packages.
  2. Go through all the packages that were updated in the web project and apply them to the other projects as well (each "Update" will display a tree with the applicable projects, I was fine just OKAY-clicking through).
  3. Rebuild.

You should now be good and it shouldn't bark at you. Hope that helps others.

Solution 2

I just came throught the same issue and a bug is opened here: http://nuget.codeplex.com/workitem/3268

What I've done is the following, I added to the solution level the package Microsoft.Bcl.Build

In my dev env if you don't have the package loaded, just right click the solution and select manage nuget packages, you see a yellow bar with a restore button, just click it and you will be fine.

In my build script before compiling the project I run this command:

.\myproject\.nuget\NuGet.exe install .\myproject\.nuget\packages.config -OutputDirectory .\myproject\packages

This will restore solution level packages and you will be fine.

This should be fixed by the end of this summer in version 2.7 according to the issue report

Share:
18,982

Related videos on Youtube

Robert Oschler
Author by

Robert Oschler

Newly minted, avid Windows Phone developer with a passion for natural language processing apps that leverage Azure for a complete, intelligent, mobile client platofrm. Also a devout robotics enthusiast and consumer EEG headset applicaitons developer (Emotiv EPOC headset).

Updated on June 18, 2022

Comments

  • Robert Oschler
    Robert Oschler almost 2 years

    I'm having a particularly difficult refactoring session involving a C# solution with multiple projects in Visual Studio 2012. I needed to pull out a bunch of code into their own assemblies so that code could be shared across several projects, all in the same solution. However, no matter what I try, I get warnings for the projects that reference the new shared projects that "All projects referencing {shared project name} must install nuget package Microsoft.Bcl.Build".

    I have been over the dependent projects and the shared projects with a fine-tooth comb, verifying in detail that they all use the same version and exact same DLL for the Microsoft.Bcl version 1.0.1.19 and Microsoft.Bcl.Async version 1.0.16 packages:

    • System.Runtime
    • System.Threading.Tasks

    • Microsoft.Threading.Task

    • Microsoft.Threading.Tasks.Extensions
    • Microsoft.Threading.Tasks.Extensions.Phone

    The DLL paths are all resolved and identical. The XAP file does build but I still get that warning telling me that Microsoft.Bcl.Build is not referenced in the dependent projects, despite the fact that I can see that it is.

    If I try instead to uninstall and then reinstall those two packages using NuGet for each project involved, I get references with empty paths and the warning icon for the 5 DLL references involved. For some reason NuGet adds the references but can't find the DLLs. Also, if I do this, I find myself with the problem frequently of having projects where I get the "Can't add reference" error when trying to add a reference. Then I have close and re-open the solution, and that leads to a "project failed to load" error. So I have to edit the project file manually, remove the faulty package import statements, and reload the project.

    How can I fix this problem and what is the general technique for avoiding this headache in the future? Letting NuGet manage missing packages didn't help at al.

  • Bob.at.Indigo.Health
    Bob.at.Indigo.Health almost 11 years
    I just updated NuGet packages in my App, and now I get the same warning message about needing to install Microsoft.Bcl.Build. I don't know what this whole "restore" thing is that is being discussed. I don't see any sign of a "yellow bar with a restore button". My solution contains an Azure deployment project that references the main project, but the Visual Studio 2012 UI doesn't provide a context menu option to manage NuGet packages for that project. Any thoughts or suggestions?
  • JuChom
    JuChom almost 11 years
    @Bob.at.SBS close VS. In file explorer, open your solution folder, go into your .nuget folder and edit your packages.config. Add this line <package id="Microsoft.Bcl.Build" version="1.0.7" targetFramework="net45" /> in the packages node. Now, reopen your solution and right click on your solution -> Manage Nuget Packages for solution. The yellow bar will appear.
  • JuChom
    JuChom almost 11 years
    To complete my answer, Microsoft.Bcl.Build is a target file, VS asks it for loading your project. When you hit restore, it will restore the package and you will be able to reload missing projects!
  • Bob.at.Indigo.Health
    Bob.at.Indigo.Health almost 11 years
    I don't have a .nuget folder in my solution folder (or anywhere under that folder tree). Each of my project folders (except for the Azure project folder) contains a packages.config file. The Azure project folder contains some cryptic subfolders that contain packages.config files.
  • JuChom
    JuChom almost 11 years
    Have you enabled package restore for your solution?
  • Bob.at.Indigo.Health
    Bob.at.Indigo.Health almost 11 years
    I enabled package restore, which got me the .nuget folder, but that folder doesn't contain a packages.config file. I've created a new SO question for my issue (stackoverflow.com/questions/17180268/…).
  • JuChom
    JuChom almost 11 years
    Oops, you're right this files is created when you add package to solution level... Create this file and paste this in it: <?xml version="1.0" encoding="utf-8"?> <packages> <package id="Microsoft.Bcl.Build" version="1.0.7" targetFramework="net45" /> </packages>
  • Bob.at.Indigo.Health
    Bob.at.Indigo.Health almost 11 years
    Ok, so now I have a .nuget folder that was created when I right-clicked the solution and enabled package restore. In that folder, I've added a packages.config file with the requisite <package> entry. No yellow bar in the Manage NuGet Packages window. Rebuild All still emits the warning. I added the new packages.config to the solution (right-clicked on the .nuget folder in solution explorer and selected Add Existing File. Didn't help.
  • JuChom
    JuChom almost 11 years
    An issue is opened for your problem check here: connect.microsoft.com/VisualStudio/feedback/details/789839/…
  • Jamie R Rytlewski
    Jamie R Rytlewski almost 11 years
    Similar to the above command, but my packages.config was not in the .nuget folder. Try this. nuget install .{projectname}\packages.config -OutputDirect packages This worked great for us.
  • JuChom
    JuChom almost 11 years
    My answer solves the nuget package restore problem and load project failed problem.

Related