TFS unable to restore nuget packages (dev PCs build ok) - tfs

A previously working on-premises TFS 2015 (with update 1) fails all builds that have nuget packages in them. The build log shows:
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
Restoring NuGet package StyleCop.Error.MSBuild.1.0.0.
Restoring NuGet package Microsoft.Diagnostics.Tracing.EventSource.Redist.1.1.28.
Restoring NuGet package Microsoft.Diagnostics.Tracing.EventRegister.1.1.28.
Restoring NuGet package Microsoft.Diagnostics.Tracing.EventSource.1.1.28.
Restoring NuGet package StyleCop.MSBuild.4.7.50.
Restoring NuGet package Newtonsoft.Json.8.0.3.
Restoring NuGet package Dapper.1.42.0.
Restoring NuGet package FluentAssertions.4.2.2.
WARNUNG: Unable to find version '1.1.28' of package 'Microsoft.Diagnostics.Tracing.EventRegister'.
WARNUNG: Unable to find version '1.0.0' of package 'StyleCop.Error.MSBuild'.
WARNUNG: Unable to find version '1.1.28' of package 'Microsoft.Diagnostics.Tracing.EventSource.Redist'.
WARNUNG: Unable to find version '1.1.28' of package 'Microsoft.Diagnostics.Tracing.EventSource'.
WARNUNG: Unable to find version '1.42.0' of package 'Dapper'.
WARNUNG: Unable to find version '8.0.3' of package 'Newtonsoft.Json'.
WARNUNG: Unable to find version '4.7.50' of package 'StyleCop.MSBuild'.
WARNUNG: Unable to find version '4.2.2' of package 'FluentAssertions'.
Unable to find version '4.2.2' of package 'FluentAssertions'.
Unable to find version '4.7.50' of package 'StyleCop.MSBuild'.
Unable to find version '1.1.28' of package 'Microsoft.Diagnostics.Tracing.EventRegister'.
Unable to find version '8.0.3' of package 'Newtonsoft.Json'.
Unable to find version '1.42.0' of package 'Dapper'.
Unable to find version '1.1.28' of package 'Microsoft.Diagnostics.Tracing.EventSource'.
Unable to find version '1.1.28' of package 'Microsoft.Diagnostics.Tracing.EventSource.Redist'.
Unable to find version '1.0.0' of package 'StyleCop.Error.MSBuild'.
Unerwarteter Exitcode 1 vom Tool NuGet.exe zurückgegeben
On dev PCs the solutions build just fine and nuget packages are restored without problems.
How to fix this?

The error message indicates that the packages cannot be found in your package resource. Since the packages can be restored on you dev PC, you can compare the nuget.config file on your TFS server and dev PCs to see if there is any difference between them. The nuget.config file locates at "%APPDATA%\NuGet\NuGet.Config".
And the nuget.exe version you use may also cause this issue, see this question for reference: "Unable to find version" during TFS Build 2015 when restoring NuGet packages

Related

The NuGet Installer task used in TFS 2017 build definition fails to clear the global-packages folder with an error

