0

We are generating nuget packages on Azure pipelines using the the "nuget pack" task. But when we search up the package in visual studio it lists the package name followed by the text "by VssAdministrator"

We would like it to say "by OurCompanyName" but I can't find any option in the task to do this, nor any documentation on it, nor any results on google talking about how to set this value. I'm not even sure what the value is called. Package creator? manufacturer? developer?

Any help would be appreciated. Thanks.

Mark Mercer
  • 105
  • 7

2 Answers2

1

I think you are probably missing the description in the csproj you are generating the package from.

You can look at this documentation: https://learn.microsoft.com/en-us/nuget/create-packages/creating-a-package-msbuild

<Project Sdk="Microsoft.NET.Sdk">   
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <PackageId>ClassLibDotNetStandard</PackageId>
    <Version>1.0.0</Version>
    <Authors>your_name</Authors>
    <Company>your_company</Company>   
  </PropertyGroup> 
</Project>

As you can see, you can set your Author name and Company name

C-JARP
  • 1,028
  • 14
  • 16
0

TL;DR;

With new SDK (core) .csproj file formats, use dotnet pack, and the DevOps pipeline task DotNetCoreCLI@2 with the pack command option to pack libraries into NuGet packages. nuget pack was used for the older .Net framework project formats.

Op stated

We are generating nuget packages on Azure pipelines using the the "nuget pack" task

nuget pack is used in conjunction with the older "non-SDK" .csproj (.Net Framework) file format, and requires the addition of an additional .nuspec file placed in the same directory as the .csproj file with the same name as the project (e.g. Foo.csproj needs Foo.nuspec). You can then edit the authors, version and other package info as needed in the .nuspec file.

However, I would strongly suggest you move all your projects across to the new SDK style .csproj format, as used by .Net Core + Standard. The new project format ALSO supports .Net Framework, and has a multitude of benefits with handling of package dependencies, simplification of binding redirects, and conciseness, and removes the need for a separate .nuspec file.

Conversion of an old .csproj class library to the new format is usually as simple as

  • Make a note of the project dependencies, and package dependencies in the packages.config file
  • Delete the old .csproj file, .nuspec file (if present), the Properties/AssemblyInfo.cs file, and packages.config file
  • Create a new .net standard project file and copy it across to the project directory
  • Edit the .csproj file (unlike the old project format, you don't need to unload it first) and change the target framework as applicable, e.g. to <TargetFramework>net48</TargetFramework> or whatever your .Net Framework version was.
  • Better still:
    • If your project isn't tied to .Net framework (e.g. if it's a library of class POCOs and Interfaces), leave it as .Net Standard. This will work on any .Net project, including Framework.
    • Or, if you can try multi-targetting of your project to both .Net Framework AND core <TargetFrameworks>net48;net5.0</TargetFrameworks> (note the plural, TargetFrameworks). net5.0 is the same as netcoreapp5.0
  • Once created, you'll be able to change the NuGet Package information for your new project assembly in the Project Properties -> Package tab in VS, or manually edit the .csproj file as per @C-Jarp's answer

On your Azure DevOps pipeline, after building your library, you can then pack it with the DotNetCoreCLI@2 pack task:

  ... restore + build steps
  ... unit test step

  - task: DotNetCoreCLI@2
    displayName: Packaging NuGets
    inputs:
      command: 'pack'
      arguments: '--configuration $(buildConfiguration)'
      packagesToPack: | 
        MyLibrary/MyLibrary.csproj;
        .. Other libraries;

And now you can push it to your NuGet repository (e.g. DevOps artifacts)

StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • The DotNetCoreCLI pack task in Azure DevOps pipelines uses `dotnet pack ` under the hood. – StuartLC Jun 03 '21 at 12:30
  • I believe all that you've said is what we need. The project is a .Net Core project and should be using the new project format. It is likely that we used nuget pack because we didn't know there was an alternative, just learning about azure as we are. What's the best way to pack a nuget package under .Net core? – Mark Mercer Jun 09 '21 at 13:18
  • Ok, Just read this: DotNetCoreCLI@2 pack task... Will try – Mark Mercer Jun 09 '21 at 13:23
  • Yes, 'dotnet pack' and 'dotnet push' will build and upload the package from a local environment, and for your Devops yaml pipeline you'll want the DotNetCoreCLI@2 task which wraps the dotnet calls. – StuartLC Jun 09 '21 at 14:58