VSTS Release Task - Push to Nuget - nuget

I'm trying to set up CI for my Core projects and wrappers to our vsts nuget feed.
I've followed the Zen of Package Management tutorial here.
It's a little out of date, but I believe I managed to translate the changes.
My Build seems to work fine, it builds and packages the dll's into several nuget packages.
The release seems to work also, but the Nuget Feed is not updated with the latest packages.
My Release task is only one task as shown in the image below.
The log shows that it found and downloaded the packages, but it does not show any success on the actual push to nuget.
This is the log that shows the packages being found, and successful completion.
2017-11-15T02:40:59.5675003Z ##[section]Finishing: Initialize Job
2017-11-15T02:40:59.6125167Z ##[section]Starting: Download Artifacts
2017-11-15T02:41:00.2861639Z Downloading artifact
2017-11-15T02:41:00.2961643Z Creating artifacts directory: d:\a\r1\a
...etc
2017-11-15T02:41:00.8313684Z Downloading file d:\a\r1\a\Satalyst-Visual Studio-CI\drop\release\Packaged\Satalyst.AzureWrapper.Domain.2.0.0.3.nupkg
2017-11-15T02:41:00.9943663Z Downloading file d:\a\r1\a\Satalyst-Visual Studio-CI\drop\release\Packaged\Satalyst.PaymentGateway.Interfaces.2.0.0.3.nupkg
2017-11-15T02:41:00.9998063Z Downloading file d:\a\r1\a\Satalyst-Visual Studio-CI\drop\release\Packaged\Satalyst.PaymentGateway.Test.2.0.0.3.nupkg
...etc
2017-11-15T02:41:01.0750176Z Download complete.
2017-11-15T02:41:01.0761342Z 16 placed file(s): 16 downloaded, 0 empty
2017-11-15T02:41:01.0830178Z 1 MB downloaded at 1491 KB/sec. Download time: 00:00:00.2761869.
2017-11-15T02:41:01.0830178Z Downloaded linked artifact Satalyst-Visual Studio-CI
2017-11-15T02:41:01.0830178Z Finished artifacts download
2017-11-15T02:41:01.0890187Z ##[section]Finishing: Download Artifacts
... its this bit below that succeeds, but the feed does not show the new packages??
2017-11-15T02:41:01.0920188Z ##[section]Starting: NuGet Publish
2017-11-15T02:41:01.1190170Z ==============================================================================
2017-11-15T02:41:01.1190170Z Task : NuGet
2017-11-15T02:41:01.1190170Z 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.
2017-11-15T02:41:01.1190170Z Version : 2.0.15
2017-11-15T02:41:01.1190170Z Author : Microsoft Corporation
2017-11-15T02:41:01.1190170Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2017-11-15T02:41:01.1190170Z ==============================================================================
2017-11-15T02:41:04.1372760Z Caching tool: NuGet 4.1.0 x64
2017-11-15T02:41:04.1502760Z Found tool in cache: NuGet 4.1.0 x64
2017-11-15T02:41:04.1612765Z Resolved from tool cache: 4.1.0
2017-11-15T02:41:04.1612765Z Using version: 4.1.0
2017-11-15T02:41:04.1612765Z Found tool in cache: NuGet 4.1.0 x64
2017-11-15T02:41:05.1667858Z [command]C:\Windows\system32\chcp.com 65001
2017-11-15T02:41:05.1667858Z Active code page: 65001
2017-11-15T02:41:05.1877908Z ##[section]Finishing: NuGet Publish
2017-11-15T02:41:05.1937859Z ##[section]Finishing: Release
Any assistance would be greatly appreciated, I've been doing a bit of trial and error to find the issue with no success. I'm now a bit stuck with no error messages and no feedback on the outcome for the push.

