Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves the documentation for nuget pack -action #6215

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 29 additions & 3 deletions docs/pipelines/tasks/package/nuget.md
Expand Up @@ -69,7 +69,7 @@ If your code depends on NuGet packages, make sure to add this step before your [
| `packagesToPack`<br/>Path to csproj or nuspec file(s) to pack | Pattern to search for csproj directories to pack.<br />You can separate multiple patterns with a semicolon, and you can make a pattern negative by prefixing it with '!'. Example: `**\\*.csproj;!**\\*.Tests.csproj` |
| `configuration`<br/>Configuration to package | When using a csproj file this specifies the configuration to package. |
| `packDestination`<br/>Package folder | Folder where packages will be created. If empty, packages will be created at the source root. |
| `versioningScheme`<br/>Automatic package versioning | Cannot be used with include referenced projects. If you choose 'Use the date and time', this will generate a [SemVer](http://semver.org/spec/v1.0.0.html)-compliant version formatted as `X.Y.Z-ci-datetime` where you choose X, Y, and Z.<br />If you choose 'Use an environment variable', you must select an environment variable and ensure it contains the version number you want to use.<br />If you choose 'Use the build number', this will use the build number to version your package. **Note:** Under Options set the build number format to be '[$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)](https://go.microsoft.com/fwlink/?LinkID=627416)'.<br/>Options: `off`, `byPrereleaseNumber`, `byEnvVar`, `byBuildNumber` |
| `versioningScheme`<br/>Automatic package versioning | Cannot be used with include referenced projects. If you choose 'Use the date and time', this will generate a [SemVer](http://semver.org/spec/v1.0.0.html)-compliant version formatted as `X.Y.Z-ci-datetime` where you choose X, Y, and Z.<br />If you choose 'Use an environment variable' (byEnvVar), you must select an environment variable and ensure it contains the version number you want to use.<br />If you choose 'Use the build number' (byBuildNumber), this will use the build number to version your package.<br />**Note:** Under Options set the build number format to be '[$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)](https://go.microsoft.com/fwlink/?LinkID=627416)', or if you're using YAML to configure your pipeline, specify the said format as the "name", like shown in the [Versioning schemes]("#versioning-schemes").<br/>Options: `off`, `byPrereleaseNumber`, `byEnvVar`, `byBuildNumber` |
| `includeReferencedProjects`<br/>Environment variable | Enter the variable name without $, $env, or %. |
| `majorVersion`<br/>Major | The 'X' in version [X.Y.Z](http://semver.org/spec/v1.0.0.html) |
| `minorVersion`<br/>Minor | The 'Y' in version [X.Y.Z](http://semver.org/spec/v1.0.0.html) |
Expand All @@ -89,9 +89,35 @@ If your code depends on NuGet packages, make sure to add this step before your [

For **byPrereleaseNumber**, the version will be set to whatever you choose for major, minor, and patch, plus the date and time in the format `yyyymmdd-hhmmss`.

For **byEnvVar**, the version will be set as whatever environment variable, e.g. `MyVersion` (no **$**, just the environment variable name), you provide. Make sure the environment variable is set to a proper SemVer e.g. `1.2.3` or `1.2.3-beta1`.
```YAML
# Sets your version number to be 1.0.X, where X equals the value from a pipeline or environment variable called "Patch"
- task: NuGetCommand@2
inputs:
command: pack
versioningScheme: byPrereleaseNumber
majorVersion: '1'
minorVersion: '0'
patchVersion: '$(Patch)'
packTimezone: utc
```

For **byEnvVar**, the version will be set as whatever environment variable, e.g. `MyVersion` (no **$**, just the environment variable name), you provide. Make sure the environment variable is set to a proper SemVer e.g. `1.2.3` or `1.2.3-beta1`. If you select this option, you also need to set the environment variable, like in the example below.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to update to match the env vars in the text and the example?


```YAML
# Set a variable that contains version number for your NuGet task:
- task: NuGetCommand@2
inputs:
command: pack
versioningScheme: byEnvVar
versionEnvVar: PackageVersion
```

For **byBuildNumber**, the version will be set to the build number, ensure that your build number is a proper SemVer e.g. `1.0.$(Rev:r)`. If you select **byBuildNumber**, the task will extract a dotted version, `1.2.3.4` and use only that, dropping any label. To use the build number as is, you should use **byEnvVar** as described above, and set the environment variable to `BUILD_BUILDNUMBER`.
For **byBuildNumber**, the version will be set to the build number, ensure that your build number is a proper SemVer e.g. `1.0.$(Rev:r)`. See an example of this below as YAML. If you select **byBuildNumber**, the task will extract a dotted version, `1.2.3.4` and use only that, dropping any label. To use the build number as is, you should use **byEnvVar** as described above, and set the environment variable to `BUILD_BUILDNUMBER`.

```YAML
# Set build name, if you use byBuildNumber
name: $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
```

::: moniker-end

Expand Down