Nuget Custom package Restore from URI on Build Server - visual-studio-2017

Could anyone suggest me the best way to restore custom Nuget packages on a build server after a TFS build definition is triggered.
Whether to pass the packagesource URI through nuget.config, or restore it using powershell

You could install your custom Nuget packages by right clicking the project in VS -- select Manage NuGet Packages, and check in the packages.config file.
Then, in your TFS build definition, add a NuGet Installar task before VS Build task to restore the packages.

Related

The nuget command failed with exit code(1) The element <ProductVersion> beneath element <Project> is unrecognized

I'm setting a build in Azure DevOps Pipelines, I have in repos some solutions including a SQL Server Analysis Project. This project triggers a error in the build for the NuGetCommand:
[error]The nuget command failed with exit code(1) ...: error MSB4067: The element <ProductVersion> beneath element <Project> is unrecognized.)
[error]Packages failed to restore
[section]Finishing: NuGetCommand
Any ideas how to solve this error? Maybe run the NuGetCommand for all projects except this SSAS, how can I exclude this solution/project?
I tried to Manage NuGet Packages for this SQL Server Analysis Project, but is not supported.
I have this code in the azure pipeline, I need to run this command for every solutions except SQL Server Analysis Project.
- task: NuGetCommand#2
inputs:
restoreSolution: '$(solution)'
The nuget command failed with exit code(1) The element beneath element is unrecognized
This issue is more related to the MSBuild instead of nuget.
Since NuGet is now fully integrated into MSBuild, when we invoke nuget to restore packages, it will call MSBuild auto-detection. There is a issue in MSBuild 15 about it.
Besides,
the latest version of Microsoft Reporting Services Projects for Visual
Studio (1.18) adds MSBuild support for SSRS projects. With this
installed, SSRS projects can be updated to a format supported by
MSBuild, which prevents this problem from happening.
So, to resolve this issue, please update your Visual Studio on the agent server to the latest version to check if you still have this issue.
Hope this helps.

Installing NuGet package located in local package repository into a new Visual Studio Solution

