Reputation: 21
We have an existing Devops pipeline set up to use .Net Core tasks to package and push a .Net Standard class library as a Nuget artifact. We are trying to replace this with a pipeline that uses Nuget tasks--we are using Nuget Pack and Nuget Push. We haven't been able to get the package name created by the Nuget tasks to match the package name we had been using when packaging with the .Net Core tasks.
The .Net Core tasks were pulling the package name from the PackageId specified in the .csproj file. The Nuget task appears to be pulling it from the Assembly name of the project. Is there a way to configure the pacakge name with Nuget tasks?
Upvotes: 2
Views: 2409
Reputation: 202
I don't have the specific answer to your question but if you are working on Net core projects what worked for me is setting the project to generate the nuget on build task. Look for GeneratePackageOnBuild in the csproj. This will create the nuget each time is built with the properties on your csproj.
If you don't set AssemblyName the package name will be the same as your csproj filename..
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Company>ACME inc</Company>
<Version>1.1.0</Version>
<AssemblyName>YourPackageID</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
</PropertyGroup>
</Project>
You won't need to pack anything, just push the nupkg in the build directory. The Nuget Push task just needs a regex like this -the path may contain multiple regex expresions:
$(Build.SourcesDirectory)/**/**/*.nupkg;$(Build.SourcesDirectory)/**/**/**/*.nupkg;
Upvotes: 4