Publishing prerelease NuGet packages with dotnet CLI in Azure DevOps - azure-devops

I have been playing with a pipeline but still haven't found a way to make dotnet pack in Azure DevOps create version "2021.10.22-alpha.1" (template is YYYY.MM.DD-alpha.Rev) for my library. I wasn't able to find a way to specify "alpha" at anywhere (yes, I tried everything).

I've finally found it.
Set "Automatic package versioning" to off so no Version is passed
to MSBuild. Otherwise it'd ignore any suffixes or prefixes
In
"Additional build properties" set
VersionSuffix=foo;VersionPrefix=$(Build.BuildNumber)
Adjust
BuldNumber format in the Options section of the pipeline if need
Now my package version is "2021.10.22.8-foo". It's still not ideal but I'm on the right way.

Related

Pipeline on Azure Devops is failing

a month ago we had a solution (big one) in .net framework 4.7.2. This was building fine on azure devops pipeline.
Now we ported our solution to net5.
Everything is working in visual studio but on azure devops, the pipeline is failing.
We had to change our Microsoft.Interop.Word (and excel, and outlook) to a com reference. Because net5 is multiplatform and interop is not.
Because we removed the nuget packages and changed to com reference the pipeline is failing.
Does anyone know how to handle this specific problem?
We can't remove the interop.excel and etc from our projects because they are dependent on it.
Beneath you see the result we have.
It feels like we have tried everything to make it work again on azure devops.
have you consider self-hosted agent since you have requirement to stay the external library in this case Microsoft.Office.Interops and I don't think Microsoft Azure DevOps Pipeline agent support that currently.
With self-hosted agent, you install the PIAs and link your library/com references to the paths.
There is problem with assembly in the code, your code may be building on local environment as it is getting references for all assemblies however when you checking in the code pipelines could not fetch the assemblies through nuget package restore, if you are referencing assembly from local machine, make sure you add its nuget package reference package.config file, so nuget restore will restore the package
can you try below
Link

Azure DevOps keep NLog configuration on Release, when Nuget Packaging updates

I am trying to keep my NLog configurations, when I do a release from Azure Devops. The Nuget Package portion overwrites my NLog configurations and sets it back to default. I would like to know how to preserve my configurations when I release my build, but keep the Nuget Packages update to date for the other packages.
You need to remove the NLog.Config package for that.
It's documented here: https://www.nuget.org/packages/NLog.Config
Note: Unfortunately this package won't work well when using
Advised to:
download manually: https://raw.githubusercontent.com/NLog/NLog/dev/src/NuGet/NLog.Config/content/NLog.config
set "Copy To Output Directory" to "Copy if newer"

Configuring Nuget pack for prerelease on VSTS

Note
If there is an easier way to create prerelease packages please let me know!
I am using Visual Studio Team Services and have setup a nuget pack and publish step.
I have a build variable called $(BuildSuffix) that allows me to tag build-specific variables onto the end of the build number format like so
$(Build.DefinitionName)_1.0.$(date:yyyy)$(date:MM)$(date:dd)$(rev:.r)$(BuildSuffix)
The idea then is that I can set $(BuildSuffix) to -beta so that my final build version might be Build_1.0.20170119.2-beta.
According to the nuget documentation here, appending -beta to a build number will create a prerelease package. The build in VSTS comes out with -beta appended but the nuget pack stage never seems to contain it. It always comes out as the exact version number but without the -beta tag.
My nuspec files look like this:
<package >
<metadata>
<id>MyCompany.Data</id>
<version>$version$</version>
My NuGet package step looks like this:
After some research and bashing my head against a brick wall I figured out how. You have to:
Configure a local Build Agent
Install Nuget CLI
On Nuget Packager Task set Path To NuGet.exe to the NuGet CLI
Set NuGet Arguments on the same screen to -suffix beta
With new NuGet task(version 2) you can specify Additional build properties and there you can pass your custom build number directly instead of using -suffix NuGet argument. Additional build properties are substituting $token$ with supplied value in nuspec and you are free to change whatever you want in there.
I also see it on your screenshot, but I never tried to use it like this with older NuGet tasks as those are deprecated now.
Maybe it will be helpful to try import NuGet Packaging Task Group definition I am using on my private projects. Check it out Here.

How to remove the [warning]To connect to NuGet feeds when restoring NuGet packages

I've got a build running in VSTS which is restoring NuGet packages from both nuget.org and a custom feed in VSTS. The custom feed is in the solutions NuGet.config as a <packageSource>, along with the user name and password in <packageSourceCredentials>
The build, including the restore, is working Ok, but there is a warning ...
2016-10-12T16:18:57.6589001Z ##[warning]To connect to NuGet feeds
hosted in your Team Services account/TFS project collection with
NuGet 3.1 or below, edit your build definition to specify a path
to a NuGet.config containing the package sources you wish to use.
How can I remove this?
Based on my test, that warning remains even through using higher version of nugget (e.g. 3.3) or do not restore package from VSTS feed. (Hosted build agent has the same result).
You can’t remove it unless you custom a build task to restore package through command line.
I submit a issue here.
Update:
The issue has been updated.
I see the issue in the code coming from our transition from depending
on assets coming with the agent to being deployed with the task. You
can get around this for now until we get an official change out by
either (1) choosing to use the Nuget 3.5 version radio button in the
task config or (2) supplying a path to your nuget.config.
So, you can use Nuget 3.5 version or specify nuget.config file.

Can I publish symbols to VSTS?

I'm currently publishing some NuGets to my VSTS feed. Is there support for VSTS acting as a Symbol Server as well so I can publish my symbol packages?
You can publish your symbols to a file share. There is not presently support for using VSTS itself as a symbol server.
It is now possible to use VSTS as a symbol server
I've also written a blog post on how to setup a symbol-server using a VSTS build definition where the symbols are published on a file share. It's actually more as a step-by-step guide on how to publish and expose them via IIS
Checkout Source Link. It is becoming a new standard or at least recommended way.
SourceLink is a language- and source-control agnostic system for providing first-class source debugging experiences for binaries. The goal of the project is to enable anyone building NuGet libraries to provide source debugging for their users with almost no effort. Microsoft libraries, such as .NET Core and Roslyn have enabled SourceLink. SourceLink is supported by Microsoft.
In a case of VSTS Git repository and .Net Core project
Add nuget reference of Microsoft.SourceLink.Vsts.Git to your project - the one which will be dotnet pack later (as of now in preview - make sure you tick "Include prereleases" in VS Nuget Manager)
Add <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder> into PropertyGroup where the TargetFramework element is.
Add .NET Core task with command pack
The nuget package will now contain PDB files so you clients can easily debug your library.