UPDATE: Apparently providing too much pre-amble adds more confusion that clarity, so here's my question:
How do I add packages to a project from the local packages repository (i.e. not the central NuGet repository) when there are no references to them in the current solution and thus they do not show up as installed in the "Manage Package for Solutions" window.
Original with the background detail:
We use a local NuGet package folder that contains all the packages to be used by our projects. We do NOT want it to be arbitrarily updated or changed (i.e. no Installs of existing packages or restore's (if possible))
We've recently switched to VS2017 and are building our solutions and projects from scratch. We set up a NuGet.Config to point to the local packages folder. It works (as in we see new packages installed there if we test-install a package into a project from the NuGet central repository).
However, because the NuGet packages are currently not installed into any projects in the solution, NuGet reports (via Get-Package or the GUI) that there are no packages installed.
This seems to mean that we can't add the projects in the packages directory to the appropriate solutions without going to the central NuGet repository, despite their availability in the local package folder!
I'd prefer to see the package in the repository so that I can add them to their respective projects and have NuGet create the packages.config file for the project (using the new format).
Do I really have to re-install the packages from NuGet's central server just to add them to a project?
Installing from the central NuGet repository literally writes over the existing package in the local repository. More to the point, a few of our packages use versions that are no longer available on the NuGet repository.
Our current work-around is to editing the packages.config file by hand in one project in the solution, which makes the package visible in the "Manage Package for Solutions" window. We then can install the package in our actual target project by simply selecting the target project in the GUI (this performs the appropriate alterations on the target project's .csproj file). We then remove the hand-edited packages.config from the original project.
This is using NuGet 4.6 as installed by VS 2017.
Many thanks for any advice.
How do I add packages to a project from the local packages repository (i.e. not the central NuGet repository) when there are no references to them in the current solution and thus they do not show up as installed in the "Manage Package for Solutions" window.
Not sure if I completely understand your problem correctly, if not, please let me know for free.
To resolve this issue, you can create a local feed for those packages, so that you can see those packages in the Manage Package for Solutions and add them to their respective projects and have NuGet create the packages.config file for the project even if you don't have them installed.
Add those packages .nupkg into your local repository folder (Including those versions that are no longer available on the NuGet repository).
Head into Visual Studio and open the NuGet Settings dialog via Tools > NuGet Package Manager > Package Manager Settings. Click the Package Sources tab within the settings dialog, followed by the plus icon in the top left to add a new package source.
Enter the Name and Source of your local repository. The name can be any string and will be the name displayed in the NuGet Package Manager within Visual Studio.
Now that you have added the local package source, you will be able to use your local repository from within Visual Studio in the usual way, either via the Console or via the Package Dialog, by selecting it from the Package Source menu:
Hope this helps.

Package restore failed. Rolling back package changes for 'ConsoleApp1' while installing new package

I get Package restore failed. Rolling back package changes for 'ConsoleApp1' while installing a new package. In particular I am trying to install the dropbox API, but I tried several other packages and get the same result.
I install by right clicking on the project and choosing Manage nuGet Packages... Then I select the package and click Install.
The NuGet is able to connect with the NuGet server as the package seems to download. The download information flashes on the screen pretty quick so I captured it with screen recording software to see if there were error messages. There were none.
I updated visual studio 2017 to latest patch level. My windows 10 machine is also at the latest level.
The project I am trying to install into is a freshly created Console App(.Net Core).
Here are the other questions I looked at:
Package restore failed. Rolling back package changes
does not have any responses because it is not a well developed question.
package restore failed rolling back package change for ' myproject' in vs 2017 .net mvc core project
Yet another poorly worded question with no viable answers.
Package restore failed. Rolling back package changes for 'myproject' in vs 2017 in MVC Core
That one is trying to update packages, not install new.
Nuget - Package restore failed. Rolling back package changes for 'WebApplication1'. 0
Seems to be for a custom package.
I am new to using Visual Studio.
To expand on #Michael Potter's answer, create a Console App (.NET Framework), NOT Console App (.NET Core).
The problem was that I am using Console App(.Net Core) Core is not compatible with Dropbox API.
I figured that out by opening NuGet Package Manager -> Package Manager Console and running Install-Package Dropbox-Api.
Then the error message about compatibility was on the screen plain to see.
To solve the problem I am switching to Console App (.Net Framework).
bring the version of the solution package to 1.1.3enter image description here

NuGet Package Manager not working in Visual Studio 2017 - for a.NET Core 1.1 web application

I just created a .NET Core Web Application in VS2017 and I wanted to be able to serve a single page application. In order to be able to do that I tried to install the nuget package Microsoft.AspNetCore.StaticFiles. But my NuGet installer failed and threw the following error
Severity Code Description Project File Line Suppression State
Package restore failed. Rolling back package changes for 'MyApp'.
Right click on the project=>Properties and set TargetFramework to .net core 2.0(less than or equal to the packages version you are using)
build the project and then install whatever you want from nuget.

SlowCheetah - TeamCity - [restore] Unable to find version '2.5.15' of package 'SlowCheetah'

I have an issue with my TeamCity instance not retrieving version 2.5.15 of SlowCheetah from TeamCity. It restores all of my other nuget based dependencies just fine.
I added SlowCheetah to one project in my Solution via the Nuget Package Manager Console and it works fine locally. However when TeamCity tries to get the nuget package is complains with
[restore] Unable to find version '2.5.15' of package 'SlowCheetah'.
I've had a look at adding a nuget installer - https://johanleino.wordpress.com/2013/06/17/making-use-of-teamcitys-nuget-capabilities-part-2/
and this
http://sedodream.com/2011/12/12/SlowCheetahXMLTransformsFromACIServer.aspx
neither of which work.
Any ideas?
I believe you need to update your Nuget version on TeamCity.