We have a build definition in place created in TFS 2017, which builds a .net solution that has dependency on some of our NuGet packages, during compilation the solution restores the NuGet package from packages (global-packages) folder present at this path %userprofile%\.nuget\packages instead of downloading latest one from our internal feed.
I saw a command at this page to avoid using the global-packages folder, but when I added the nuget locals global-packages -clear argument in NuGet installer task, which is used to restore the nuget packages, the task failed with the below error saying unknown option -Clear.
The NuGet Version I am using is 3.5.0 in the task.
2019-09-05T09:27:18.8819742Z ##[section]Starting: NuGet restore $(build.sourcesdirectory)/IntelliSuiteService.sln
2019-09-05T09:27:18.8819742Z ==============================================================================
2019-09-05T09:27:18.8819742Z Task : NuGet Installer
2019-09-05T09:27:18.8819742Z Description : Installs or restores missing NuGet packages
2019-09-05T09:27:18.8819742Z Version : 0.2.31
2019-09-05T09:27:18.8819742Z Author : Microsoft Corporation
2019-09-05T09:27:18.8819742Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2019-09-05T09:27:18.8819742Z ==============================================================================
2019-09-05T09:27:19.4601187Z [command]C:\Windows\system32\chcp.com 65001
2019-09-05T09:27:19.4757465Z Active code page: 65001
2019-09-05T09:27:19.5069958Z Detected NuGet version 3.5.0.1938 / 3.5.0
2019-09-05T09:27:19.5226206Z SYSTEMVSSCONNECTION exists true
2019-09-05T09:27:19.5226206Z [command]F:\Builds\NextGen_Gated\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe restore -NonInteractive F:\Builds\NextGen_Gated\2\s\SuiteService.sln -NoCache nuget locals global-packages -Clear
2019-09-05T09:27:20.1007732Z Unknown option: '-Clear'
2019-09-05T09:27:20.1163983Z ##[error]Error: F:\Builds\NextGen_Gated\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.31\node_modules\nuget-task-common\NuGet\3.5.0\NuGet.exe failed with return code: 1
2019-09-05T09:27:20.1163983Z ##[error]Packages failed to install
2019-09-05T09:27:20.1320334Z ##[section]Finishing: NuGet restore $(build.sourcesdirectory)/SuiteService.sln
You should run the command separately from the nuget restore command.
You can can log in to the agent machine and run it from the command line, or in the build add a command line or batch task that run the command.

How to install FSharp.xUnit?

I've installed Visual Studio 2017 and included the test package and the F# package. I'm trying to run a simple test using xUnit but it says xUnit is not found.
module HelloWorldTest
open FsUnit.xUnit
open Xunit
open System.Diagnostics
[<Fact>]
let ``Say Hello`` () =
Assert.True(true)
Error
The namespace or module 'FsUnit' is not defined.
I tried installing the package with dotnet but that produces an error.
> dotnet add package FSharp.xUnit
Writing C:\Temp\tmp8DAB.tmp
info : Adding PackageReference for package 'FSharp.xUnit' into project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
log : Restoring packages for C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj
...
error: Unable to find package FSharp.Core. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package FsUnit.xUnit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package xunit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package xunit.runner.visualstudio. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package FSharp.xUnit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package Microsoft.NET.Test.Sdk with version (>= 16.0.0)
error: - Found 1 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 15.9.0]
error: Package 'FSharp.xUnit' is incompatible with 'all' frameworks in project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
So how can I install xUnit for F#? This guide from MS unfortunately is lacking any of this information.
https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-fsharp-with-dotnet-test
EDIT:
After adding the NuGet package source
> dotnet add package FsUnit.xUnit
Writing C:\Temp\tmp5BA6.tmp
info : Adding PackageReference for package 'FsUnit.xUnit' into project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
log : Restoring packages for C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj
...
info : CACHE https://api.nuget.org/v3-flatcontainer/fsunit.xunit/index.json
info : Package 'FsUnit.xUnit' is compatible with all the specified frameworks in project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
info : PackageReference for package 'FsUnit.xUnit' version '3.4.0' updated in file 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.

Nuget Restore does not work via Jenkins

