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

Add extra options to dotnet pack command #9956

Merged
merged 9 commits into from
Apr 20, 2019
2 changes: 2 additions & 0 deletions Tasks/DotNetCoreCLIV2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Options specific to **dotnet pack** command
* **Configuration to Package\*:** When using a csproj file this specifies the configuration to package.
* **Package Folder\*:** Folder where packages will be created. If empty, packages will be created alongside the csproj file.
* **Do not build\*:** Don't build the project before packing. Corresponds to the --no-build command line parameter.
* **Include Symbols\*:** Additionally creates symbol NuGet packages. Corresponds to the --include-symbols command line parameter.
* **Include Source\*:** Includes source code in the package. Corresponds to the --include-source command line parameter.
* **Automatic package versioning\*:** Cannot be used with include referenced projects. If you choose 'Use the date and time', this will generate a SemVer -compliant version formatted as X.Y.Z-ci-datetime where you choose X, Y, and Z.
If you choose 'Use an environment variable', you must select an environment variable and ensure it contains the version number you want to use.
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
"loc.input.help.outputDir": "Folder where packages will be created. If empty, packages will be created alongside the csproj file.",
"loc.input.label.nobuild": "Do not build",
"loc.input.help.nobuild": "Don't build the project before packing. Corresponds to the --no-build command line parameter.",
"loc.input.label.includesymbols": "Include Symbols",
"loc.input.help.includesymbols": "Additionally creates symbol NuGet packages. Corresponds to the --include-symbols command line parameter.",
"loc.input.label.includesource": "Include Source",
"loc.input.help.includesource": "Includes source code in the package. Corresponds to the --include-source command line parameter.",
"loc.input.label.versioningScheme": "Automatic package versioning",
"loc.input.help.versioningScheme": "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.\n\nIf you choose 'Use an environment variable', you must select an environment variable and ensure it contains the version number you want to use.\n\nIf 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)'.",
"loc.input.label.versionEnvVar": "Environment variable",
Expand Down
14 changes: 12 additions & 2 deletions Tasks/DotNetCoreCLIV2/packcommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export async function run(): Promise<void> {
let propertiesInput = tl.getInput("buildProperties");
let verbosity = tl.getInput("verbosityPack");
let nobuild = tl.getBoolInput("nobuild");
let includeSymbols = tl.getBoolInput("includesymbols");
let includeSource = tl.getBoolInput("includesource");
let outputDir = undefined;

try {
Expand Down Expand Up @@ -124,15 +126,15 @@ export async function run(): Promise<void> {
const dotnetPath = tl.which("dotnet", true);

for (const file of filesList) {
await dotnetPackAsync(dotnetPath, file, outputDir, nobuild, version, props, verbosity);
await dotnetPackAsync(dotnetPath, file, outputDir, nobuild, includeSymbols, includeSource, version, props, verbosity);
}
} catch (err) {
tl.error(err);
tl.setResult(tl.TaskResult.Failed, tl.loc("Error_PackageFailure"));
}
}

function dotnetPackAsync(dotnetPath: string, packageFile: string, outputDir: string, nobuild: boolean, version: string, properties: string[], verbosity: string): Q.Promise<number> {
function dotnetPackAsync(dotnetPath: string, packageFile: string, outputDir: string, nobuild: boolean, includeSymbols: boolean, includeSource: boolean, version: string, properties: string[], verbosity: string): Q.Promise<number> {
let dotnet = tl.tool(dotnetPath);

dotnet.arg("pack");
Expand All @@ -147,6 +149,14 @@ function dotnetPackAsync(dotnetPath: string, packageFile: string, outputDir: str
dotnet.arg("--no-build");
}

if (includeSymbols) {
dotnet.arg("--include-symbols");
}

if (includeSource) {
dotnet.arg("--include-source");
}

if (properties && properties.length > 0) {
dotnet.arg("/p:" + properties.join(";"));
}
Expand Down
22 changes: 20 additions & 2 deletions Tasks/DotNetCoreCLIV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 151,
"Patch": 1
"Minor": 152,
"Patch": 0
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "dotnet $(command)",
Expand Down Expand Up @@ -367,6 +367,24 @@
"required": false,
"visibleRule": "command = pack"
},
{
ryandle marked this conversation as resolved.
Show resolved Hide resolved
"name": "includesymbols",
"type": "boolean",
"label": "Include Symbols",
"defaultValue": "false",
"helpMarkDown": "Additionally creates symbol NuGet packages. Corresponds to the --include-symbols command line parameter.",
"required": false,
"visibleRule": "command = pack"
},
{
"name": "includesource",
"type": "boolean",
"label": "Include Source",
"defaultValue": "false",
"helpMarkDown": "Includes source code in the package. Corresponds to the --include-source command line parameter.",
"required": false,
"visibleRule": "command = pack"
},
{
"name": "versioningScheme",
"type": "pickList",
Expand Down
22 changes: 20 additions & 2 deletions Tasks/DotNetCoreCLIV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 151,
"Patch": 1
"Minor": 152,
"Patch": 0
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down Expand Up @@ -367,6 +367,24 @@
"required": false,
"visibleRule": "command = pack"
},
{
"name": "includesymbols",
"type": "boolean",
"label": "ms-resource:loc.input.label.includesymbols",
"defaultValue": "false",
"helpMarkDown": "ms-resource:loc.input.help.includesymbols",
"required": false,
"visibleRule": "command = pack"
},
{
"name": "includesource",
"type": "boolean",
"label": "ms-resource:loc.input.label.includesource",
"defaultValue": "false",
"helpMarkDown": "ms-resource:loc.input.help.includesource",
"required": false,
"visibleRule": "command = pack"
},
{
"name": "versioningScheme",
"type": "pickList",
Expand Down