How to ensure TFS build server gets updated Nuget packages - asp.net-mvc

I have an ASP.NET MVC website that was using the pre-release bits of Application Insights. I used the 'Manage Nuget Packages' option on the website to upgrade Application Insights to the latest version. Everything builds and runs successfully locally. All the App. Insights DLLs have been updated to v1.1.0. However when I try to run a gated build on TFS to check these changes in I keep getting the following error:
This project references NuGet package(s) that are missing on this
computer(here it's pointing to the build server). Enable NuGet Package
Restore to download them. For more information, see
http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is
....\packages\Microsoft.ApplicationInsights.Agent.Intercept.0.17.0\build\Microsoft.ApplicationInsights.Agent.Intercept.targets.
This only happens when the gated build runs on trying to check in. It results in the gated build failing which rejects my checking.
Is there anything that I can do here?

Looking at the error i believe , you have not enabled automatic package restore option.
please enable this option to resolve the error , while nuget restore works.
Steps to enable :
Click on Tools -> Nuget Package Manager -> Package Manager Settings -->general --> check the option Automatically restore package while building .
This feature will download all packages which are referred by your packages.config files before building the code to make sure code has all references included while building the code.

Related

Nuget Restore in MS Build Step

In my asp.net web application, i have solution with 5 projects and nuget.org. In TFS Build Definition,
1) While building the whole solution in Visual Studio Build Task
Nuget packages getting restored.
2) While trying to generate executable files for individual projects in MS Build Task
If I select Restore Nuget packages, It's not finding nuget packages and step getting failed with message - "Process 'NuGet.exe' exited with code '1'."
I have tried many references online and none worked. Any suggestions on how to solve this?
Do i need to make any changes in the nuget.config file to support restoring
packages to individual projects.
Do not directly select Restore Nuget pacakges in MS build task configuration. This option is deprecated. To restore NuGet packages, add a NuGet Installer step before the build.
(Important) This option is deprecated. Make sure to clear this
checkbox and instead use the NuGet Installer build step.
Source Link: MSBuild
Besides, you could also build single project not the entire solution in Visual Studio Build task. Just select the project (.*proj) files instead of .sln file.
Unless you are building a customized MSBuild project file, then we recommend you use the MSBuild step instead of the Visual Studio Build step.
You could also try to build single project using Visual Studio Build task, see if the issue is still exists.
Same problem, downgraded to 4.4.1. it helped

VSTS Xamarin.Android build error

I want to setup the build of my Xamarin.Android app in VSTS.
I received the following error in the Build.Xamarin.Android step: Error : 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 ....\packages\Xamarin.Android.Support.Animated.Vector.Drawable.25.4.0.2\build\MonoAndroid70\Xamarin.Android.Support.Animated.Vector.Drawable.targets
I followed the steps as described on the page described in this link: https://learn.microsoft.com/nl-nl/vsts/build-release/apps/mobile/xamarin?tabs=vsts
What am I doing wrong?
Build.Xamarin.Android step: Error : 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.
You need to check two tasks in your build definition:
Task : Use NuGet 4.3.0
Task : NuGet restore
If any task is missing in your build definition, please add it. If the error persists, please provide the build log.

Update Packages of a MVC Project

Im trying to use an ASP.NET web application downloaded from the internet. Im looking for a way restore all the dependencies/packages in a quick way (clean and building the project did not solve it), rather than installing them via nuget one by one. Is there anyway to download and install/resolve (version issues) all the necessary packages at once?
I tried below package manager console commands, but they did not resolve the package conflicts.
Update-Package -Reinstall,
nuget install packages.config and other solutions here - How do I get NuGet to install/update all the packages in the packages.config?
[resolve/install packages]
Can someone help? Maybe Im using wrong commands or doing something wrong.
If you go into Tools > Nuget Package Manager > Manage Nuget Packages for Solution, it will show a yellow bar at the top asking you if you want to restore missing packages. That's a manual way, but there are also some important VS options you want to look at as well, one being an option to restore packages on build.
There is a generic restore option as well from the package manager console, and that should have worked if it was simply a matter of reimporting the missing packages...
Update-Package -reinstall
You can try to delete the folders, than reinstall using these options. However, is there a possibility there is a .NET framework version mismatch with the version of the DLL's? Maybe some of the DLL's need updated?
Remove package folders from Package folder - don't remove package.config. Next, build you application - nuget should automatically restore all packages.

VisualStudio 2013 list all NuGet packages

I have a mvc 5 web project with a number of NuGet packages installed (like email, log, pagedlist etc).
In a new similar project I would like to install the same NuGet packages. How can I in the old project list all installed NuGet packages?
You can find a packages.config file in the old project's root directory.
You can copy it to the new project.
If you go to Tools -> NuGet Packet Manager -> Packet manager settings and check Allow NuGet to download missing packages and the other check box that states Automatically check for missing packages during build in Visual Studio it will download it for you next time you build.
If you want to list all installed nuget packages for the project take a look at this one.
http://blogs.msdn.com/b/david_kidder/archive/2014/08/19/micro-blog-how-to-list-installed-nuget-packages-from-package-manager-console-and-be-able-to-read-them.aspx
You might also want to enable nuget package restore to restore the packages when rebuilding your project/s.
Here's another link for you - http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html
In the root folder of your original project find a packages.config file. Copy its contents to your new project, same file name.
Go to Visual Studio > Tools > Package Manager Settings > General
Enable "Allow Nuget to download..." and "Automatically check for missing..."
Now build your new project
Most of the answers here are partially correct.
The first part is true. The packages.config file lists all packages that are used by the project.
However, all the answers about using Package Restore are incorrect. Package Restore will download any missing packages, however it is NOT the same as installing a package into a project. It will not add references, run any install.ps1 scripts, or add files, modify .config, etc. Package Restore simply downloads missing packages. It is assumed that the packages were already installed to the project.
In order for the packages to be correctly installed in your new project, open the Package Manager console, then type:
Update-Package -ProjectName MyProjectName -Reinstall
This will force NuGet to run through the install process and correctly install the package into your project.

Referenced Dll's not found in Team Foundation Service (or: nuget packages not available on other pc)

when I create a build for the Team Foundation Service, I get all kind of reference dll's not found exceptions.
These references are added by nugget packages.
I've added the 'package restore' option on the solution which added 3 files in a .NuGet folder.
EDIT
When i got the solution from TFS on another pc, i got the same errors (missing dll's), so it's not only the TFS build service having problems.
The missing dll's are are missing files from installed nuget packages (some are part of the default VS template, Unity was a package i added later), which (the packages) are added on the first pc, but then are missing on the next pc (that's why i added the 'or' in the title of this question)
How can i get the Nuget added files on pc2 too?
I guess you've found a solution by now. I write this just to provide an answer for this question.
To have NuGet packages automatically downloaded on another PC, you need to enable NuGet package restore on build. You do this in two steps:
Right click the solution and select Enable NuGet Package Restore.
This will add a .nuget solution folder with NuGet.Config, NuGet.exe and NuGet.targets underneath it. These files should actually be checked in to source control, but the binary file is tiny. It will also modify the MSBuild scripts in all projects of the solution to import the NuGet.targets file to hook NuGet into the build process.
In Tools -> Library Package Manager -> Package Manager Settings make sure the option 'Allow NuGet to download missing packages during build' is checked.
This step must be done on all machines.
Now the BuildDependsOn property of all project build scripts should make the RestorePackages target in NuGet.targets kick in and download missing packages before you get build errors for missing references.

Resources