Compilation error requiring install Microsoft.Bcl.Build. How to install nuget package Microsoft.Bcl.Build on a unit test project - visual-studio-2013

I have a vs2013 solution with 2 projects in NET 4.0, let's say project A and project B. Project B has a reference to project A. When I compile project B I get a compilation error saying:
All projects referencing ProjectA.csproj must install nuget package Microsoft.Bcl.Build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317569.
To install nuget package on project B I select project B in solution explorer, then I open a nuget console and type below command:
Install-Package Microsoft.Bcl.Build -Version 1.0.21
but it seems it is not installing it on project B. What am I doing wrong?

Related

The type 'xct:TabView' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built

I'm getting the error of the tittle when trying to use XCT TabView.
I'm using Microsoft Visual Studio Community 2022. I installed XCT in my project by running both the commands in NuGet Package Manager Console:
Install-Package Xamarin.CommunityToolkit
Install-Package Xamarin.CommunityToolkit.Markup
In NuGet solution manager I selected both packages, I checked every checkbook responding to my projects and I hit "Install".
I get the following errors and warnings though:
Package restore failed. Rolling back package changes for 'MyProject'.
and
Error NU1605 Detected package downgrade: Xamarin.Forms from 5.0.0.2291 to 5.0.0.2196. Reference the package directly from the project to select a different version.
MyProject -> Xamarin.CommunityToolkit.Markup 2.0.0 -> Xamarin.Forms (>= 5.0.0.2291)
MyProject -> Xamarin.Forms (>= 5.0.0.2196)
I also added the relative namespace to XAML: xmlns:xct="http://xamarin.com/schemas/2020/toolkit
By the way, I get the same error too for xct:TabViewItem but I additionally get another error for it: Cannot resolve type "xct:TabViewItem"
Any ideas?
I had tried to do this and met the same problem as you.
This issue happened because the version of xamarin.forms is too low. So you can open the nuget package manager to update the xamarin.forms to the lastest version.
You can also download the earlier version of the Xamarin.CommunityToolkit and Xamarin.CommunityToolkit.Markup such as 1.3.1

The specified task executable location ......csc.exe is invalid error

I have a project on TFS that is working on everyone else's machine, except mine. When building I get the error that can be seen in the image. "The specified task executable location csc.exe is invalid." currently trying to repair VS 2017 now.
Based on the message, seems the csc.exe is damaged.
Just try below things to narrow down the issue:
Navigate to the Microsoft.Net.Compilers package location, delete
the package folder, then rebuild. Generally the package will be
restored automatically during the build.
YOUR_PROJECT_DIR\packages\Microsoft.Net.Compilers.2.6.1
Uninstall and Re-install the Microsoft.Net.Compilers package:
Open Visual Studio
Go to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution
Go to Installed tab and find Microsoft.Net.Compilers package
Uninstall the package from your project
Try to build your project now. (Thus it will use the default compiler which lives in the .NET framework folder:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe)
If you really need the Microsoft.Net.Compilers package then go ahead and find it in the Browse tab and install the latest stable
version.
Build the project and if everything works, make sure you commit changes to your code repository.
You can also try to run below command to uninstall and reinstall the
Nuget packages from the Package Manager Console: See Microsoft.Net.Compilers
Uninstall-Package Microsoft.Net.Compilers -Version 2.6.1
Install-Package Microsoft.Net.Compilers -Version 2.6.1
Remove Microsoft.CodeDom.Providers.DotNetCompilerPlatform and Microsoft.Net.Compilers Nuget Packages.
Installing MSBuild 2015 will resolve the issue.
https://www.microsoft.com/en-us/download/confirmation.aspx?id=48159
I hit this question even though my error was "The specified task executable csc.exe could not be run" when pulling down existing web project with unit tests and trying to run it locally for the first time.
I was able to resolve this by building each project individually in my solution.

Nuget Packager task - dependency is not added

I'm using Visual Studio Team Services to automate the creation of a nuget package. This package has a dependency on another nuget package (Newtonsoft.Json v8.0.3). I have configured a Nuget Packager task as part of the build:
But the generated package doesn't contain the reference to the nuget package:
Running the following script on my local machine to generate the package:
nuget pack myproject.csproj -Symbols -IncludeReferencedProjects -Properties Configuration=Release -OutputDirectory bin/Release
I can see that the dependency is added to the generated package:
What am I missing here? Why the dependencies are not being added to to package that is being generated on the build server?
"IncludeReferencedProjects" is used to add the referenced project to the nuget package, not the referenced nuget packages.
Include referenced projects either as dependencies or as part of the
package. If a referenced project has a corresponding nuspec file that
has the same name as the project, then that referenced project is
added as a dependency. Otherwise, the referenced project is added as
part of the package. Learn more at NuGet.org.
When you create the nuget package for the project which referenced to another nuget package. The nuget package dependency will be added automatically if the nupkg file exists in the packages folder. For your issue, you can add a "NuGet Installer" task in your build definition to restore the nuget package files for your solution. And then when you create the nuget package for your project, the referenced nuget package will be added as dependency.
I have found a solution for my problem, even though I don't understand why the package was not being created properly.
So basically I have 2 builds:
a "generic" build that will compile the entire solution and run unit tests, etc (automatic, triggered on commit)
a build to generate the nuget package (manual)
This problem is on the 2nd build. I was trying to understand what were the differences between creating the package manually on my local machine and creating the package on the build server and I realized that on the build server I was not getting the source code for the solution, only for the project folder and the .nuget folder. Given that I have more than 40 projects in the solution it makes no sense to get the whole source code for the 2nd build, right? But for some reason this is not enough to generate the nuget package properly.
So, the solution to my problem was to get the source code for the following files/folders:
Project folder
.nuget folder (needed when restoring/installing the missing packages)
Solution file (mysolution.sln)

