Presently sponsored by ScriptRunner
Get your free PowerShell Security e-Book!
If you're using Azure DevOps (also known as VSTS), and you work with dotnet core in any capacity, perhaps you're migrating from one version to the next - as I was for some of my projects.
An error that struck me was the following (redacted for clarity and brevity in the post):
Errors in D:\a\1\s\Zimmergren.Demos.API\Zimmergren.Demos.Web\Zimmergren.Demos.Web.csproj Package Microsoft.Extensions.FileProviders.Physical 2.0.0 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.Extensions.FileProviders.Physical 2.0.0 supports: netstandard2.0 (.NETStandard,Version=v2.0) Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.1 is not compatible with netcoreapp2.1 (.NETCoreApp,Version=v2.1). Package Microsoft.VisualStudio.Web.CodeGeneration.Contracts 2.0.1 supports: netstandard2.0 (.NETStandard,Version=v2.0) One or more packages are incompatible with .NETCoreApp,Version=v2.1.) 2018-09-25T16:14:46.1605781Z ##[error]Packages failed to restore 2018-09-25T16:14:46.1623512Z ##[section]Finishing: NuGet restore
It clearly states that
One or more packages are incompatible with .NETCoreApp,Version=v2.1.)
This struck me as odd, as I know for a fact that a lot of the packages I use that got this error message indeed have support for the latest incarnation of dotnet core.
When I examined the logs of the pipeline execution, I noticed that it didn't use the latest version and it tried to fetch version
4.1.0 from the cache:
2018-09-25T16:11:54.8393379Z Caching tool: NuGet 4.1.0 x64 2018-09-25T16:11:54.8524100Z Found tool in cache: NuGet 4.1.0 x64 2018-09-25T16:11:54.8878912Z Resolved from tool cache: 4.1.0 2018-09-25T16:11:54.8880712Z Using version: 4.1.0 2018-09-25T16:11:54.8883410Z Found tool in cache: NuGet 4.1.0 x64
Solution: Create a "NuGet Tool Installer" task
The solution was very simple, once figuring out what the culprit was. The default version of NuGet running in the VSTS pipeline was not the latest one - so I tried to grab the latest one instead, which you can do by creating a "NuGet Tool Installer" task and point it to a
Version of NuGet.exe to install, which you simply specify the version number of the desired NuGet.exe you want to execute in the build.
It looks something like this:
Once this have been properly configured, the builds all succeeded using the latest incarnation of .net core, which in my case was v2.1.
Join the newsletter to receive the latest updates in your inbox.