Skip to content

Commit

Permalink
added .net core 3.0 information and fixed bug for modify output path (#…
Browse files Browse the repository at this point in the history
…11800)

* added .net core 3.0 information and fixed bug for modify output path

* fixed test

* 1. Display message at the end
2. Revert output folder modification behaviour

* Rephrased the infromational message

* Changed message and added the message to be displayed as warning when command exection fails

* Message will only be shown as warning if command is publish

* Fixed for message to be printed only once
  • Loading branch information
hiyadav authored Nov 26, 2019
1 parent 6164cbc commit 35e7bc1
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,6 @@
"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.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"
}
68 changes: 41 additions & 27 deletions Tasks/DotNetCoreCLIV2/dotnetcore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import * as pushCommand from './pushcommand';
import * as restoreCommand from './restorecommand';
import * as utility from './Common/utility';

let MessagePrinted = false;

export class dotNetExe {
private command: string;
private projects: string[];
Expand All @@ -34,30 +36,37 @@ export class dotNetExe {
tl.setResourcePath(path.join(__dirname, "task.json"));
this.setConsoleCodePage();

switch (this.command) {
case "build":
case "publish":
case "run":
await this.executeBasicCommand();
break;
case "custom":
this.command = tl.getInput("custom", true);
await this.executeBasicCommand();
break;
case "test":
await this.executeTestCommand();
break;
case "restore":
await restoreCommand.run();
break;
case "pack":
await packCommand.run();
break;
case "push":
await pushCommand.run();
break;
default:
tl.setResult(tl.TaskResult.Failed, tl.loc("Error_CommandNotRecognized", this.command));
try {
switch (this.command) {
case "build":
case "publish":
case "run":
await this.executeBasicCommand();
break;
case "custom":
this.command = tl.getInput("custom", true);
await this.executeBasicCommand();
break;
case "test":
await this.executeTestCommand();
break;
case "restore":
await restoreCommand.run();
break;
case "pack":
await packCommand.run();
break;
case "push":
await pushCommand.run();
break;
default:
throw tl.loc("Error_CommandNotRecognized", this.command);
}
}
finally {
if (!MessagePrinted) {
console.log(tl.loc('NetCore3Update'));
}
}
}

Expand Down Expand Up @@ -113,6 +122,11 @@ export class dotNetExe {
}
}
if (failedProjects.length > 0) {
if (this.command === 'publish' && !MessagePrinted) {
tl.warning(tl.loc('NetCore3Update'));
MessagePrinted = true;
}

throw tl.loc("dotnetCommandFailed", failedProjects);
}
}
Expand Down Expand Up @@ -258,7 +272,7 @@ export class dotNetExe {
}

private extractOutputArgument(): void {
if (!this.arguments || !this.arguments.trim()) {
if (!this.arguments || !this.arguments.trim()) {
return;
}

Expand Down Expand Up @@ -348,7 +362,7 @@ export class dotNetExe {
tl.error(tl.loc("noWebProjectFound"));
}
return projectFilesUsingWebSdk;
}
}
return resolvedProjectFiles;
}
return projectFiles;
Expand All @@ -360,7 +374,7 @@ export class dotNetExe {
try {
var fileBuffer: Buffer = fs.readFileSync(projectfile);
var webConfigContent: string;

var fileEncodings = ['utf8', 'utf16le'];

for(var i = 0; i < fileEncodings.length; i++) {
Expand Down
5 changes: 3 additions & 2 deletions Tasks/DotNetCoreCLIV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 161,
"Minor": 162,
"Patch": 0
},
"minimumAgentVersion": "2.115.0",
Expand Down Expand Up @@ -557,6 +557,7 @@
"NGCommon_UnabletoDetectNuGetVersion": "Unknown NuGet version selected.",
"NGCommon_UnableToFindTool": "Unable to find tool %s",
"Warning_SessionCreationFailed": "Could not create provenance session: %s",
"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."
"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"
}
}
7 changes: 4 additions & 3 deletions Tasks/DotNetCoreCLIV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"demands": [],
"version": {
"Major": 2,
"Minor": 161,
"Minor": 162,
"Patch": 0
},
"minimumAgentVersion": "2.115.0",
Expand Down Expand Up @@ -557,6 +557,7 @@
"NGCommon_UnabletoDetectNuGetVersion": "ms-resource:loc.messages.NGCommon_UnabletoDetectNuGetVersion",
"NGCommon_UnableToFindTool": "ms-resource:loc.messages.NGCommon_UnableToFindTool",
"Warning_SessionCreationFailed": "ms-resource:loc.messages.Warning_SessionCreationFailed",
"Warning_UpdatingNuGetVersion": "ms-resource:loc.messages.Warning_UpdatingNuGetVersion"
"Warning_UpdatingNuGetVersion": "ms-resource:loc.messages.Warning_UpdatingNuGetVersion",
"NetCore3Update": "ms-resource:loc.messages.NetCore3Update"
}
}
}

0 comments on commit 35e7bc1

Please sign in to comment.