We currently get the following error on the build server with no related changes we can notice. What could be wrong or where should we start debug it?
...
RestorePackages:
"E:\AzureBuildAgentWorkingFolder\2\s\Server\.nuget\NuGet.exe" install "packages.config" -source "" -NonInteractive -solutionDir "E:\AzureBuildAgentWorkingFolder\2\s\Server\ "
All packages listed in packages.config are already installed.
##[error]C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(234,5): Error NETSDK1064: Package Microsoft.AspNet.SignalR.Client, version 2.4.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
...
We have checked and the folder and files for the signalr (Microsoft.AspNet.SignalR.Client, version 2.4.0) package exists.
I have tried:
clean entire build folder
adding msbuild restore to pipeline
different nuget versions from 4 -> 5
Microsoft.AspNet.SignalR.Client version 2.4.0 and 2.4.1
manual build with VS on the build server (works)
Related
The sample NotepadAndCalculatorTest project built in VS Code using the terminal command dotnet build throws the following errors:
C:\Program Files\dotnet\sdk\5.0.401\Microsoft.Common.CurrentVersion.targets(820,5): error : The BaseOutputPath/OutputPath property is not set for project 'NotepadCalculatorTest.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'. You may be seeing this message because you are trying to build a project without a solution file,
and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\Users\<username>\VSCode Projects\WinAppDriverTryout\Test\Samples\C#\NotepadAndCalculatorTest\NotepadCalculatorTest.csproj]
Or:
NotepadCalculatorTest.csproj(109,5): 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\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props.
Could someone point me towards a possible way to get rid of the errors?
dotnet build carries out an implicit restore as part of the command.
This uses dotnet restore which does not support project references in packages.config & is exactly what this project is using.
dotnet restore only supports .csproj package references.
That's why, this project builds perfectly fine in Visual Studio but dotnet build throws errors.
You can migrate packages.config to package references by right-clicking on the file within Visual Stduio and clicking migrate, however that still won't fix your problem as dotnet cli works properly with .NET Framework only if the project was created using the dotnet new command.
I assume this project was created in Visual Studio since it has a Visual Studio solution file - .sln - and so commonly have a differently structured .csproj format.
This then usually breaks some CLI commands, even if you migrate the references in this case.
You have 2 workarounds.
1. Use nuget restore
The easiest option is to download the NuGet CLI executable from here, taken from the downloads page.
If you are not on Windows, use this guide by Microsoft.
Add it to your PATH or place it in the root folder of the project.
Run nuget restore, which is compatible with packages.config (run .\nuget restore if you're inside PowerShell to trust the command as PowerShell does not does not load commands from the current location by default for security).
Your should get output similar to this:
PS C:\Users\StackOverflow\NotepadAndCalculatorTest> .\nuget restore
MSBuild auto-detection: using msbuild version '16.9.0.16703' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'.
Restoring NuGet package Microsoft.WinAppDriver.Appium.WebDriver.1.0.1-Preview.
Restoring NuGet package Selenium.Support.3.8.0.
Restoring NuGet package Selenium.WebDriver.3.8.0.
Restoring NuGet package Castle.Core.4.2.1.
Restoring NuGet package MSTest.TestFramework.1.2.0.
Restoring NuGet package Newtonsoft.Json.10.0.3.
Restoring NuGet package MSTest.TestAdapter.1.2.0.
Adding package 'MSTest.TestFramework.1.2.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Selenium.Support.3.8.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Castle.Core.4.2.1' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Microsoft.WinAppDriver.Appium.WebDriver.1.0.1-Preview' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Selenium.WebDriver.3.8.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Newtonsoft.Json.10.0.3' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'MSTest.TestAdapter.1.2.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Microsoft.WinAppDriver.Appium.WebDriver.1.0.1-Preview' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Selenium.Support.3.8.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Selenium.WebDriver.3.8.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Castle.Core.4.2.1' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Newtonsoft.Json.10.0.3' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'MSTest.TestAdapter.1.2.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'MSTest.TestFramework.1.2.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
NuGet Config files used:
C:\Users\StackOverflow\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
C:\Users\StackOverflow\.nuget\packages\
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Installed:
7 package(s) to packages.config projects
Then run dotnet build.
It won't try to run dotnet restore as the packages have already been restored by NuGet already so you won't get any errors:
PS C:\Users\StackOverflow\NotepadAndCalculatorTest> dotnet build
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Nothing to do. None of the projects specified contain packages to restore.
NotepadCalculatorTest -> C:\Users\StackOverflow\NotepadAndCalculatorTest\bin\Debug\NotepadCalculatorTest.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.08
2. Port the project
The 2nd workaround is to create a new project using dotnet new & port the code over so that your .csproj file works with dotnet restore and subsequently, dotnet build.
I would recommend option 1 unless you don't want to restore via NuGet.
I want to install OPCFoundation.NetStandard.Opc.Ua version 1.4.355.26 (and all of its dependencies) to an offline machine. My online and offline machines are running Visual Studio 2019 16.1.3.
When I install OPCFoundation.NetStandard.Opc.Ua version 1.4.355.26 using the NuGet Package Manager, it installs many dependencies, including Libuv.1.10.0. See screenshot:
When I download the same package for offline installation, nuget.exe fetches Libuv.1.9.2. See screenshot:
C:\Users\cstankevitz\Downloads>nuget.exe install OPCFoundation.NetStandard.Opc.Ua
Feeds used:
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Installing package 'OPCFoundation.NetStandard.Opc.Ua' to 'C:\Users\cstankevitz\Downloads'.
GET https://api.nuget.org/v3/registration3-gz-semver2/opcfoundation.netstandard.opc.ua/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/opcfoundation.netstandard.opc.ua/index.json 558ms
Attempting to gather dependency information for package 'OPCFoundation.NetStandard.Opc.Ua.1.4.355.26' with respect to project 'C:\Users\cstankevitz\Downloads', targeting 'Any,Version=v0.0'
Gathering dependency information took 16.89 sec
Attempting to resolve dependencies for package 'OPCFoundation.NetStandard.Opc.Ua.1.4.355.26' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'OPCFoundation.NetStandard.Opc.Ua.1.4.355.26'
Resolved actions to install package 'OPCFoundation.NetStandard.Opc.Ua.1.4.355.26'
Retrieving package 'Libuv 1.9.2' from 'nuget.org'.
...
Of course, when I bring the downloaded packages to my offline machine and install them using Visual Studio 2019 NuGet Package Manager, the install fails because the Libuv.1.10.0 is not available.
How can I get nuget.exe (or any other tool) to download the correct packages needed by NuGet Package Manager for offline installation?
Here is how I installed the correct dependencies to my offline system:
On the online system
Fetch the source of https://github.com/StuffOfInterest/NuGetDependencyDownloader
Edit PackageTools.cs and modify the function GetRangedPackageVersion so that it contains the code below. This is needed to fix a "bug" in which older packages are not downloaded when newer packages are available -- but the older packages will be needed in Step 9 below.
Compile and run NuGetDependencyDownloader to download the package and its dependencies
Copy the packages to an external drive
On the offline system
Copy the packages to your offline system (c:\Work\2019-07018 Nuget Offline\ in my example)
Edit options for Nuget Package Manager | Package Sources. Add a source that points to the directory used in step 5. Specify Local Package Source Screenshot
Run Nuget Package Manager.
Specify the Package source that you created in step 6. Specify package source screenshot
Install your package
Notice that it appears to install but nothing is actually happening. It is trying to contact something online (which will fail after a long timeout). This is repeated for every dependency. Speed up the failure by disconnecting all of your interfaces (unplug cables, etc).
private IPackage GetRangedPackageVersion(IQueryable<IPackage> packages, IVersionSpec versionSpec)
{
packages = packages.Where(o => o.Version == versionSpec.MinVersion);
IPackage package = packages
.OrderByDescending(o => o.Version)
.FirstOrDefault();
return package;
}
If you look at the output of the Preview Changes dialog in VS, all the Microsoft.AspNetCore packages are version 2.0.1, whereas running nuget.exe, it got versions 1.1.x. If you look at OPCFoundation.NetStandard.Opc.Ua on nuget.org and expand the dependencies, you see it has dependencies on the 1.1 packages for net46 and netstandard2.0, but 2.0 dependencies for netstandard2.0.
From this I can deduce that your project is using netcoreapp2.0, netstandard2.0, or above, whereas nuget.exe is probably using some .NET Framework for dependencies.
As for ways to get the same packages that your project actually uses, I've answered this question several times in the past and I usually link to the first time I answered it
I am new in Xamarin android development.
I take the code pull from git.
After that i opened my solution in visual studio.
I cleaned the solution - now it is fine.
then i trying to build the solution it is showing the error.
>Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
NuGet Package restore failed for project app: Unable to find version '2.0.0' of package 'FastAndroidCamera'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'FastAndroidCamera.2.0.0' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The remote name could not be resolved: 'api.nuget.org'
1>------ Rebuild All started: Project: app, Configuration: Debug Any CPU ------
1>D:\PRANAV\TOLL\GIT\MobileApp-12-06-2018\MobileApp\app\app.csproj(467,5): 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.Build.Download.0.4.3\build\Xamarin.Build.Download.props.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========\
This is the error that i am getting . So guys can you figure where i am doing the mistakes ?
According to the error message,
To prevent NuGet from restoring packages during build, open the Visual
Studio Options dialog, click on the Package Manager node and uncheck
'Allow NuGet to download missing packages during build.'
It seems the project use the older now deprecated NuGet package restore that is MSBuild based and runs NuGet.exe on every build. These messages are from NuGet.exe.
Check the similar issue here.
To resolve this issue, you should make sure to upgrade to the latest version of NuGet which does package restore automatically instead of MSBuild based NuGet package restore.
You're going to want to delete the NuGet targets (delete the .nuget folder and then manually edit your .csproj files and remove the lines that import the NuGet.targets file). This is no longer needed. Using the new way to restore nuget package, the NuGet packages will be automatically restored by Visual Studio just before the build.
See this post by David Ebbo for more information: http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html and the blog how to switch from "Enable Package Restore" to "Automatic Package Restore"
Hope this helps.
I need to install Nuget Package ProductionStackTrace, so I use the following command
PM> Install-Package ProductionStackTrace
But when I execute this command I get the following error
The source at Microsoft Visual Studio Offline Packages [C:\Program Files (x86)\Microsoft SDKs\NuGetPackages] is unreachable.
I checked the path and yes the package is not there; isn't Nuget Package added by default? If not, from where I can add it?
Visual Studio provides some common packages for us to use in the Microsoft SDKs\NuGetPackages folder when our computer doesn't have network.
The C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\ folder is not means that the cache for the packages has been installed before from internet. So the package ProductionStackTrace will not add into this folder.
If you want to use this package without network, you need to download it when you have network. You can download it from the nuget.org.
Certainly, you can also add this package in to the Microsoft SDKs\NuGetPackages so that you can use it when you do not have a network. The add command line is:
nuget add <packagePath> -source <sourcePath> [options]
You can refer to the nuget Add reference for detail.
Hope this can help you.
Unclear why this happened for my installation, but Visual Studio (VS 2022 preview at this time) had an offline location (good), but no package source to nuget.
This caused my build to fail on packages not found in the offline directory.
Hence I ended up adding a Package source in Visual Studio for Nuget as:
nuget.org
https://api.nuget.org/v3/index.json
Which then allowed VS to do a Restore of packages to succeed. Then not having to do a nuget install Newtonsoft.json -source ... type command for each failed package.
for Visual Studio Mac, packages are copied into the path /Users/{username}/.nuget/packages
You can choose menu for Visual Studio->Preferences->Nuget->Sources and add a new source using this path and install already cached packages.
manually dowload from nuget.org package with extension NUPKG file,and copy paste that into (C:\Program Files (x86)\Microsoft SDKs\NuGetPackages) relative path
OR
RUN CMD COMMAND:
dotnet add projectpath package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore --version 6.0.0
When I try and build my project in Teamcity (or in a clean repository on my machine), it fails with the error message
The schema version of 'Microsoft.Bcl' is incompatible with version 1.7.30402.9028 of NuGet. Please upgrade NuGet to the latest version from <nuget url>...
I've set my NuGet.Targets to restore packages, and not require user interactions to accept licenses. In addition both my local machine and the build server have the restore packages setting enabled (in the project/env variable as appropriate).
I'm aware of this issue http://blogs.msdn.com/b/dotnet/archive/2013/06/12/nuget-package-restore-issues.aspx. I've tried the second and third options suggested here, but without success.
Does anyone have any suggestions how to resolve this error?
Turns out the version of NuGet that is held in the .nuget folder of my solution was out of date. The version that Visual Studio uses had updated correctly, but the command line version didn't.
I followed the instructions described here Nuget versioning issue with package restore to resolve the problem.
In the solution directory run these commands:
cd .nuget
nuget.exe update -Self
Try updating the nuget that teamcity is using
If you are using version 8.x.x
Administration -> Nuget Settings -> Nuget Commandline -> (click fetch nuget) -> then choose the latest version and install it. Make sure "Set as Default" is checked.