Reputation: 303
I have created a simple class library in .net standard 2.0 with a few nuget dependencies like Dapper.
I am using Team Foundation Server 16 to then build and package the project. My issue is, that when I then browse to my new NuGet package, it does not list it's dependencies in the NuGet package manager in VS and I have to install them manually afterwards.
Creating a nuget package of the same class library from Visual Studio 2019 locally works as intended.
My build tasks on TFS are:
The NuGet pack uses default settings with command "pack" and path pointing only to .csproj file.
Upvotes: 0
Views: 669
Reputation: 28086
Creating a nuget package of the same class library from Visual Studio 2019 locally works as intended.
It's one issue about nuget pack
command. When you pack the .net standard
project in VS locally, it(right-click=>pack button) actually calls dotnet cli
instead of nuget.exe
to do the pack
job.
For now, nuget pack
command can't work well with those projects that use PackageReference
to manage nuget packages. (Including .net framework
projects with PackageReference
,.net core
and .net standard
projects).
More details see discussions here and here.
To resolve that issue(For TFS2017 and above):
Use dotnet pack command instead of nuget pack command. And for pipeline in tfs, use dotnet restore, build, pack tasks instead of nuget restore, nuget pack tasks.
Update1 for TFS2016:
Since TFS will run those tasks in tfs agents, one alternative way is to install .net core sdk
manually, and then use command-line task to execute dotnet pack
command to create nuget packages.
.net core sdk
download link here.
Update2:
Also, we can still use nuget pack
command/task. To include those dependencies, we need to create an extra xx.nuspec file with content similar to this:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>PackageName</id>
<version>1.0.0</version>
<title>xxx</title>
<authors>xxx</authors>
<owners>xxx</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<description>xxx</description>
<releaseNotes>xxx</releaseNotes>
<copyright>Copyright 2020</copyright>
<tags>Tag1 Tag2</tags>
<dependencies>
<dependency id="Dapper" version="1.30.0"/>
//define other dependencies manually here.
</dependencies>
</metadata>
</package>
Place this file in same directory where xx.csproj
exists, and then nuget pack
command/task can now create the package with dependencies.
Upvotes: 2