2

My package builds successfully and is uploaded to the Packages feed in VSTS however I can't seem to figure out how to edit the Description and Author of the package so that my set values show in the Package feed.

From what I read I put my content in the NuGet Packager under additional build properties and when I look at the log file I see this:

...NuGet.exe pack "...csproj" -OutputDirectory "..." -Properties Configuration=release;Description="My Description";Authors="Me";Owners="My Company"

From the documentation I believe I did this right(but clearly I did not). It does seem a bit confusing as to what goes in "Additional build properties" vs NuGet Arguments.

Again my goal is get the Description and Author that I set to be viewable from the NuGet Package Manager within Visual Studio.

LorneCash
  • 1,446
  • 2
  • 16
  • 30

2 Answers2

3

You could create a package according to the .nuspec file. Steps:

  1. Generate .nuspec file for your project (command: nugget spec).

For example: (Include author and description token)

<?xml version="1.0"?>
<package >
  <metadata>
    <id>CommLib1</id>
    <version>1.0.0.6</version>
    <title>CommLib1</title>
    <authors>$author$</authors>
    <owners>$author$</owners>
    <licenseUrl>http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE</licenseUrl>
    <projectUrl>http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE</projectUrl>
    <iconUrl>http://ICON_URL_HERE_OR_DELETE_THIS_LINE</iconUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>$description$</description>
    <releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
    <copyright>Copyright 2016</copyright>
    <tags>Tag1 Tag2</tags>
  </metadata>
</package>
  1. Include this file to source control
  2. Specify Nuget Arguments (token in step 1) of Nuget Packager build step enter image description here

Update1:

In general, you just need to update AssemblyInfo.cs file of your project (Author=>AssemblyCompany; Description=>AssemblyDescription; Version=>AssemblyVersion), it creates package according to this data unless it can't retrieve metadata from your assembly (I have a project has this issue).

So, steps:

  1. Make sure nuget could retrieve necessary metadata by creating package through nuget.exe command directly in your local/build machine (nuget pack [XX].csproj)

  2. Create a build definition (1. Visual Studio Build 2. Nuget Packager with default value 3. Nuget Publisher)

starian chen-MSFT
  • 33,174
  • 2
  • 29
  • 53
  • I thought about doing that but I didn't want to have to manually update the version in the *.NuSpec file. I see you have a variable "$(v)" there but is there a way to pull the value of that variable value from the AssemblyVersion property? My solution is a single class library and I'm trying to make a template so that I can easily publish our common internal class libraries easily. – LorneCash Nov 08 '16 at 15:06
  • @LorneCash Yes, you can specify version in the argument. (I am using a variable value in build definition) – starian chen-MSFT Nov 09 '16 at 02:09
  • @LorneCash You could update AssemblyInfo.cs file directly if it could retrieve metadata from your assembly, then build, pack and publish through VSTS build. I updated my answer. – starian chen-MSFT Nov 09 '16 at 03:37
  • @LorneCash Your previous comment is just a part, you need to edit it or add a new comment in order to I can get your point. – starian chen-MSFT Nov 10 '16 at 07:45
  • Here's the steps you are telling me to follow (see below) and please correct me if I have something wrong. 1. Manually create *.nuspec via command line 2. Edit Author and Description in *.nuspec 3. Add *.nuspec to TFS 4. Point NuGet Packager build task to *.nuspec file in TFS That all makes sense but what about the next time I want to do a build? The *.nuspec file has the version right in the xml. I want to set the AssemblyVersion property in my AssemblyInfo.cs without having to enter it again in the *.nuspec or in a build variable. I want to set it once and be done. – LorneCash Nov 10 '16 at 07:54
  • I'm currently NOT using a *.nuspec file in my NuGet Packager I just have it pointed to the *.csproj and it's updating the version perfectly but if I switch to using a *.nuspec I don't understand how the *.nuspec get's updated to match the AssemblyInfo.cs without manual intervention. – LorneCash Nov 10 '16 at 07:54
  • @LorneCash First, you need to point nugget package build task to package file (csproj) instead of .nuspec, it will based on .nuspec file and project file if there is [project name].nuspec file in the same folder. Secondly, you don't need to edit Author and Description in .nuspec file, just keep $author$ and $description, then specify the value in nuget argument. Thirdly, with $version$ in .nuspec, it uses AssemblyVersion value in AssemblyInfo.cs file (e.g. [assembly: AssemblyVersion("1.0.0.9")]).BTW you could update AssemblyVersion.cs file and package project file directly without .nuspec file – starian chen-MSFT Nov 11 '16 at 01:37
  • @LorneCash What's the result if you update AssemblyInfo.cs file and package project file directly without .nuspec file? – starian chen-MSFT Nov 11 '16 at 01:38
  • I'm not using a nuspec file now... I would really like to get this to work without one and I think it should from what I've read I just can't seem to figure this out still... I've posted a new question related to this, I'm trying to break this one down so I understand why this isn't working. Here's the new question: http://stackoverflow.com/questions/40570795/ if you wanna attack that too. – LorneCash Nov 13 '16 at 06:07
  • @LorneCash Do you specify AssemblyCompany and AssemblyDescription values in AssemblyInfo.cs file? If so, could you reproduce that issue with new project? What's the version of your Nuget.exe? – starian chen-MSFT Nov 14 '16 at 01:30
1

If it's building the package then there are no problems with your NuGet Packager build step. Two things need to change though.

  1. In order to specify properties like you are doing there MUST be a tokenized *.nuspec file in the same directory as the solution file with the same name and of course the *.nuspec file needs to be checked in to VSTS/TFS.
  2. The token name for description can't be Description.

For more details on the *.nuspec file please see the solution here:

Nuget.exe pack WARNING: Description was not specified. Using 'Description'

Community
  • 1
  • 1
LorneCash
  • 1,446
  • 2
  • 16
  • 30