Myget and VSTS integration - azure-devops

I'm using VSO to host and build my code. I also followed these steps MyGet with Visual Studio Team Services to have the packages available as myget feed but someone the feeds are always empty. I only have the 'Nuget Package' build step but it seems to me that I will also need the 'Nuget Publisher' is that the case?

You don’t need to add Nuget Publisher step/task to publish package, need to make sure the package is in the build drop (Publish Build Artifacts)
Simple steps:
Create a new build definition
(Optional) Add NuGet Installer
Add Visual Studio Build step/task to build your solution/project
Add NuGet Packager step/task (Path to csproj: ***.csproj; Package Folder: $(build.artifactstagingdirectory))
Add Publish Build Artifacts (Path to Publish: $(build.artifactstagingdirectory); Artifact Name: drop; Artifact Type: Server)
Save build definition
Open feed of your myget
Click Package sources
Click Add package source >Visual Studio Team Services Build Definition. (refer to Deploy a package built on Visual Studio Team Services)
Queue previous build on VSTS
Wait some minutes and check package in myget.

Related

conditionnally select nuget package during build

Our build environment is VSTS pipeline and our development environment is visual studio.
We are using dev branches (or feature branches) and we have a main branch (master branch).
As piece of code are getting stable and don't need much debug, We are now willing to split our projects into nuget packages.
As long as we are in dev or feature branch, we want to generate and use the -alpha nuget package to test and use the latest code.
But as soon as we are doing a pull request to the master branch, we want to use the stable nuget package.
Of course, without having to manually go to the nuget package manager and update every nuget package before committing;
Said differently, every project in a dev branch should automatically build with the -alpha version of each nuget package and the build of the master branch should be with the stable version of the package.
How can we create a vsts pipeline to achieve this
conditionnally select nuget package during build
You could add a task (powershell or batch) to modify the nuget.config or the project file to update the package version with condition.
steps:
- powershell: |
# Write your PowerShell commands here.
update the package version in the nuget.config or project file.
displayName: 'Update package version'
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
You create two (build) pipelines:
Dev / Feature you name it -> gets triggered by your feature/* branches and publishes your -aplpha nuget package
Stable / Prod -> gets triggered by pull requests into the main branch and publishes the stable nuget package
I personally don't have much experience with YAML, yet, but in the classic pipeline editor you can easily add tasks. Each pipeline should roughly be looking like this:
Some more details:
Missing on the screen shot is the important trigger part. You can also edit that in the classic pipeline editor in the "trigger" tab. There you choose your feature branch setting (e.g. feature/*) and exclude the master on the feature pipeline.
Converting all to YAML should be straight forward via the "View YAML" feature in the classic web editor.
Depending on your private setup you might need extra steps like NuGet auth if you use a private NuGet server etc..

Azure DevOps Pipeline not downloading reference

I'm relatively new to Azure DevOps, but I've already created 4 other pipelines that are working. I'm running into trouble with a build pipeline that is not pulling in NuGet references. I added the Task NuGet restore, but it's only getting some of the packages.
It works when I build in Visual Studio 2017. If I do a nuget restore from the command line, some of the packages are fetched. When I build, Visual Studio fetches the additional packages at the beginning of the build. Why is the NuGet restore task not fetching all of the packages? Why are the remaining packages fetched during the Visual Studio build, but not during the Azure DevOps build?
My project is old legacy ASP.NET that my boss wants automated. I'm talking the version of ASP.NET with .ASPX files that preceded MVC.
This is the error from the Azure DevOps build:
[error]WebApp\web.config(95,0): Error ASPCONFIG: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
For this issue , first, make sure to select vs2017-win2016 agent when running the pipeline.
Secondly you can try to install the latest nuget.
Another possibility for your issue could be that some packages used by your project is not hosted in nuget.org. If part of the packages used locally are hosted in private server or local package source, the online Nuget Restore Task can't download the mssing packages. Please check your packages.config and project file to make sure all your packages are hosted in nuget.org.

Nuget packages included in artifacts automatically

We have a TeamCity build server and for a time were had the internal Nuget server enabled. We'd generate Nuget packages, which it'd automatically publish to the nuget feed.
We've since moved to another Nuget server and disabled the TC internal Nuget server; additionally we started building Nuget packages using OctoPack in some configurations which never built them before. The problem is that these Nuget packages seem to automatically be added to the build configuration's Artifacts. This is a waste, since the same packages are being published to the external (to TeamCity) Nuget server.
Is there a setting which automatically will find and include Nuget packages in TeamCity's artifacts, or is it just doing this on its own? I cant even explicitly exclude the packages in the configuration's artifacts setting, they get included regardless.
TeamCity is version 2018.1.2.
New packages in built-in TeamCity NuGet feeds could be added via the followings ways.
So to avoid publishing produced nuget packages as a build artifacts inspect:
Artifact paths settings in your build configuration
NuGet Pack build steps settings: uncheck "Publish created packages to build artifacts" option
NuGet Publish build steps settings: don't specify TeamCity built-in NuGet feed URLs in "Package source" field.

Nuget push teamcity URL

My I know what should I put in WhatShouldIPutInHere? I want to push my nuget to my team city server. it is on localhost:90. Thanks
[Exec] C:\TeamCity\buildAgent\work\f091ac5edf11aa03\packages\OctoPack.3.5.2\build\OctoPack.targets(109, 5): error MSB3073: The command ""C:\TeamCity\buildAgent\work\f091ac5edf11aa03\packages\OctoPack.3.5.2\build\nuget.exe" push "C:\TeamCity\buildAgent\work\f091ac5edf11aa03\TodoWebApp\obj\octopacked\TodoWebApp.1.0.26.nupkg" MyAPiKey -Source WhatShouldIPutInHere? "
A regular nuget push (what OctoPack is trying to do) is not going to work.
The TeamCity documentation states
You can publish packages to the feed either as build artifacts of the NuGet Pack build step (using the Publish created packages to build artifacts checkbox, packages will be indexed asynchronously) or via the NuGet Publish build step (since TeamCity 2017.1, packages will be indexed synchronously)
Make sure that OctoPack only creates a package (and not trying to push it) and make it an artifact to add it to the TeamCity NuGet Server.

TeamCity can't find Nuget

I have a build set up on Team City but can't seem to get NuGet to restore the packages. My build configuration has two steps: Restore Nuget, then Build the solution. I have set up NuGet on TeamCity, so when I create a NuGet build step, I can choose a NuGet version from the drop down:
But when I build, it cant find NuGet:
Failed to find NuGet executable NuGet.CommandLine.3.3.0.nupkg. Check the version is listed in NuGet server settings tab.
Why cant it find NuGet?
UPDATE