Skip to content

Commit 3575916

Browse files
johntericksonAasim Malladi
andauthored
Null-proof (#12656)
* Null-proof * Addressed PR comments Co-authored-by: Aasim Malladi <[email protected]>
1 parent ee87882 commit 3575916

File tree

43 files changed

+125
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+125
-103
lines changed

Tasks/Common/packaging-common/Strings/resources.resjson/en-US/resources.resjson

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@
2525
"loc.messages.NGCommon_UnabletoDetectNuGetVersion": "Unknown NuGet version selected.",
2626
"loc.messages.NGCommon_UnableToFindTool": "Unable to find tool %s",
2727
"loc.messages.Warning_SessionCreationFailed": "Could not create provenance session.",
28-
"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, uncheck the 'Check for Latest Version' option in the task."
28+
"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, uncheck the 'Check for Latest Version' option in the task.",
29+
"loc.messages.Warning_IncompatibleNugetMsbuildVersion": "The detected version of MSBuild (%s) is incompatible with NuGet (%s). See https://aka.ms/AA84eyr"
2930
}

Tasks/Common/packaging-common/module.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"NGCommon_UnabletoDetectNuGetVersion": "Unknown NuGet version selected.",
2727
"NGCommon_UnableToFindTool": "Unable to find tool %s",
2828
"Warning_SessionCreationFailed": "Could not create provenance session.",
29-
"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, uncheck the 'Check for Latest Version' option in the task."
29+
"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, uncheck the 'Check for Latest Version' option in the task.",
30+
"Warning_IncompatibleNugetMsbuildVersion": "The detected version of MSBuild (%s) is incompatible with NuGet (%s). See https://aka.ms/AA84eyr"
3031
}
3132
}

Tasks/Common/packaging-common/nuget/NuGetToolGetter.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ export async function getNuGet(versionSpec: string, checkLatest?: boolean, addNu
8888
console.log(taskLib.loc("Info_UsingVersion", version));
8989
toolPath= toolLib.findLocalTool(NUGET_TOOL_NAME, version);
9090

91+
// Check if NuGet version is incompatible with msbuild
92+
issueWarningWhenNuGetIncompatible(version);
93+
9194
if (addNuGetToPath){
9295
console.log(taskLib.loc("Info_UsingToolPath", toolPath));
9396
toolLib.prependPath(toolPath);
@@ -99,6 +102,18 @@ export async function getNuGet(versionSpec: string, checkLatest?: boolean, addNu
99102
return fullNuGetPath;
100103
}
101104

105+
export async function issueWarningWhenNuGetIncompatible(nugetVersion: string) {
106+
const nugetSemVer = semver.coerce(nugetVersion);
107+
108+
// invert so the below is not called in unit tests
109+
if (!semver.gte(nugetSemVer, '4.8.2')) {
110+
const msbuildSemVer = await getMSBuildVersion();
111+
if (semver.satisfies(msbuildSemVer, '>=16.5.0')) {
112+
taskLib.logIssue(taskLib.IssueType.Warning, taskLib.loc('Warning_IncompatibleNugetMsbuildVersion', msbuildSemVer, nugetSemVer));
113+
}
114+
}
115+
}
116+
102117
function pathExistsAsFile(path: string) {
103118
try {
104119
return taskLib.stats(path).isFile();
@@ -146,7 +161,7 @@ export async function cacheBundledNuGet(
146161
if (cachedVersionToUse == null) {
147162
// Attempt to match nuget.exe version with msbuild.exe version
148163
const msbuildSemVer = await getMSBuildVersion();
149-
if (msbuildSemVer && semver.gte(msbuildSemVer, '16.5.0')) {
164+
if (semver.satisfies(msbuildSemVer, '>=16.5.0')) {
150165
taskLib.debug('Snapping to v5.4.0');
151166
cachedVersionToUse = '5.4.0';
152167
nugetPathSuffix = 'NuGet/5.4.0/';

Tasks/DotNetCoreCLIV2/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"demands": [],
1818
"version": {
1919
"Major": 2,
20-
"Minor": 167,
21-
"Patch": 7
20+
"Minor": 173,
21+
"Patch": 0
2222
},
2323
"minimumAgentVersion": "2.115.0",
2424
"instanceNameFormat": "dotnet $(command)",

Tasks/DotNetCoreCLIV2/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"demands": [],
1818
"version": {
1919
"Major": 2,
20-
"Minor": 167,
21-
"Patch": 7
20+
"Minor": 173,
21+
"Patch": 0
2222
},
2323
"minimumAgentVersion": "2.115.0",
2424
"instanceNameFormat": "ms-resource:loc.instanceNameFormat",

Tasks/DownloadPackageV0/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"author": "ms-vscs-rm",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 167,
13-
"Patch": 5
12+
"Minor": 173,
13+
"Patch": 0
1414
},
1515
"demands": [],
1616
"minimumAgentVersion": "1.99.0",

Tasks/DownloadPackageV0/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"author": "ms-vscs-rm",
1010
"version": {
1111
"Major": 0,
12-
"Minor": 167,
13-
"Patch": 5
12+
"Minor": 173,
13+
"Patch": 0
1414
},
1515
"demands": [],
1616
"minimumAgentVersion": "1.99.0",

Tasks/DownloadPackageV1/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"author": "ms-vscs-rm",
1010
"version": {
1111
"Major": 1,
12-
"Minor": 167,
13-
"Patch": 5
12+
"Minor": 173,
13+
"Patch": 0
1414
},
1515
"demands": [],
1616
"releaseNotes": "Adds support to download Maven, Python, Universal and Npm packages.",

Tasks/DownloadPackageV1/task.loc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"author": "ms-vscs-rm",
1010
"version": {
1111
"Major": 1,
12-
"Minor": 167,
13-
"Patch": 5
12+
"Minor": 173,
13+
"Patch": 0
1414
},
1515
"demands": [],
1616
"releaseNotes": "ms-resource:loc.releaseNotes",

Tasks/MavenV2/task.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
"author": "Microsoft Corporation",
1818
"version": {
1919
"Major": 2,
20-
"Minor": 167,
21-
"Patch": 5
20+
"Minor": 173,
21+
"Patch": 0
2222
},
2323
"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`",
2424
"demands": [

0 commit comments

Comments
 (0)