I am building up a Jenkins environment for building Xamarin app projects.
I want to do a nuget restore at the start of the job by executing the command via powershell, but nuget can't find the referenced packages. It throws errors like:
WARNING: Unable to find version '2.9.0' of package 'ReactiveProperty'.
WARNING: Unable to find version '1.0.2' of package 'PCLStorage'.
WARNUNG: Unable to find version '2.3.0-beta2' of package 'Rx-Interfaces'.
...
When I do the nuget restore with my windows (admin) user in powershell, it just works fine and is copying all the referenced packages into the project.
I feel that this has something to do with permissions...
OS is Windows 10, Jenkins version is 2.19.1
Here is the full Jenkins log:
Gestartet durch Benutzer xxx
[EnvInject] - Loading node environment variables.
Baue in Arbeitsbereich e:\jenkins_workspace\xxx
Updating xxx at revision '2016-11-11T11:24:47.469 +0100'
At revision 36612
No changes for xxx since the previous build
[xxx] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "&'C:\Windows\TEMP\hudson7328741479356255129.ps1'"
Restoring NuGet package PCLStorage.1.0.2.
Restoring NuGet package ReactiveProperty.2.9.0.
WARNUNG: Unable to find version '1.0.2' of package 'PCLStorage'.
WARNUNG: Unable to find version '2.9.0' of package 'ReactiveProperty'.
Restoring NuGet package Rx-Core.2.3.0-beta2.
Restoring NuGet package Rx-Interfaces.2.3.0-beta2.
WARNUNG: Unable to find version '2.3.0-beta2' of package 'Rx-Core'.
WARNUNG: Unable to find version '2.3.0-beta2' of package 'Rx-Interfaces'.
Restoring NuGet package Rx-Linq.2.3.0-beta2.
Restoring NuGet package Rx-Main.2.3.0-beta2.
WARNUNG: Unable to find version '2.3.0-beta2' of package 'Rx-Main'.
WARNUNG: Unable to find version '2.3.0-beta2' of package 'Rx-Linq'.
Restoring NuGet package Rx-PlatformServices.2.3.0-beta2.
Restoring NuGet package Serilog.1.5.7.
WARNUNG: Unable to find version '2.3.0-beta2' of package 'Rx-PlatformServices'.
...
...
...
Eine Ausnahme vom Typ "NuGet.CommandLineException" wurde ausgel”st.
Build step 'Windows PowerShell' marked build as failure
Finished: FAILURE

unable to delete Nuget package from TFS - Package Management feed

C:>nuget.exe delete Package1 1.0.0.0 -Source https://test.pkgs.visualstudio.com/_packaging/MyFeed/nuget/v2 -ApiKey VSTS
gives confirmation of package deleted
Package1 1.0.0.0 was deleted successfully.
However, when i refresh package management (TFS Web), the 'Package 1' package is still show up in the Web interface. It shouldn't show here because it has been deleted. Right?
Problem: I can't further push package.
Error:
Failed to process due to conflict.
Why so?
This link it says "Note: Unlisting is permanent. Once you unlist a version of a package, it cannot be re-listed.
You may not upload a package with the same name and version as the unlisted package."

xunit.core is incompatible with version of NuGet

I added a new project to the solution. I've added some nuget packages however it fails when building on TFS. It works fine when building locally. I get the following error messages:
C:\Builds\8\Server-Dev-CI\src\.nuget\NuGet.targets (58): The schema version of 'xunit.core' is incompatible with version 2.0.30828.5 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.
C:\Builds\8\Server-Dev-CI\src\.nuget\NuGet.targets (58): The schema version of 'xunit.extensibility.execution' is incompatible with version 2.0.30828.5 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.
C:\Builds\8\Server-Dev-CI\src\.nuget\NuGet.targets (58): One or more errors occurred.
C:\Builds\8\Server-Dev-CI\src\.nuget\NuGet.targets (58): The command ""C:\Builds\8\Server-Dev-CI\src\.nuget\nuget.exe" install "C:\Builds\8\Server-Dev-CI\src\Modules\UnitTests.xUnit\packages.config" -source "https://nuget.org/api/v2/" -o "C:\Builds\8\Server-Dev-CI\src\packages"" exited with code 1.
When I open the sources in VS2013 (on the build server) I see the following:
I have to click Restore Packages to get it to work.
I already updated NuGet. Where is it getting " 2.0.30828.5 of NuGet" from???
I figured it out. The whole time I though TFS uses Visual Studio's NuGet, however it turns out TFS runs:
C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\nuget.exe restore
I had to open up console and update nuget:
nuget.exe update -self

Resources