Skip to content

XAML New NuGetPackage

Codeblack edited this page Mar 12, 2017 · 1 revision

New-NuGetPackage

Creates new NuGet-packages according to the specified nuspec-files.

Specifying the base-path

This function can be used before and after the files are copied to the drop-directory. For this reason, the path that is used as the base-path of the files defined in the nuspec file, is determined using the following rules:

  • if the drop-directory is empty and the BasePath parameter is not provided, the resulting base-path is the binaries-directory
  • if the BasePath parameter is provided and that folder does exist in the binaries-directory, the resulting base-path is the location of that folder (so the binaries-directory with the folder from the BasePath parameter added)
  • in all other cases, the resulting base-path is the drop-directory with the (optional) folder from the BasePath parameter added; if that folder does not exist, it is created

Pre-package script

If a PowerShell script with the same name as the nuspec-file exists, in the same folder, it as executed as a pre-package script. Providing such a script is mandatory if the BasePath parameter specifies a new folder. This folder must be populated by the pre-package script.

The pre-package script is called with the following parameters, in this order:

  • SourcesDirectory: this is the root-directory containing the source-files
  • BinariesDirectory: this is the root-directory containing the results of the build
  • DropDirectory: this is the drop-directory containing the results of the build
  • BaseDirectory: this is the base-directy for the files defined in the nuspec file, as specified above

Example scenario's

There are mainly 3 scenario's for using the base-path, as shown in the following paragraphs. When in doubt, just run a build to see what the resulting folder- & file-structure in the drop-directory looks like. Modify the nuspec-file and/or the pre-package script accordingly.

Single solution, directly from the build-output

Set the 'Output location' build-process parameter to 'SingleFolder'. This will cause all build-results to be placed in the binaries- and drop-directory. In this case, don't provide the BasePath parameter; the file-references in the nuspec-file are usually just the file-names, without a path.

Multiple solutions, directly from the build-output

Set the 'Output location' build-process parameter to 'PerProject'. This will cause the build-results from each solution to be copied to a folder with the solution-name within the binaries- and drop-directory. In this case, don't provide the BasePath parameter and add the correct solution-name in the path for the file-references in the nuspec-file.

One or more solutions, with full control over the file-structure

Provide the BasePath parameter with a value like 'PrePackage'; this will cause a new folder with that name to be created in the drop-directory. Also provide a pre-package script, as described above. In the pre-package script, using the passed parameters, create the desired folder-structures and copy the files as needed. You can specify either 'SingleFolder' or 'PerProject' for the 'Output location' build-process parameter, but you have to take the resulting folder-structure into account.

Parameters

SourcesDirectory

Specifies the root-directory containing the source-files.

BinariesDirectory

Specifies the root-directory containing the results of the build.

DropDirectory

Specifies the drop-directory containing the results of the build.

NuspecFilePath

Specifies the file-path for one or more nuspec-files, relative to the sources-directory. If not provided, all nuspec-files in the sources-directory will be processed.

BasePath

Specifies the path to use as the base-path for the files in the nuspec-file(s), relative to the drop- or binaries-directory. If the drop-directory is present and populated, the base-path is relative to the drop-directory; otherwise it is relative to the binaries-directory. If not provided, or empty, the base-path is the drop- or binaries-directory itself.

OutputPath

Specifies the path to use as the output-path for the package(s), relative to the drop-directory. Default is 'Package'.

AdditionalPackOptions

Specifies additional command-line options for the pack-command.

WhatIf

Specifies that no changes should be made.