Why can't I install Ninject 3.2.2 if my project targets MonoAndroid,Version=v5.1?

When installing Ninject I get this log from the Output in VS2015:
Attempting to gather dependencies information for package 'Ninject.3.2.2' with respect to project 'ProjectPhoenix.Droid', targeting 'MonoAndroid,Version=v5.1'
Attempting to resolve dependencies for package 'Ninject.3.2.2' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Ninject.3.2.2'
Resolved actions to install package 'Ninject.3.2.2'
Attempting to gather dependencies information for package 'Ninject.3.2.2' with respect to project 'ProjectPhoenix.iOS', targeting 'Xamarin.iOS,Version=v1.0'
Attempting to resolve dependencies for package 'Ninject.3.2.2' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Ninject.3.2.2'
Resolved actions to install package 'Ninject.3.2.2'
For adding package 'Ninject.3.2.2' to project 'ProjectPhoenix.Droid' that targets 'monoandroid51'.
Install failed. Rolling back...
Package 'Ninject 3.2.2.0' does not exist in project 'ProjectPhoenix.Droid'
Could not install package 'Ninject 3.2.2'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v5.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
========== Finished ==========
I'm working on Xamarin and the same project runs great on Xamarin Studio and other instances of Visual Studio 2015, so I know this is a problem not with the code but with my configuration.
I believe what you're asking is answered here in this other SO question:
How come there's no IKernel implementation in Ninject.Portable
Ninject needs platform specific code to work in each Xamarin Platform, so, for a Xamarin project I would suggest you use the Ninject.Portable NuGet package instead of the plain Ninject one. You also need to install the NuGet in Droid, iOS, Tests and UITests projects to be able to compile all the Solution.
Best Regards

How do I install a NuGet package into the second project in a solution?

I'm currently working on a solution that initially contained one project (My.First.Project.Name). I've installed Castle Windsor by executing:
Install-Package Castle.Windsor
I've just added another project (My.Second.Project.Name) to the solution and want to install Castle Windsor into this project also, but when I run Install-Package Castle.Windsor again, I get the error:
'Castle.Core 2.5.2' already installed
'Castle.Windsor 2.5.2' already installed
My.First.Project.Name already has a reference to 'Castle.Core 2.5.2'
My.First.Project.Name already has a reference to 'Castle.Windsor 2.5.2'
So my question is: How do I persuade the NuGet Package Manager to install the package into the second project?
There's 3 approaches :).
In NuGet 1.1 (The latest release) we've improved powershell pipelining so you can do this:
Get-Project -All | Install-Package SomePackage
That will install "SomePackage" into all of your projects. You can use wildcards to narrow down which projects:
Get-Project Mvc* | Install-Package SomePackage
That will use wildcard semantics (in this case, find all projects that start with mvc).
Get-Project SomeProject | Install-Package SomePackage
That will install SomePackage into SomeProject and nothing else.
There's two approaches.
As you already learned, the Package Manager Console has a drop down that lists the projects in your solution.
The other approach is to use the -Project flag. Nice thing about that is it gives you Intellisense with the project names! For example:
Install-Package SomePackage -Project MvcApplication2
The answer is, embarassingly, blindlingly simple.
The "Package Manager Console" has a drop-down titled "Default Project" in its toolbar, changing the project there to My.Second.Project.Name then allows Install-Package Castle.Windsor to install the package into the second project.
In Visual Studio 2015 (as of Nuget v3.1.2) the syntax is now:
Install-Package ThePackage -ProjectName YourProjectName
Note: -ProjectName vs -Project
In Visual Studio, you can go to Tools -> NuGet Package Manager -> Manage NuGet Packages for the entire Solution. From there, select the Nuget Package you want to share between projects and click Manage. This will allow you to add a specific installed NuGet Package to whichever other projects you want.
If you just need to copy packages from existing project to the new one, just copy and/or modify packages.config file to the new project and run Update-Package -reinstall -Project YourProjectName
There is also the option to force a reinstall. With certain problems, this helped me.
Update-Package Microsoft.Owin -Reinstall

Resources