1
votes

This is my original YML file.

trigger:
- master

pool:
  vmImage: 'Ubuntu-16.04'

variables:
  buildConfiguration: 'Release'

steps:

- task: NuGetToolInstaller@0
  displayName: "NuGet use 4.9.3"
  inputs:
    versionSpec: 4.9.3

- task: DotNetCoreInstaller@0
  inputs:
    version: '2.2.104'

- task: NuGetCommand@2
  displayName: "NuGet Restore"
  inputs:
    restoreSolution: '**/*.csproj'

- task: DotNetCoreCLI@2
  displayName: ".NET build"
  inputs:
    projects: '**/*.csproj'
    arguments: --configuration $(BuildConfiguration) --no-restore

- task: DotNetCoreCLI@2
  displayName: ".NET publish package"
  inputs:
    command: publish
    arguments: '--configuration $(BuildConfiguration) --no-restore --output $(Build.ArtifactStagingDirectory)/app/pkg'

This is the output I get for the Nuget Restore step.

[section]Starting: NuGet restore ============================================================================== Task : NuGet Description : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task. Version : 2.147.6 Author : Microsoft Corporation Help : More Information ============================================================================== Caching tool: NuGet 4.1.0 x64 Found tool in cache: NuGet 4.1.0 x64 Resolved from tool cache: 4.1.0 Using version: 4.1.0 Found tool in cache: NuGet 4.1.0 x64

How do I disable the use of "tool cache"? It is using 4.1.0 instead of 4.9.3.

UPDATE: As recommended by the comments, I updated my YML file.

trigger:
- master

pool:
  vmImage: 'vs2017-win2016'

variables:
  buildConfiguration: 'Release'

steps:

- task: DotNetCoreCLI@2
  inputs:
    command: restore

- task: DotNetCoreCLI@2
  displayName: ".NET build"
  inputs:
    projects: '**/*.csproj'
    arguments: --configuration $(BuildConfiguration) --no-restore

- task: DotNetCoreCLI@2
  displayName: ".NET publish package"
  inputs:
    command: publish
    arguments: '--configuration $(BuildConfiguration) --no-restore --output $(Build.ArtifactStagingDirectory)/app/pkg'

I still get errors.

It's still doing the same thing.

Starting NuGet restore

Task : NuGet Description : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task. Version : 2.147.6 Author : Microsoft Corporation Help : More Information h t t p s ://go.microsoft.com/fwlink/?LinkID=613747

Caching tool: NuGet 4.1.0 x64 Found tool in cache: NuGet 4.1.0 x64 Resolved from tool cache: 4.1.0 Using version: 4.1.0 Found tool in cache: NuGet 4.1.0 x64 SYSTEMVSSCONNECTION exists true SYSTEMVSSCONNECTION exists true [command]C:\windows\system32\chcp.com 65001 Active code page: 65001 Detected NuGet version 4.1.0.2450 / 4.1.0 SYSTEMVSSCONNECTION exists true Saving NuGet.config to a temporary config file. [command]C:\hostedtoolcache\windows\NuGet\4.1.0\x64\nuget.exe sources Add -NonInteractive -Name NuGetOrg -Source https://www.nuget.org/api/v2/ -ConfigFile d:\a\1\Nuget\tempNuGet_57.config Package Source with Name: NuGetOrg added successfully. Saving NuGet.config to a temporary config file.

Why is it even doing a Nuget Restore when it is no longer in my YML file?

2
Try to add this noCache: true to the NuGet restore task.Shayki Abramczyk
I'd be surprised if it works on Ubuntu, given the task description: Uses NuGet.exe. If this is a .NET Core application, use dotnet restore.Daniel Mann
No luck it's still doing the same thing.Jonas Arcangel
I ended up using the YML file in the Microsoft Docs sample and using windows-2019. It worked. github.com/MicrosoftDocs/pipelines-dotnet-core/blob/master/…Jonas Arcangel

2 Answers

1
votes

This is working for me

- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.9.x'
  inputs:
    versionSpec: 4.9.x

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Pipeline.TriggerDirectory)/Library.sln'
    vstsFeed: '[your feed here]'
    noCache: true

Log

Tool install

[section]Starting: Use NuGet 4.9.x
========================================================================= Task : NuGet Tool Installer
Description : Acquires a specific version of NuGet from the internet or the tools cache and adds it to the PATH. Use this task to change the version of NuGet used in the NuGet tasks.
Version : 0.145.0
Author : Microsoft Corporation
Help : More Information
========================================================================= You are using a query match on the version string. Behavior changes or breaking changes might occur as NuGet updates to a new version. Downloading: https://dist.nuget.org/win-x86-commandline/v4.9.3/nuget.exe
Caching tool: NuGet 4.9.3 x64
Using version: 4.9.3
Found tool in cache: NuGet 4.9.3 x64
Using tool path: C:\hostedtoolcache\windows\NuGet\4.9.3\x64 Prepending PATH environment variable with directory: C:\hostedtoolcache\windows\NuGet\4.9.3\x64
[section]Finishing: Use NuGet 4.9.x

Package restore

[section]Starting: NuGet restore ========================================================================= Task : NuGet
Description : Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
Version : 2.147.6
Author : Microsoft Corporation
Help : More Information
========================================================================= SYSTEMVSSCONNECTION exists true
SYSTEMVSSCONNECTION exists true
[command]C:\windows\system32\chcp.com 65001
Active code page: 65001
Detected NuGet version 4.9.3.5777 / 4.9.3+e5150f1e119e456e01c4f1e413213d392eda1c3a
SYSTEMVSSCONNECTION exists true
Saving NuGet.config to a temporary config file.
[command]C:\hostedtoolcache\windows\NuGet\4.9.3\x64\nuget.exe

1
votes

The tools installer and NuGet tasks are more appropriate for Windows machines. Since you're using an Ubuntu agent, just use the dotnet restore command:

- task: DotNetCoreCLI@2
  inputs:
    command: restore