Skip to content

Commit

Permalink
Users/shrverm/fix dotnetcorecli push auth (#13191)
Browse files Browse the repository at this point in the history
* fix dotnet nuget push onPrem by setting credential configuration (#13183)
* Restrict credentials in config to Basic scheme (#13054)
* bump task version of legacy tasks
Co-authored-by: Jonathan Myers <11822817+jmyersmsft@users.noreply.github.com>
  • Loading branch information
shadargee1982 authored Jun 29, 2020
1 parent 9051c03 commit 1a3f41c
Show file tree
Hide file tree
Showing 49 changed files with 143 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"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.Info_BasicCredRestriction": "This task now configures NuGet to send these credentials using the Basic scheme\nonly. Most users will be unaffected by this change. If these are Windows domain\ncredentials and they have recently stopped working, try setting the build\nvariable %s to the value '%s' (without quotes).",
"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",
Expand Down
6 changes: 3 additions & 3 deletions Tasks/Common/packaging-common/Tests/nugetL0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ not xml
helper.AddSourceToNuGetConfig("SourceCredentials", "http://credentials", "foo", "bar");
assert.strictEqual(
configFile,
'<configuration><packageSources><add key="SourceName" value="http://source/"/><add key="SourceCredentials" value="http://credentials"/></packageSources><packageSourceCredentials><SourceCredentials><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/></SourceCredentials></packageSourceCredentials></configuration>',
'<configuration><packageSources><add key="SourceName" value="http://source/"/><add key="SourceCredentials" value="http://credentials"/></packageSources><packageSourceCredentials><SourceCredentials><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/><add key="ValidAuthenticationTypes" value="basic"/></SourceCredentials></packageSourceCredentials></configuration>',
'Helper should have added the "SourceCredentials" source with credentials');

helper.RemoveSourceFromNuGetConfig("SourceCredentials");
Expand Down Expand Up @@ -251,14 +251,14 @@ not xml
helper.AddSourceToNuGetConfig("1Feed", "http://credentials", "foo", "bar");
assert.strictEqual(
configFile,
'<configuration><packageSources><add key="1Feed" value="http://credentials"/></packageSources><packageSourceCredentials><_x0031_Feed><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/></_x0031_Feed></packageSourceCredentials></configuration>',
'<configuration><packageSources><add key="1Feed" value="http://credentials"/></packageSources><packageSourceCredentials><_x0031_Feed><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/><add key="ValidAuthenticationTypes" value="basic"/></_x0031_Feed></packageSourceCredentials></configuration>',
'Helper should have added the "1Feed" source with credentials');
helper.RemoveSourceFromNuGetConfig("1Feed");

helper.AddSourceToNuGetConfig("Feed with spaces and :", "http://credentials", "foo", "bar");
assert.strictEqual(
configFile,
'<configuration><packageSources><add key="Feed with spaces and :" value="http://credentials"/></packageSources><packageSourceCredentials><Feed_x0020_with_x0020_spaces_x0020_and_x0020__x003a_><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/></Feed_x0020_with_x0020_spaces_x0020_and_x0020__x003a_></packageSourceCredentials></configuration>',
'<configuration><packageSources><add key="Feed with spaces and :" value="http://credentials"/></packageSources><packageSourceCredentials><Feed_x0020_with_x0020_spaces_x0020_and_x0020__x003a_><add key="Username" value="foo"/><add key="ClearTextPassword" value="bar"/><add key="ValidAuthenticationTypes" value="basic"/></Feed_x0020_with_x0020_spaces_x0020_and_x0020__x003a_></packageSourceCredentials></configuration>',
'Helper should have added the "Feed with spaces" source with credentials');
helper.RemoveSourceFromNuGetConfig("Feed with spaces");

Expand Down
4 changes: 2 additions & 2 deletions Tasks/Common/packaging-common/bump-task-version.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Param(
)

# Bump patch version and adjust sprint
"DotNetCoreCLIV2","DownloadPackageV0","DownloadPackageV1","MavenV2","MavenV3","NpmV1","NpmAuthenticateV0","NuGetV0","NuGetCommandV2","NuGetPublisherV0","NuGetToolInstallerV0","NuGetToolInstallerV1","PipAuthenticateV0","TwineAuthenticateV0","UniversalPackagesV0", "UseNodeV1" | % {
"DotNetCoreCLIV2","DownloadPackageV0","DownloadPackageV1","MavenV2","MavenV3","NpmV0","NpmV1","NpmAuthenticateV0","NuGetInstallerV0","NuGetV0","NuGetCommandV2","NuGetPublisherV0","NuGetToolInstallerV0","NuGetToolInstallerV1","PipAuthenticateV0","TwineAuthenticateV0","UniversalPackagesV0","UseNodeV1" | % {
$taskLocation = Join-Path "$taskRoot/$_" "task.json"
$taskContent = Get-Content $taskLocation
$task = $taskContent | ConvertFrom-Json
Expand All @@ -37,7 +37,7 @@ Param(
}

# Just bump the patch version for these.
"UseDotNetV2" | % {
"UseDotNetV2","DownloadGitHubNugetPackageV1","DownloadGitHubNpmPackageV1" | % {
$taskLocation = Join-Path "$taskRoot/$_" "task.json"
$taskContent = Get-Content $taskLocation
$task = $taskContent | ConvertFrom-Json
Expand Down
1 change: 1 addition & 0 deletions Tasks/Common/packaging-common/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"Info_SavingTempConfig": "Saving NuGet.config to a temporary config file.",
"Info_UsingToolPath": "Using tool path: %s",
"Info_UsingVersion": "Using version: %s",
"Info_BasicCredRestriction": "This task now configures NuGet to send these credentials using the Basic scheme\nonly. Most users will be unaffected by this change. If these are Windows domain\ncredentials and they have recently stopped working, try setting the build\nvariable %s to the value '%s' (without quotes).",
"NGCommon_AddingSources": "Setting credentials in NuGet.config",
"NGCommon_AreaNotFoundInSps": "Unable to locate the '%s' [%s] area. The service containing that area may not be available in your region.",
"NGCommon_DetectedNuGetExtensionsPath": "Detected NuGet extensions loader path (NUGET_EXTENSIONS_PATH environment variable): %s",
Expand Down
4 changes: 4 additions & 0 deletions Tasks/Common/packaging-common/nuget/NuGetConfigHelper2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export class NuGetConfigHelper2 {
}

sources.forEach((source) => {
tl.debug(`considering source ${source.feedUri}. Internal: ${source.isInternal}`)
if (source.isInternal)
{
if(this.authInfo.internalAuthInfo.useCredConfig)
Expand All @@ -109,6 +110,7 @@ export class NuGetConfigHelper2 {
{
if (!this.authInfo.externalAuthInfo || this.authInfo.externalAuthInfo.length < 1)
{
tl.debug('No external auth information');
return;
}

Expand Down Expand Up @@ -137,6 +139,8 @@ export class NuGetConfigHelper2 {
default:
break;
}
} else {
tl.debug(`No auth information found for source ${source.feedUri}`);
}
}
});
Expand Down
20 changes: 18 additions & 2 deletions Tasks/Common/packaging-common/nuget/NuGetXmlHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,20 @@ export class NuGetXmlHelper implements INuGetXmlHelper {

private _addCredentialsToSource(xml: any, name: string, username: string, password: string): any {
if (xml) {
let xmlSourceCredentials = NuGetXmlHelper._getOrCreateLastElement(xml, "packageSourceCredentials");
let xmlFeedName = xmlSourceCredentials.c(NuGetXmlHelper._nuGetEncodeElementName(name));
const xmlSourceCredentials = NuGetXmlHelper._getOrCreateLastElement(xml, "packageSourceCredentials");
const encodedName = NuGetXmlHelper._nuGetEncodeElementName(name);
const authTypesVar = "ValidAuthenticationTypes_" + encodedName;
const xmlFeedName = xmlSourceCredentials.c(encodedName);

let authTypes = tl.getVariable(authTypesVar);
if(!authTypes) {
if(username !== "VssSessionToken") {
console.log(tl.loc("Info_BasicCredRestriction", authTypesVar, 'negotiate,ntlm'));
}

authTypes = 'basic';
}

xmlFeedName.c("add", {
key: "Username",
value: username
Expand All @@ -70,6 +82,10 @@ export class NuGetXmlHelper implements INuGetXmlHelper {
key: "ClearTextPassword",
value: password
});
xmlFeedName.c("add", {
key: "ValidAuthenticationTypes",
value: authTypes
});
}

return xml;
Expand Down
2 changes: 2 additions & 0 deletions Tasks/DotNetCoreCLIV2/dotnetcore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export class dotNetExe {
}

public async execute() {
tl.setResourcePath(path.join(__dirname, "node_modules", "packaging-common", "module.json"));
tl.setResourcePath(path.join(__dirname, "task.json"));

this.setConsoleCodePage();

try {
Expand Down
4 changes: 2 additions & 2 deletions Tasks/DotNetCoreCLIV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 2,
"Minor": 170,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "dotnet $(command)",
Expand Down Expand Up @@ -570,4 +570,4 @@
"NetCore3Update": "Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x (3.0 and 3.1) SDK/Runtime along with 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",
"DeprecatingDotnet2_2": ".NET Core SDK/runtime 2.2 is now End of Line(EOL) and will be removed from all agents by end of March, 2020. If you're using 2.2 SDK/runtime, kindly upgrade to newer versions which are not EOL or use UseDotNet task to install the requied version."
}
}
}
4 changes: 2 additions & 2 deletions Tasks/DotNetCoreCLIV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 2,
"Minor": 170,
"Patch": 0
"Patch": 1
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down Expand Up @@ -570,4 +570,4 @@
"NetCore3Update": "ms-resource:loc.messages.NetCore3Update",
"DeprecatingDotnet2_2": "ms-resource:loc.messages.DeprecatingDotnet2_2"
}
}
}
4 changes: 2 additions & 2 deletions Tasks/DownloadGitHubNpmPackageV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 1
"Patch": 3
},
"runsOn": [
"Agent",
Expand Down Expand Up @@ -104,4 +104,4 @@
"WorkingDirectoryNotDirectory": "Please change your working directory to a valid directory",
"NGCommon_AreaNotFoundInSps": "Unable to locate the '%s' [%s] area. The service containing that area may not be available in your region."
}
}
}
4 changes: 2 additions & 2 deletions Tasks/DownloadGitHubNpmPackageV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 1
"Patch": 3
},
"runsOn": [
"Agent",
Expand Down Expand Up @@ -104,4 +104,4 @@
"WorkingDirectoryNotDirectory": "ms-resource:loc.messages.WorkingDirectoryNotDirectory",
"NGCommon_AreaNotFoundInSps": "ms-resource:loc.messages.NGCommon_AreaNotFoundInSps"
}
}
}
4 changes: 2 additions & 2 deletions Tasks/DownloadGitHubNugetPackageV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 4
"Patch": 6
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "dotnet restore",
Expand Down Expand Up @@ -141,4 +141,4 @@
"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.",
"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"
}
}
}
4 changes: 2 additions & 2 deletions Tasks/DownloadGitHubNugetPackageV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 4
"Patch": 6
},
"minimumAgentVersion": "2.115.0",
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",
Expand Down Expand Up @@ -141,4 +141,4 @@
"Warning_UpdatingNuGetVersion": "ms-resource:loc.messages.Warning_UpdatingNuGetVersion",
"NetCore3Update": "ms-resource:loc.messages.NetCore3Update"
}
}
}
6 changes: 3 additions & 3 deletions Tasks/DownloadPackageV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"author": "ms-vscs-rm",
"version": {
"Major": 0,
"Minor": 169,
"Patch": 2
"Minor": 170,
"Patch": 0
},
"demands": [],
"minimumAgentVersion": "1.99.0",
Expand Down Expand Up @@ -108,4 +108,4 @@
"Info_ResolvedToolFromCache": "Resolved from tool cache: %s",
"UnsupportedProjectScopedFeeds": "Project-scoped feeds are not supported by this version of the \"Download Package\" task. Please use version 1 or higher."
}
}
}
6 changes: 3 additions & 3 deletions Tasks/DownloadPackageV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"author": "ms-vscs-rm",
"version": {
"Major": 0,
"Minor": 169,
"Patch": 2
"Minor": 170,
"Patch": 0
},
"demands": [],
"minimumAgentVersion": "1.99.0",
Expand Down Expand Up @@ -107,4 +107,4 @@
"OperationFailed": "ms-resource:loc.messages.OperationFailed",
"UnsupportedProjectScopedFeeds": "ms-resource:loc.messages.UnsupportedProjectScopedFeeds"
}
}
}
6 changes: 3 additions & 3 deletions Tasks/DownloadPackageV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"author": "ms-vscs-rm",
"version": {
"Major": 1,
"Minor": 169,
"Patch": 2
"Minor": 170,
"Patch": 0
},
"demands": [],
"releaseNotes": "Adds support to download Maven, Python, Universal and Npm packages.",
Expand Down Expand Up @@ -187,4 +187,4 @@
"Info_Downloading": "Downloading package: %s, version: %s using feed id: %s, project: %s",
"Info_UsingArtifactToolDownload": "Using artifact tool to download the package"
}
}
}
6 changes: 3 additions & 3 deletions Tasks/DownloadPackageV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"author": "ms-vscs-rm",
"version": {
"Major": 1,
"Minor": 169,
"Patch": 2
"Minor": 170,
"Patch": 0
},
"demands": [],
"releaseNotes": "ms-resource:loc.releaseNotes",
Expand Down Expand Up @@ -186,4 +186,4 @@
"Info_Downloading": "ms-resource:loc.messages.Info_Downloading",
"Info_UsingArtifactToolDownload": "ms-resource:loc.messages.Info_UsingArtifactToolDownload"
}
}
}
6 changes: 3 additions & 3 deletions Tasks/MavenV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 169,
"Patch": 2
"Minor": 170,
"Patch": 0
},
"releaseNotes": "Configuration of the SonarQube analysis was moved to the [SonarQube](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarqube) or [SonarCloud](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarcloud) extensions, in task `Prepare Analysis Configuration`",
"demands": [
Expand Down Expand Up @@ -409,4 +409,4 @@
"AuthenticationNotNecessary": "No built-in Maven feeds requiring authentication were found. Disable 'Authenticate built-in Maven feeds' for faster builds.",
"UsingAuthFeed": "Using built-in feed: "
}
}
}
6 changes: 3 additions & 3 deletions Tasks/MavenV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 169,
"Patch": 2
"Minor": 170,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"demands": [
Expand Down Expand Up @@ -409,4 +409,4 @@
"AuthenticationNotNecessary": "ms-resource:loc.messages.AuthenticationNotNecessary",
"UsingAuthFeed": "ms-resource:loc.messages.UsingAuthFeed"
}
}
}
6 changes: 3 additions & 3 deletions Tasks/MavenV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 169,
"Patch": 2
"Minor": 170,
"Patch": 0
},
"releaseNotes": "Configuration of the SonarQube analysis was moved to the [SonarQube](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarqube) or [SonarCloud](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarcloud) extensions, in task `Prepare Analysis Configuration`",
"demands": [
Expand Down Expand Up @@ -422,4 +422,4 @@
"UsingAuthFeed": "Using built-in feed: ",
"NoTestResults": "No test result files matching %s were found, so publishing JUnit test results is being skipped."
}
}
}
6 changes: 3 additions & 3 deletions Tasks/MavenV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 169,
"Patch": 2
"Minor": 170,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"demands": [
Expand Down Expand Up @@ -422,4 +422,4 @@
"UsingAuthFeed": "ms-resource:loc.messages.UsingAuthFeed",
"NoTestResults": "ms-resource:loc.messages.NoTestResults"
}
}
}
6 changes: 3 additions & 3 deletions Tasks/NpmAuthenticateV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 0,
"Minor": 169,
"Patch": 2
"Minor": 170,
"Patch": 0
},
"runsOn": [
"Agent",
Expand Down Expand Up @@ -67,4 +67,4 @@
"argumentFormat": ""
}
}
}
}
Loading

0 comments on commit 1a3f41c

Please sign in to comment.