It's caused by the configuration of Path to NuGet package(s) to publish option for NuGet Push task in your release definition.
Please change the Path to NuGet package(s) to publish as:
$(System.DefaultWorkingDirectory)/**/packed/*.nupkg
Then the nuget package should be published to your feed correctly.

Related

How to run nuget package (tool) from artifact feed

I'm begginer to devops. And I got a task to create 2 pipelines. One for building project and publishing it to artifact feed. And another pipeline is to run that tool.
First one I have created (created nuget as a tool and placed in my feed).
How can I now create pipeline that will do dotnet run but from my feed?
I just need guidance a big picture.
I'm trying something like this:
pool:
vmImage: windows-latest
jobs:
- job: RunTool
displayName: Run Tool
steps:
- task: DotNetCoreCLI#2
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install -g --add-source=https://pkgs.dev.azure.com/EPMC-STC/ab5c31ad-1d77-4369-80f4-ff2f14a12667/_packaging/MilanDjukicFeed/nuget/v3/index.json MigrationApp --version 8.0.18'
I'm getting:
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate run 'dotnet dev-certs https --trust' (Windows and macOS only).
Learn about HTTPS: https://aka.ms/dotnet-https
----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
C:\Users\VssAdministrator\AppData\Local\Temp\d49e97f8-e901-42d7-8c3e-d1eca71c6055\restore.csproj : error NU1301: Unable to load the service index for source https://pkgs.dev.azure.com/EPMC-STC/ab5c31ad-1d77-4369-80f4-ff2f14a12667/_packaging/MilanDjukicFeed/nuget/v3/index.json.
The tool package could not be restored.
Tool 'migrationapp' failed to install. This failure may have been caused by:
* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.
For more reasons, including package naming enforcement, visit https://aka.ms/failure-installing-tool
##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects :
Finishing: DotNetCoreCLI
On Artifacts I have MigrationApp nuget package. I can download it and run it localy.
Since you are creating Nuget as tool and need to use it in pipeline, you can use dotnet tool install command to install the Nuget tool and define the feed source.
For example: Add a command line task/ Bash task/ PowerShell
dotnet tool install -g --add-source=https://pkgs.dev.azure.com/<org-name>/<projectname>/_packaging/<feedname>/nuget/v3/index.json toolname
Then you can use the nuget tool in next tasks.
On the other hand, if you need to download the Nuget Package, you can use the task: Download package task to download the nuget package from feed and do next actions.

How can i create a manual VSTS release to NuGet?

Possible related, but seems outdated: VSTS Release Task - Push to Nuget
I have a open-source project on GitHub, which is setup to do a build on VSTS.
Now, i would like to have a VSTS Release definition, which publishes my package to NuGet. I would like to do this manually..so don't want it part of my VSTS build.
Can someone point me to the best resource on how to do this?
Here's my Release Definition:
and pertinent part of logs:
2018-03-26T03:05:29.4416011Z Downloading artifacts from: https://rpm1984.visualstudio.com//_apis/resources/Containers/1753137?itemPath=drop&isShallow=true&api-version=4.1-preview.4
2018-03-26T03:05:29.6204337Z Downloading drop/RedditSentimentAnalyzer.1.0.0-CI-20180322-025919.nupkg to D:\a\r1\a\Master CI\drop\RedditSentimentAnalyzer.1.0.0-CI-20180322-025919.nupkg
2018-03-26T03:05:29.6248792Z Downloaded drop/RedditSentimentAnalyzer.1.0.0-CI-20180322-025919.nupkg to D:\a\r1\a\Master CI\drop\RedditSentimentAnalyzer.1.0.0-CI-20180322-025919.nupkg
2018-03-26T03:05:30.4524266Z Total Files: 1, Processed: 1, Skipped: 0, Failed: 0, Download time: 1.007 secs, Download size: 10227Bytes
2018-03-26T03:05:30.5070857Z Successfully downloaded artifacts to D:\a\r1\a/Master CI
2018-03-26T03:05:30.5101258Z ##[section]Finishing: Download artifact - Master CI
...
2018-03-26T03:05:30.5119489Z ##[section]Starting: Use NuGet 4.3.0
2018-03-26T03:05:30.5122745Z ==============================================================================
2018-03-26T03:05:30.5122980Z Task : NuGet Tool Installer
2018-03-26T03:05:30.5123255Z Description : Acquires a specific version of NuGet from the internet or the tools cache and adds it to the PATH. Use this step to change the version of NuGet used in the NuGet steps.
2018-03-26T03:05:30.5123505Z Version : 0.1.5
2018-03-26T03:05:30.5123696Z Author : Microsoft Corporation
2018-03-26T03:05:30.5123904Z Help : [More Information](https://go.microsoft.com/fwlink/?linkid=852538)
2018-03-26T03:05:30.5124656Z ==============================================================================
2018-03-26T03:05:31.7510971Z Downloading: https://dist.nuget.org/win-x86-commandline/v4.3.0/nuget.exe
2018-03-26T03:05:31.8479515Z Caching tool: NuGet 4.3.0 x64
2018-03-26T03:05:31.8600552Z Using version: 4.3.0
2018-03-26T03:05:31.8602827Z Found tool in cache: NuGet 4.3.0 x64
2018-03-26T03:05:31.8603258Z Using tool path: D:\a\_tool\NuGet\4.3.0\x64
2018-03-26T03:05:31.8605921Z Prepending PATH environment variable with directory: D:\a\_tool\NuGet\4.3.0\x64
2018-03-26T03:05:31.8723553Z ##[section]Finishing: Use NuGet 4.3.0
...
123456789101112
2018-03-26T03:05:31.8764514Z ##[section]Starting: Push artifact to NuGet2018-03-26T03:05:31.8770703Z ==============================================================================2018-03-26T03:05:31.8770932Z Task : NuGet2018-03-26T03:05:31.8771244Z 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.2018-03-26T03:05:31.8771593Z Version : 2.0.242018-03-26T03:05:31.8771774Z Author : Microsoft Corporation2018-03-26T03:05:31.8772001Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)2018-03-26T03:05:31.8772231Z ==============================================================================2018-03-26T03:05:33.2855694Z [command]C:\Windows\system32\chcp.com 650012018-03-26T03:05:33.3914203Z Active code page: 650012018-03-26T03:05:33.4169477Z ##[section]Finishing: Push artifact to NuGet
2018-03-26T03:05:31.8764514Z ##[section]Starting: Push artifact to NuGet
2018-03-26T03:05:31.8770703Z ==============================================================================
2018-03-26T03:05:31.8770932Z Task : NuGet
2018-03-26T03:05:31.8771244Z 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 a
Find
No Results
```
You can use Nuget task and choose push command:

Publish prerelease (alpha) version using VSTS

I try to pack and publish a package as prelease on VSTS.
In the build step: dotnet (2* preview) pack I set a custom build number:
Automatic package versioning: use the build number.
Options:
$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)-alpha
It seems to build correctly:
Build #aspcore-repository (sqlserver)_2018.1.29.5-alpha has been
queued.
But in the pack step it loses the -alpha in the version and it is not published as a prelease package:
[command]"C:\Program Files\dotnet\dotnet.exe" pack
d:\a\1\s\SqlServer\Citolab.Repository.SqlServer.csproj --output
d:\a\1\a /p:PackageVersion=2018.1.29.3 --verbosity Detailed
What should I do to publish the package as prelease version?
This is a bug/feature of using the BuildNumber as your version source. I've submitted a pull request, but it hasn't been taken into the Nuget tasks yet. as a workaround use Environment Variable instead of Build Number and set the value to: BUILD_BUILDNUMBER.

CakeBuild: Get failed to install tool 'NUnit.ConsoleRunner'

I used CakeBuild to build and test my Xamarin Portable Class Library.
In the build.cake script I defined that I want to use the NUnit-Console to run my testcases. So I do
#tool nuget:?package=NUnit.ConsoleRunner
Unfortunatelly I get the following error when I run the Cake script.
Preparing to run build script...
VERBOSE: Restoring tools from NuGet...
VERBOSE: Feeds used:
C:\Users\bergkar\.nuget\packages\
All packages listed in C:\dev\Xamarin\fleetboard-core-library\tools\packages.config are already installed.
Running build script...
Analyzing build script...
Processing build script...
Installing tools...
Unable to find package 'NUnit.ConsoleRunner'
NuGet exited with 1
Could not find any relevant files for tool 'NUnit.ConsoleRunner'. Perhaps you need an include parameter?
Error: Failed to install tool 'NUnit.ConsoleRunner'.
When I add a specific version I want to use like below then everything works fine.
#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0
Can someone tell me why it is not working without the version stuff?
With ".\build.ps1 -Verbosity Diagnostic" I get the following output:
Preparing to run build script...
Running build script...
Module directory does not exist.
Analyzing build script...
Analyzing C:/dev/Xamarin/fleetboard-core-library/build.cake...
Processing build script...
Installing tools...
Installing NuGet package NUnit.ConsoleRunner...
Executing: "C:/dev/Xamarin/fleetboard-core-library/tools/nuget.exe" install "NUnit.ConsoleRunner" -OutputDirectory "C:/d
ev/Xamarin/fleetboard-core-library/tools" -ExcludeVersion -NonInteractive
Unable to find package 'NUnit.ConsoleRunner'
NuGet exited with 1
Feeds used:
Output:
Feeds used:
Could not find any relevant files for tool 'NUnit.ConsoleRunner'. Perhaps you need an include parameter?
Error: Cake.Core.CakeException: Failed to install tool 'NUnit.ConsoleRunner'.
at Cake.Core.Scripting.ScriptProcessor.InstallTools(ScriptAnalyzerResult analyzerResult, DirectoryPath installPath)
at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
at Cake.Commands.BuildCommand.Execute(CakeOptions options)
at Cake.CakeApplication.Run(CakeOptions options)
at Cake.Program.Main()
Now I found my problem and solved it.
The problem was that the NuGet.exe did not has a source feed which points to a public nuget source like "https://api.nuget.org/v3/index.json".
This was because my default NuGet.conf in under "C:\Users\YOUR_USER_HOME\AppData\Roaming\NuGet" had no packageSource defined. So Nuget just knows the local nuget package cache under "C:\Users\YOUR_USER_HOME.nuget\packages" and this did not include the specified package.
So after I added a packageSource in "C:\Users\YOUR_USER_HOME\AppData\Roaming\NuGet\NuGet.Conf" everything works fine.
Another way can be to add a new NuGet.Conf beside your build.ps1 file which contains all package sources you need for CakeBuild and your Xamarin project.
The following page explains how Nuget finds its configuration. Maybe this is helpful to understand the mechanism NuGet uses to find its configuration:
https://learn.microsoft.com/en-us/nuget/consume-packages/configuring-nuget-behavior

Team Services: Nuget Packager task failing

I have a Build definition in Team Services that includes a Nuget Packager task. I'm using Hosted build agents.In the last couple of builds this task began to fail, with the following message:
2017-02-22T21:43:24.9318762Z C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\2.112.0\externals\nuget\NuGet.exe pack "D:\a\1\s\src\app\Ormie\Ormie.csproj" -OutputDirectory "D:\a\1\s" -Properties Configuration=release
2017-02-22T21:43:25.5460318Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
2017-02-22T21:43:25.5460318Z Attempting to build package from 'Ormie.csproj'.
2017-02-22T21:43:25.7480272Z Packing files from 'D:\a\1\s\src\app\Ormie\bin\Release'.
2017-02-22T21:43:25.9040273Z Using 'Ormie.nuspec' for metadata.
2017-02-22T21:43:26.1645370Z ##[error]'System.Collections' already has a dependency defined for 'Microsoft.NETCore.Platforms'.
2017-02-22T21:43:26.1865365Z ##[error]System.Exception: Unexpected exit code 1 returned from tool NuGet.exe
2017-02-22T21:43:26.1865365Z at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord()
2017-02-22T21:43:26.1865365Z at System.Management.Automation.CommandProcessor.ProcessRecord()
2017-02-22T21:43:26.2015355Z ##[error]PowerShell script completed with 1 errors.
2017-02-22T21:43:26.2025352Z ##[section]Finishing: NuGet Packager
In order to understand what was happening, I tried to create the package in my development box, using NuGet version 3.3, and got a similar message. So, I've updated NuGet to version 3.5, tried to pack in my machine and it worked just fine.So, my questions are:
Is there any kind of configuration in Team Services Build Definition
that can be done to solve this issue?
How can I force the Hosted build agent to use version 3.5 in the
NuGet Packager task?
To use nuget3.5 for nugget packager task, you can add nugget.exe to source control, and then use $(Build.SourcesDirectory)\nuget.exe as path to nugget.exe.
For Nuget Restore and Nuget Publisher Tasks, they define 3.3 and 3.5 in their tasks. You can view task.json for all tasks definitions in VSTS task.
If you want Nuget Packager also can choose nugget version, you should develop your own task same as Nuget Packager function and with nuget version to choose.