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

Adding a new task to download GitHub packages #12292

Merged
merged 1 commit into from Mar 19, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Tasks/AzureIoTEdgeV2/task.json
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 4,
"Patch": 0
"Patch": 1
},
"preview": false,
"showEnvironmentVariables": true,
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureIoTEdgeV2/task.loc.json
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 2,
"Minor": 4,
"Patch": 0
"Patch": 1
},
"preview": false,
"showEnvironmentVariables": true,
Expand Down
5 changes: 2 additions & 3 deletions Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts
Expand Up @@ -43,7 +43,7 @@ export class NuGetConfigHelper2 {

public ensureTempConfigCreated() {
// save nuget config file to agent build directory
console.log(tl.loc("Info_SavingTempConfig"));
tl.debug(tl.loc("Info_SavingTempConfig"));

let tempNuGetConfigDir = path.dirname(this.tempNugetConfigPath);
if (!tl.exist(tempNuGetConfigDir)) {
Expand Down Expand Up @@ -151,7 +151,6 @@ export class NuGetConfigHelper2 {
public getSourcesFromTempNuGetConfig(): IPackageSource[] {
// load content of the user's nuget.config
let configPath: string = this.tempNugetConfigPath ? this.tempNugetConfigPath : this.nugetConfigPath;

if (!configPath)
{
return [];
Expand Down Expand Up @@ -198,7 +197,7 @@ export class NuGetConfigHelper2 {

private convertToIPackageSource(source: auth.IPackageSourceBase): IPackageSource {
const uppercaseUri = source.feedUri.toUpperCase();
const isInternal = this.authInfo.internalAuthInfo.uriPrefixes.some(prefix => uppercaseUri.indexOf(prefix.toUpperCase()) === 0);
const isInternal = this.authInfo.internalAuthInfo ? this.authInfo.internalAuthInfo.uriPrefixes.some(prefix => uppercaseUri.indexOf(prefix.toUpperCase()) === 0) : false;

return {
feedName: source.feedName,
Expand Down
42 changes: 21 additions & 21 deletions Tasks/Common/utility-common/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Tasks/ContainerStructureTestV0/task.loc.json
Expand Up @@ -14,7 +14,7 @@
"version": {
"Major": 0,
"Minor": 162,
"Patch": 0
"Patch": 1
},
"preview": true,
"demands": [],
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DotNetCoreCLIV2/task.json
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 2,
"Minor": 167,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "dotnet $(command)",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/DotNetCoreCLIV2/task.loc.json
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 2,
"Minor": 167,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down
@@ -0,0 +1,69 @@
{
"loc.friendlyName": "Download Nuget GitHub Packages",
"loc.helpMarkDown": "[See the .NET Core documentation](https://docs.microsoft.com/dotnet/core/)",
"loc.description": "Restore your nuget packages using dotnet CLI",
"loc.instanceNameFormat": "dotnet restore",
"loc.group.displayName.restoreAuth": "Feeds and authentication",
"loc.group.displayName.restoreAdvanced": "Advanced",
"loc.input.label.packageName": "Package Name",
"loc.input.help.packageName": "Name of the package to download from github",
"loc.input.label.version": "Package Version",
"loc.input.help.version": "Version of the package to download from github",
"loc.input.label.externalEndpoints": "Credentials for feed from GitHub",
"loc.input.help.externalEndpoints": "Credentials to use for external registry from GitHub",
"loc.input.label.packagesDirectory": "Destination directory",
"loc.input.help.packagesDirectory": "Specifies the folder in which packages are installed. If no folder is specified, packages are restored into the default system working directory.",
"loc.messages.BuildIdentityPermissionsHint": "For internal feeds, make sure the build service identity '%s' [%s] has access to the feed.",
"loc.messages.CouldNotSetCodePaging": "Could not set the code paging of due to following error: %s",
"loc.messages.Error_AutomaticallyVersionReleases": "Autoversion: Getting version number from build option is not supported in releases",
"loc.messages.Error_CommandNotRecognized": "The command %s was not recognized.",
"loc.messages.Error_InvalidPackageName": "Package name is invalid.",
"loc.messages.Error_NoSourceSpecifiedForPush": "No source was specified for push",
"loc.messages.Error_NoValueFoundForEnvVar": "No value was found for the provided environment variable.",
"loc.messages.Error_NoVersionFoundInBuildNumber": "Could not find version number data in the following environment variable: BUILD_BUILDNUMBER. The value of the variable should contain a substring with the following formats: X.Y.Z or X.Y.Z.A where A, X, Y, and Z are positive integers.",
"loc.messages.Error_PackageFailure": "An error occurred while trying to pack the files.",
"loc.messages.Error_PushNotARegularFile": "%s is not a file. Check the 'Path/Pattern to nupkg' property of the task.",
"loc.messages.Info_AttemptingToPackFile": "Attempting to pack file: ",
"loc.messages.Info_NoPackagesMatchedTheSearchPattern": "No packages matched the search pattern.",
"loc.messages.Info_NoFilesMatchedTheSearchPattern": "No files matched the search pattern.",
"loc.messages.PackageFailedToInstall": "Package failed to restore",
"loc.messages.PackagesFailedToPublish": "Packages failed to publish",
"loc.messages.PackagesInstalledSuccessfully": "Packages were restored successfully",
"loc.messages.PackagesPublishedSuccessfully": "Packages were published successfully",
"loc.messages.UnknownFeedType": "Unknown feed type '%s'",
"loc.messages.Warning_AutomaticallyVersionReferencedProjects": "The automatic package versioning and include referenced projects options do not work together. Referenced projects will not inherit the custom version provided by the automatic versioning settings.",
"loc.messages.Warning_MoreThanOneVersionInBuildNumber": "Found more than one instance of version data in BUILD_BUILDNUMBER.Assuming first instance is version.",
"loc.messages.dotnetCommandFailed": "Dotnet command failed with non-zero exit code on the following projects : %s",
"loc.messages.noProjectFilesFound": "Project file(s) matching the specified pattern were not found.",
"loc.messages.noPublishFolderFoundToZip": "A publish folder could not be found to zip for project file: %s.",
"loc.messages.noWebProjectFound": "No web project was found in the repository. Web projects are identified by presence of either a web.config file, wwwroot folder in the directory, or by the usage of Microsoft.Net.Web.Sdk in your project file. You can set Publish Web Projects property to false (publishWebProjects: false in yml) if your project doesn't follow this convention or if you want to publish projects other than web projects.",
"loc.messages.zipFailed": "Zip failed with error: %s",
"loc.messages.Error_ApiKeyNotSupported": "DotNetCore currently does not support using an encrypted Api Key.",
"loc.messages.Error_ExpectedConfigurationElement": "Invalid xml. Expected element named 'configuration'.",
"loc.messages.Error_NoMatchingFilesFoundForPattern": "No matching files were found with search pattern: %s",
"loc.messages.Error_NoUrlWasFoundWhichMatches": "No download URL was found for %s",
"loc.messages.Error_NoVersionWasFoundWhichMatches": "No version was found which matches the input %s",
"loc.messages.Error_NuGetToolInstallerFailer": "Tool install failed: %s",
"loc.messages.Info_AvailableVersions": "The available versions are: %s",
"loc.messages.Info_ExpectBehaviorChangeWhenUsingVersionQuery": "You are using a query match on the version string. Behavior changes or breaking changes might occur as NuGet updates to a new version.",
"loc.messages.Info_MatchingUrlWasFoundSettingAuth": "Using authentication information for the following URI: ",
"loc.messages.Info_ResolvedToolFromCache": "Resolved from tool cache: %s",
"loc.messages.Info_SavingTempConfig": "Saving NuGet.config to a temporary config file.",
"loc.messages.Info_UsingToolPath": "Using tool path: %s",
"loc.messages.Info_UsingVersion": "Using version: %s",
"loc.messages.NGCommon_AddingSources": "Setting credentials in NuGet.config",
"loc.messages.NGCommon_AreaNotFoundInSps": "Unable to locate the '%s' [%s] area. The service containing that area may not be available in your region.",
"loc.messages.NGCommon_DetectedNuGetExtensionsPath": "Detected NuGet extensions loader path (NUGET_EXTENSIONS_PATH environment variable): %s",
"loc.messages.NGCommon_DetectedNuGetVersion": "Detected NuGet version %s / %s",
"loc.messages.NGCommon_IgnoringNuGetExtensionsPath": "Detected NuGet extensions loader path (NUGET_EXTENSIONS_PATH environment variable). Extensions are ignored when using the built-in NuGet client",
"loc.messages.NGCommon_NoSourcesFoundInConfig": "No package sources were found in the NuGet.config file at %s",
"loc.messages.NGCommon_NuGetConfigIsInvalid": "The NuGet.config at %s is invalid.",
"loc.messages.NGCommon_NuGetConfigIsPackagesConfig": "Expected a NuGet.config file at %s, but its contents appear to be a packages.config. Check the settings for the %s task and confirm you selected NuGet.config rather than packages.config.",
"loc.messages.NGCommon_RemovingSources": "Preparing to set credentials in NuGet.config",
"loc.messages.NGCommon_SpsNotFound": "Unable to find the '%s' [%s] area. There may be a problem with your Team Foundation Server installation.",
"loc.messages.NGCommon_UnabletoDetectNuGetVersion": "Unknown NuGet version selected.",
"loc.messages.NGCommon_UnableToFindTool": "Unable to find tool %s",
"loc.messages.Warning_SessionCreationFailed": "Could not create provenance session: %s",
"loc.messages.Warning_UpdatingNuGetVersion": "Updating version of NuGet.exe to %s from %s. Behavior changes or breaking changes might occur as NuGet updates to a new version. If this is not desired, deselect the 'Check for Latest Version' option in the task.",
"loc.messages.NetCore3Update": "Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions. \nSome commonly encountered changes are: \nIf you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting"
}
42 changes: 42 additions & 0 deletions Tasks/DownloadGitHubNugetPackage/dotnetrestore.ts
@@ -0,0 +1,42 @@
import tl = require("azure-pipelines-task-lib/task");
import tr = require("azure-pipelines-task-lib/toolrunner");
import path = require("path");

import * as restoreCommand from './restorecommand';

let MessagePrinted = false;

export class dotNetExe {

constructor() {
}

public async execute() {
tl.setResourcePath(path.join(__dirname, "task.json"));
this.setConsoleCodePage();

try {
await restoreCommand.run();
}
finally {
if (!MessagePrinted) {
console.log(tl.loc('NetCore3Update'));
}
}
}

private setConsoleCodePage() {
// set the console code page to "UTF-8"
if (tl.osType() === 'Windows_NT') {
try {
tl.execSync(path.resolve(process.env.windir, "system32", "chcp.com"), ["65001"]);
}
catch (ex) {
tl.warning(tl.loc("CouldNotSetCodePaging", JSON.stringify(ex)))
}
}
}
}

var exe = new dotNetExe();
exe.execute().catch((reason) => tl.setResult(tl.TaskResult.Failed, reason));
22 changes: 22 additions & 0 deletions Tasks/DownloadGitHubNugetPackage/make.json
@@ -0,0 +1,22 @@
{
"common": [
{
"module": "../Common/utility-common",
"type": "node",
"compile": true
},
{
"module": "../Common/packaging-common",
"type": "node",
"compile": true
}
],
"rm": [
{
"items": [
"node_modules/packaging-common/node_modules/azure-pipelines-task-lib"
],
"options": "-Rf"
}
]
}