From a24e39a8fc57e23c61faf4e3172793e0ea149cd1 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Thu, 20 Jun 2019 15:38:59 +0530 Subject: [PATCH 01/15] Searching for csproj, vbproj, fsproj using sdk Microsoft.Net.Sdk.Web --- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 40 +++- Tasks/DotNetCoreCLIV2/make.json | 6 + Tasks/DotNetCoreCLIV2/package-lock.json | 260 +++++++++++++++++++----- Tasks/DotNetCoreCLIV2/package.json | 4 +- Tasks/DotNetCoreCLIV2/task.json | 4 +- Tasks/DotNetCoreCLIV2/task.loc.json | 4 +- 6 files changed, 254 insertions(+), 64 deletions(-) diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index d30c33978713..e1709a3b268a 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -9,6 +9,10 @@ import * as pushCommand from './pushcommand'; import * as restoreCommand from './restorecommand'; import * as utility from './Common/utility'; + +var ltxdomutility = require('webdeployment-common/ltxdomutility') +var fileEncoding = require('webdeployment-common/fileencoding') + export class dotNetExe { private command: string; private projects: string[]; @@ -325,22 +329,50 @@ export class dotNetExe { } var projectFiles = utility.getProjectFiles(projectPattern); + var resolvedProjectFiles: string[] = []; if (searchWebProjects) { - projectFiles = projectFiles.filter(function (file, index, files): boolean { + resolvedProjectFiles = projectFiles.filter(function (file, index, files): boolean { var directory = path.dirname(file); return tl.exist(path.join(directory, "web.config")) || tl.exist(path.join(directory, "wwwroot")); }); - if (!projectFiles.length) { - tl.error(tl.loc("noWebProjctFound")); - } + if (!resolvedProjectFiles.length) { + var projectFilesUsingWebSdk = projectFiles.filter(this.isWebSdkUsed) + if(!projectFilesUsingWebSdk.length) { + tl.error(tl.loc("noWebProjectFound")); + } + return projectFilesUsingWebSdk; + } + return resolvedProjectFiles; } return projectFiles; } + private isWebSdkUsed(projectfile: string) { + var fileBuffer: Buffer = fs.readFileSync(projectfile); + var fileEncodeType = fileEncoding.detectFileEncoding(projectfile, fileBuffer); + var webConfigContent: string = fileBuffer.toString(fileEncodeType[0]); + + if(fileEncodeType[1]) { + webConfigContent = webConfigContent.slice(1); + } + + var ltxDom = new ltxdomutility.LtxDomUtility(webConfigContent); + var projectDomArray: Array = ltxDom.getElementsByTagName("project"); + + for(var project of projectDomArray) { + if(project.attrs['Sdk'].toLowerCase() == "microsoft.net.sdk.web" || + project.attrs['sdk'].toLowerCase() == "microsoft.net.sdk.web") { + return true; + } + } + + return false; + } + private isPublishCommand(): boolean { return this.command === "publish"; } diff --git a/Tasks/DotNetCoreCLIV2/make.json b/Tasks/DotNetCoreCLIV2/make.json index d2028214f63a..6fe04d17529d 100644 --- a/Tasks/DotNetCoreCLIV2/make.json +++ b/Tasks/DotNetCoreCLIV2/make.json @@ -9,6 +9,12 @@ "module": "../Common/packaging-common", "type": "node", "compile": true + }, + { + "module": "../Common/webdeployment-common", + "type": "node", + "dest": "./", + "compile" : true } ], "rm": [ diff --git a/Tasks/DotNetCoreCLIV2/package-lock.json b/Tasks/DotNetCoreCLIV2/package-lock.json index 7c8244da0df6..d8df01b6004a 100644 --- a/Tasks/DotNetCoreCLIV2/package-lock.json +++ b/Tasks/DotNetCoreCLIV2/package-lock.json @@ -50,6 +50,11 @@ "@types/node": "*" } }, + "abbrev": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", + "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" + }, "adm-zip": { "version": "0.4.13", "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.13.tgz", @@ -107,20 +112,19 @@ } }, "azure-devops-node-api": { - "version": "6.6.3", - "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-6.6.3.tgz", - "integrity": "sha512-94wSu4O6CSSXoqYWg7Rzt2/IqbW2xVNu2qOtx6e7lnXxnDOcAu4eRzi8tgVNHsXTIGOVEsTqgMvGvFThKr9Pig==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/azure-devops-node-api/-/azure-devops-node-api-8.0.0.tgz", + "integrity": "sha512-QkIzphuE3y/hZVMB6ONN0Dev5r9+CIAiopWulwoYx1Er0kYcsbXsKXKynuLSxsVPocMppbr4YPhTsX2eHY/Mjw==", "requires": { - "os": "0.1.1", "tunnel": "0.0.4", - "typed-rest-client": "1.0.9", + "typed-rest-client": "1.2.0", "underscore": "1.8.3" }, "dependencies": { "typed-rest-client": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.0.9.tgz", - "integrity": "sha512-iOdwgmnP/tF6Qs+oY4iEtCf/3fnCDl7Gy9LGPJ4E3M4Wj3uaSko15FVwbsaBmnBqTJORnXBWVY5306D4HH8oiA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.2.0.tgz", + "integrity": "sha512-FrUshzZ1yxH8YwGR29PWWnfksLEILbWJydU7zfIRkyH7kAEzB62uMAl2WY6EyolWpLpVHeJGgQm45/MaruaHpw==", "requires": { "tunnel": "0.0.4", "underscore": "1.8.3" @@ -171,6 +175,15 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, + "binary": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", + "integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=", + "requires": { + "buffers": "~0.1.1", + "chainsaw": "~0.1.0" + } + }, "bl": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz", @@ -193,6 +206,19 @@ "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" }, + "buffers": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", + "integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=" + }, + "chainsaw": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", + "integrity": "sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=", + "requires": { + "traverse": ">=0.3.0 <0.4" + } + }, "compress-commons": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-1.2.2.tgz", @@ -228,6 +254,43 @@ "readable-stream": "^2.0.0" } }, + "decompress-zip": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/decompress-zip/-/decompress-zip-0.3.0.tgz", + "integrity": "sha1-rjvLfjTGWHmt/nfhnDD4ZgK0vbA=", + "requires": { + "binary": "^0.3.0", + "graceful-fs": "^4.1.3", + "mkpath": "^0.1.0", + "nopt": "^3.0.1", + "q": "^1.1.2", + "readable-stream": "^1.1.8", + "touch": "0.0.3" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "readable-stream": { + "version": "1.1.14", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", + "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" + } + } + }, "end-of-stream": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", @@ -313,17 +376,20 @@ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, "ip-address": { - "version": "5.9.0", - "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-5.9.0.tgz", - "integrity": "sha512-+4yKpEyent8IpjuDQVkIpzIDbxSlCHTPdmaXCRLH0ttt3YsrbNxuZJ6h+1wLPx10T7gWsLN7M6BXIHV2vZNOGw==", + "version": "5.9.2", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-5.9.2.tgz", + "integrity": "sha512-7aeFm/7oqo0mMhubTSjZ2Juw/F+WJ3hyfCScNVRQdz5RSRhw1Rj4ZlBFsmEajeKgQDI8asqVs31h8DpxEv7IfQ==", "requires": { "jsbn": "1.1.0", - "lodash.find": "^4.6.0", - "lodash.max": "^4.0.1", - "lodash.merge": "^4.6.1", - "lodash.padstart": "^4.6.1", - "lodash.repeat": "^4.1.0", - "sprintf-js": "1.1.1" + "lodash": "^4.17.11", + "sprintf-js": "1.1.2" + }, + "dependencies": { + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==" + } } }, "isarray": { @@ -358,31 +424,6 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" }, - "lodash.find": { - "version": "4.6.0", - "resolved": "https://registry.npmjs.org/lodash.find/-/lodash.find-4.6.0.tgz", - "integrity": "sha1-ywcE1Hq3F4n/oN6Ll92Sb7iLE7E=" - }, - "lodash.max": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/lodash.max/-/lodash.max-4.0.1.tgz", - "integrity": "sha1-hzVWbGGLNan3YFILSHrnllivE2o=" - }, - "lodash.merge": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", - "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==" - }, - "lodash.padstart": { - "version": "4.6.1", - "resolved": "https://registry.npmjs.org/lodash.padstart/-/lodash.padstart-4.6.1.tgz", - "integrity": "sha1-0uPuv/DZ05rVD1y9G1KnvOa7YRs=" - }, - "lodash.repeat": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/lodash.repeat/-/lodash.repeat-4.1.0.tgz", - "integrity": "sha1-/H3oEx2MisB+S0n3T/6CnR8r7EQ=" - }, "ltx": { "version": "2.8.1", "resolved": "https://registry.npmjs.org/ltx/-/ltx-2.8.1.tgz", @@ -399,11 +440,24 @@ "brace-expansion": "^1.1.7" } }, + "mkpath": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/mkpath/-/mkpath-0.1.0.tgz", + "integrity": "sha1-dVSm+Nhxg0zJe1RisSLEwSTW3pE=" + }, "mockery": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/mockery/-/mockery-1.7.0.tgz", "integrity": "sha1-9O3g2HUMHJcnwnLqLGBiniyaHE8=" }, + "nopt": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", + "requires": { + "abbrev": "1" + } + }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", @@ -420,11 +474,6 @@ "wrappy": "1" } }, - "os": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/os/-/os-0.1.1.tgz", - "integrity": "sha1-IIhF6J4ZOtTZcUdLk5R3NqVtE/M=" - }, "packaging-common": { "version": "file:../../_build/Tasks/Common/packaging-common-1.0.1.tgz", "requires": { @@ -435,14 +484,14 @@ "@types/node": "10.12.9", "@types/q": "1.5.2", "adm-zip": "^0.4.11", - "azure-devops-node-api": "^6.6.0", + "azure-devops-node-api": "8.0.0", "azure-pipelines-task-lib": "2.8.0", "azure-pipelines-tool-lib": "0.12.0", "ini": "^1.3.4", "ip-address": "^5.8.9", "ltx": "^2.6.2", "q": "^1.5.0", - "typed-rest-client": "0.12.0" + "typed-rest-client": "1.2.0" } }, "path-is-absolute": { @@ -484,6 +533,11 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=" }, + "sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" + }, "semver": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", @@ -500,9 +554,9 @@ "integrity": "sha1-NZbmMHp4FUT1kfN9phg2DzHbV7E=" }, "sprintf-js": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.1.tgz", - "integrity": "sha1-Nr54Mgr+WAH2zqPueLblqrlA6gw=" + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-VE0SOVEHCk7Qc8ulkWw3ntAzXuqf7S2lvwQaDLRnUeIEaKNQJzV6BwmLKhOqT61aGhfUMrXeaBk+oDGCzvhcug==" }, "string_decoder": { "version": "1.0.3", @@ -523,15 +577,38 @@ "xtend": "^4.0.0" } }, + "touch": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/touch/-/touch-0.0.3.tgz", + "integrity": "sha1-Ua7z1ElXHU8oel2Hyci0kYGg2x0=", + "requires": { + "nopt": "~1.0.10" + }, + "dependencies": { + "nopt": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", + "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", + "requires": { + "abbrev": "1" + } + } + } + }, + "traverse": { + "version": "0.3.9", + "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", + "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=" + }, "tunnel": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", "integrity": "sha1-LTeFoVjBdMmhbcLARuxfxfF0IhM=" }, "typed-rest-client": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-0.12.0.tgz", - "integrity": "sha1-Y3b1Un9CfaEh3K/f1+QeEyHgcgw=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-1.2.0.tgz", + "integrity": "sha512-FrUshzZ1yxH8YwGR29PWWnfksLEILbWJydU7zfIRkyH7kAEzB62uMAl2WY6EyolWpLpVHeJGgQm45/MaruaHpw==", "requires": { "tunnel": "0.0.4", "underscore": "1.8.3" @@ -562,6 +639,15 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" }, + "typed-rest-client": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-0.12.0.tgz", + "integrity": "sha1-Y3b1Un9CfaEh3K/f1+QeEyHgcgw=", + "requires": { + "tunnel": "0.0.4", + "underscore": "1.8.3" + } + }, "vso-node-api": { "version": "6.5.0", "resolved": "https://registry.npmjs.org/vso-node-api/-/vso-node-api-6.5.0.tgz", @@ -638,11 +724,75 @@ } } }, + "webdeployment-common": { + "version": "file:../../_build/Tasks/Common/webdeployment-common-1.0.0.tgz", + "requires": { + "archiver": "1.2.0", + "decompress-zip": "0.3.0", + "ltx": "2.8.0", + "q": "1.4.1", + "vsts-task-lib": "2.0.1-preview", + "winreg": "1.2.2", + "xml2js": "0.4.13" + }, + "dependencies": { + "ltx": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/ltx/-/ltx-2.8.0.tgz", + "integrity": "sha512-SJJUrmDgXP0gkUzgErfkaeD+pugM8GYxerTALQa1gTUb5W1wrC4k07GZU+QNZd7MpFqJSYWXTQSUy8Ps03hx5Q==", + "requires": { + "inherits": "^2.0.1" + } + }, + "node-uuid": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", + "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=" + }, + "q": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", + "integrity": "sha1-VXBbzZPF82c1MMLCy8DCs63cKG4=" + }, + "vsts-task-lib": { + "version": "2.0.1-preview", + "resolved": "https://registry.npmjs.org/vsts-task-lib/-/vsts-task-lib-2.0.1-preview.tgz", + "integrity": "sha1-rfx4BRaPtJLVcD7eZIXOt4G2SrQ=", + "requires": { + "minimatch": "^3.0.0", + "mockery": "^1.7.0", + "node-uuid": "^1.4.7", + "q": "^1.1.2", + "semver": "^5.1.0", + "shelljs": "^0.3.0" + } + } + } + }, + "winreg": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.2.tgz", + "integrity": "sha1-hQmvo7ccW70RCm18YkfsZ3NsWY8=" + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, + "xml2js": { + "version": "0.4.13", + "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.13.tgz", + "integrity": "sha1-+EQ+B0Oeb/ktmVKPSbvTScyfMGs=", + "requires": { + "sax": ">=0.6.0", + "xmlbuilder": ">=2.4.6" + } + }, + "xmlbuilder": { + "version": "13.0.2", + "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-13.0.2.tgz", + "integrity": "sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ==" + }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", diff --git a/Tasks/DotNetCoreCLIV2/package.json b/Tasks/DotNetCoreCLIV2/package.json index 9e69cd967fd6..57a595731070 100644 --- a/Tasks/DotNetCoreCLIV2/package.json +++ b/Tasks/DotNetCoreCLIV2/package.json @@ -22,6 +22,8 @@ "azure-pipelines-task-lib": "2.8.0", "packaging-common": "file:../../_build/Tasks/Common/packaging-common-1.0.1.tgz", "q": "^1.4.1", - "utility-common": "file:../../_build/Tasks/Common/utility-common-1.0.2.tgz" + "utility-common": "file:../../_build/Tasks/Common/utility-common-1.0.2.tgz", + "vso-node-api": "6.0.1-preview", + "webdeployment-common": "file:../../_build/Tasks/Common/webdeployment-common-1.0.0.tgz" } } diff --git a/Tasks/DotNetCoreCLIV2/task.json b/Tasks/DotNetCoreCLIV2/task.json index 633cecc27d98..4bcd51af4a4e 100644 --- a/Tasks/DotNetCoreCLIV2/task.json +++ b/Tasks/DotNetCoreCLIV2/task.json @@ -17,8 +17,8 @@ "demands": [], "version": { "Major": 2, - "Minor": 154, - "Patch": 3 + "Minor": 155, + "Patch": 24 }, "minimumAgentVersion": "2.115.0", "instanceNameFormat": "dotnet $(command)", diff --git a/Tasks/DotNetCoreCLIV2/task.loc.json b/Tasks/DotNetCoreCLIV2/task.loc.json index 3e5bf7a5c93f..7f989a7c0e5d 100644 --- a/Tasks/DotNetCoreCLIV2/task.loc.json +++ b/Tasks/DotNetCoreCLIV2/task.loc.json @@ -17,8 +17,8 @@ "demands": [], "version": { "Major": 2, - "Minor": 154, - "Patch": 3 + "Minor": 155, + "Patch": 24 }, "minimumAgentVersion": "2.115.0", "instanceNameFormat": "ms-resource:loc.instanceNameFormat", From b2497ae1aaf260f3582a492e4b36b9227b7ac6e5 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Thu, 20 Jun 2019 15:56:14 +0530 Subject: [PATCH 02/15] Updating package.json --- Tasks/DotNetCoreCLIV2/package-lock.json | 10 ---------- Tasks/DotNetCoreCLIV2/package.json | 1 - 2 files changed, 11 deletions(-) diff --git a/Tasks/DotNetCoreCLIV2/package-lock.json b/Tasks/DotNetCoreCLIV2/package-lock.json index d8df01b6004a..4450f942b22f 100644 --- a/Tasks/DotNetCoreCLIV2/package-lock.json +++ b/Tasks/DotNetCoreCLIV2/package-lock.json @@ -665,16 +665,6 @@ "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", "integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ=" }, - "vso-node-api": { - "version": "6.0.1-preview", - "resolved": "https://registry.npmjs.org/vso-node-api/-/vso-node-api-6.0.1-preview.tgz", - "integrity": "sha1-RBprv5s8aNpiTbAeo1y6jwpMLKs=", - "requires": { - "q": "^1.0.1", - "tunnel": "0.0.4", - "underscore": "^1.8.3" - } - }, "vsts-task-lib": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/vsts-task-lib/-/vsts-task-lib-2.6.0.tgz", diff --git a/Tasks/DotNetCoreCLIV2/package.json b/Tasks/DotNetCoreCLIV2/package.json index 57a595731070..8516d3fcb3c1 100644 --- a/Tasks/DotNetCoreCLIV2/package.json +++ b/Tasks/DotNetCoreCLIV2/package.json @@ -23,7 +23,6 @@ "packaging-common": "file:../../_build/Tasks/Common/packaging-common-1.0.1.tgz", "q": "^1.4.1", "utility-common": "file:../../_build/Tasks/Common/utility-common-1.0.2.tgz", - "vso-node-api": "6.0.1-preview", "webdeployment-common": "file:../../_build/Tasks/Common/webdeployment-common-1.0.0.tgz" } } From 7391524c033439af823a94eedd2bacf6c0a91e44 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Thu, 20 Jun 2019 16:49:23 +0530 Subject: [PATCH 03/15] Updating error message --- Tasks/DotNetCoreCLIV2/task.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/DotNetCoreCLIV2/task.json b/Tasks/DotNetCoreCLIV2/task.json index 0b8f637bb7fd..e8e0e874acc9 100644 --- a/Tasks/DotNetCoreCLIV2/task.json +++ b/Tasks/DotNetCoreCLIV2/task.json @@ -529,7 +529,7 @@ "dotnetCommandFailed": "Dotnet command failed with non-zero exit code on the following projects : %s", "noProjectFilesFound": "Project file(s) matching the specified pattern were not found.", "noPublishFolderFoundToZip": "A publish folder could not be found to zip for project file: %s.", - "noWebProjectFound": "No web project was found in the repository. Web projects are identified by presence of either a web.config file or wwwroot folder in the directory. 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.", + "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 csproj 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.", "zipFailed": "Zip failed with error: %s", "Error_ApiKeyNotSupported": "DotNetCore currently does not support using an encrypted Api Key.", "Error_ExpectedConfigurationElement": "Invalid xml. Expected element named 'configuration'.", From b32a0315f2777de64adbb044926af5bd512379e7 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Fri, 21 Jun 2019 12:18:30 +0530 Subject: [PATCH 04/15] Review comments --- .../resources.resjson/en-US/resources.resjson | 2 +- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 29 +-- Tasks/DotNetCoreCLIV2/make.json | 6 - Tasks/DotNetCoreCLIV2/package-lock.json | 203 ++---------------- Tasks/DotNetCoreCLIV2/package.json | 3 +- 5 files changed, 26 insertions(+), 217 deletions(-) diff --git a/Tasks/DotNetCoreCLIV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/DotNetCoreCLIV2/Strings/resources.resjson/en-US/resources.resjson index dc7aaaf05254..2b10b907d0b7 100644 --- a/Tasks/DotNetCoreCLIV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/DotNetCoreCLIV2/Strings/resources.resjson/en-US/resources.resjson @@ -103,7 +103,7 @@ "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 or wwwroot folder in the directory. 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.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 csproj 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'.", diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index e34e30948c8e..f21cc5b74778 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -2,6 +2,7 @@ import tl = require("azure-pipelines-task-lib/task"); import tr = require("azure-pipelines-task-lib/toolrunner"); import path = require("path"); import fs = require("fs"); +import ltx = require("ltx"); var archiver = require('archiver'); import * as packCommand from './packcommand'; @@ -9,10 +10,6 @@ import * as pushCommand from './pushcommand'; import * as restoreCommand from './restorecommand'; import * as utility from './Common/utility'; - -var ltxdomutility = require('webdeployment-common/ltxdomutility') -var fileEncoding = require('webdeployment-common/fileencoding') - export class dotNetExe { private command: string; private projects: string[]; @@ -254,7 +251,7 @@ export class dotNetExe { } private extractOutputArgument(): void { - if (!this.arguments || !this.arguments.trim()) { + if (!this.arguments || !this.arguments.trim()) { return; } @@ -347,30 +344,16 @@ export class dotNetExe { } return resolvedProjectFiles; } - return projectFiles; } private isWebSdkUsed(projectfile: string) { var fileBuffer: Buffer = fs.readFileSync(projectfile); - var fileEncodeType = fileEncoding.detectFileEncoding(projectfile, fileBuffer); - var webConfigContent: string = fileBuffer.toString(fileEncodeType[0]); - - if(fileEncodeType[1]) { - webConfigContent = webConfigContent.slice(1); - } - - var ltxDom = new ltxdomutility.LtxDomUtility(webConfigContent); - var projectDomArray: Array = ltxDom.getElementsByTagName("project"); - - for(var project of projectDomArray) { - if(project.attrs['Sdk'].toLowerCase() == "microsoft.net.sdk.web" || - project.attrs['sdk'].toLowerCase() == "microsoft.net.sdk.web") { - return true; - } - } + var webConfigContent: string = fileBuffer.toString(); - return false; + var projectSdkUsed: string = ltx.parse(webConfigContent).getAttr("sdk") || ltx.parse(webConfigContent).getAttr("Sdk") + + return projectSdkUsed != undefined && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web" } private isPublishCommand(): boolean { diff --git a/Tasks/DotNetCoreCLIV2/make.json b/Tasks/DotNetCoreCLIV2/make.json index 6fe04d17529d..d2028214f63a 100644 --- a/Tasks/DotNetCoreCLIV2/make.json +++ b/Tasks/DotNetCoreCLIV2/make.json @@ -9,12 +9,6 @@ "module": "../Common/packaging-common", "type": "node", "compile": true - }, - { - "module": "../Common/webdeployment-common", - "type": "node", - "dest": "./", - "compile" : true } ], "rm": [ diff --git a/Tasks/DotNetCoreCLIV2/package-lock.json b/Tasks/DotNetCoreCLIV2/package-lock.json index 4450f942b22f..4cd4affe6b77 100644 --- a/Tasks/DotNetCoreCLIV2/package-lock.json +++ b/Tasks/DotNetCoreCLIV2/package-lock.json @@ -50,11 +50,6 @@ "@types/node": "*" } }, - "abbrev": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", - "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" - }, "adm-zip": { "version": "0.4.13", "resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.13.tgz", @@ -175,15 +170,6 @@ "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" }, - "binary": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/binary/-/binary-0.3.0.tgz", - "integrity": "sha1-n2BVO8XOjDOG87VTz/R0Yq3sqnk=", - "requires": { - "buffers": "~0.1.1", - "chainsaw": "~0.1.0" - } - }, "bl": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.1.tgz", @@ -206,19 +192,6 @@ "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" }, - "buffers": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/buffers/-/buffers-0.1.1.tgz", - "integrity": "sha1-skV5w77U1tOWru5tmorn9Ugqt7s=" - }, - "chainsaw": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/chainsaw/-/chainsaw-0.1.0.tgz", - "integrity": "sha1-XqtQsor+WAdNDVgpE4iCi15fvJg=", - "requires": { - "traverse": ">=0.3.0 <0.4" - } - }, "compress-commons": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/compress-commons/-/compress-commons-1.2.2.tgz", @@ -254,43 +227,6 @@ "readable-stream": "^2.0.0" } }, - "decompress-zip": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/decompress-zip/-/decompress-zip-0.3.0.tgz", - "integrity": "sha1-rjvLfjTGWHmt/nfhnDD4ZgK0vbA=", - "requires": { - "binary": "^0.3.0", - "graceful-fs": "^4.1.3", - "mkpath": "^0.1.0", - "nopt": "^3.0.1", - "q": "^1.1.2", - "readable-stream": "^1.1.8", - "touch": "0.0.3" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, "end-of-stream": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.0.tgz", @@ -440,24 +376,11 @@ "brace-expansion": "^1.1.7" } }, - "mkpath": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/mkpath/-/mkpath-0.1.0.tgz", - "integrity": "sha1-dVSm+Nhxg0zJe1RisSLEwSTW3pE=" - }, "mockery": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/mockery/-/mockery-1.7.0.tgz", "integrity": "sha1-9O3g2HUMHJcnwnLqLGBiniyaHE8=" }, - "nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", - "requires": { - "abbrev": "1" - } - }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", @@ -533,11 +456,6 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", "integrity": "sha1-iTMSr2myEj3vcfV4iQAWce6yyFM=" }, - "sax": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz", - "integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==" - }, "semver": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.3.0.tgz", @@ -577,29 +495,6 @@ "xtend": "^4.0.0" } }, - "touch": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/touch/-/touch-0.0.3.tgz", - "integrity": "sha1-Ua7z1ElXHU8oel2Hyci0kYGg2x0=", - "requires": { - "nopt": "~1.0.10" - }, - "dependencies": { - "nopt": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", - "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", - "requires": { - "abbrev": "1" - } - } - } - }, - "traverse": { - "version": "0.3.9", - "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.3.9.tgz", - "integrity": "sha1-cXuPIgzAu3tE5AUUwisui7xw2Lk=" - }, "tunnel": { "version": "0.0.4", "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.4.tgz", @@ -638,7 +533,24 @@ "version": "5.7.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.0.tgz", "integrity": "sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA==" - }, + } + } + }, + "uuid": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", + "integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ=" + }, + "vso-node-api": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/vso-node-api/-/vso-node-api-6.5.0.tgz", + "integrity": "sha512-hFjPLMJkq02zF8U+LhZ4airH0ivaiKzGdlNAQlYFB3lWuGH/UANUrl63DVPUQOyGw+7ZNQ+ufM44T6mWN92xyg==", + "requires": { + "tunnel": "0.0.4", + "typed-rest-client": "^0.12.0", + "underscore": "1.8.3" + }, + "dependencies": { "typed-rest-client": { "version": "0.12.0", "resolved": "https://registry.npmjs.org/typed-rest-client/-/typed-rest-client-0.12.0.tgz", @@ -647,24 +559,9 @@ "tunnel": "0.0.4", "underscore": "1.8.3" } - }, - "vso-node-api": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/vso-node-api/-/vso-node-api-6.5.0.tgz", - "integrity": "sha512-hFjPLMJkq02zF8U+LhZ4airH0ivaiKzGdlNAQlYFB3lWuGH/UANUrl63DVPUQOyGw+7ZNQ+ufM44T6mWN92xyg==", - "requires": { - "tunnel": "0.0.4", - "typed-rest-client": "^0.12.0", - "underscore": "1.8.3" - } } } }, - "uuid": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz", - "integrity": "sha1-PdPT55Crwk17DToDT/q6vijrvAQ=" - }, "vsts-task-lib": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/vsts-task-lib/-/vsts-task-lib-2.6.0.tgz", @@ -714,75 +611,11 @@ } } }, - "webdeployment-common": { - "version": "file:../../_build/Tasks/Common/webdeployment-common-1.0.0.tgz", - "requires": { - "archiver": "1.2.0", - "decompress-zip": "0.3.0", - "ltx": "2.8.0", - "q": "1.4.1", - "vsts-task-lib": "2.0.1-preview", - "winreg": "1.2.2", - "xml2js": "0.4.13" - }, - "dependencies": { - "ltx": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/ltx/-/ltx-2.8.0.tgz", - "integrity": "sha512-SJJUrmDgXP0gkUzgErfkaeD+pugM8GYxerTALQa1gTUb5W1wrC4k07GZU+QNZd7MpFqJSYWXTQSUy8Ps03hx5Q==", - "requires": { - "inherits": "^2.0.1" - } - }, - "node-uuid": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", - "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=" - }, - "q": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/q/-/q-1.4.1.tgz", - "integrity": "sha1-VXBbzZPF82c1MMLCy8DCs63cKG4=" - }, - "vsts-task-lib": { - "version": "2.0.1-preview", - "resolved": "https://registry.npmjs.org/vsts-task-lib/-/vsts-task-lib-2.0.1-preview.tgz", - "integrity": "sha1-rfx4BRaPtJLVcD7eZIXOt4G2SrQ=", - "requires": { - "minimatch": "^3.0.0", - "mockery": "^1.7.0", - "node-uuid": "^1.4.7", - "q": "^1.1.2", - "semver": "^5.1.0", - "shelljs": "^0.3.0" - } - } - } - }, - "winreg": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/winreg/-/winreg-1.2.2.tgz", - "integrity": "sha1-hQmvo7ccW70RCm18YkfsZ3NsWY8=" - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, - "xml2js": { - "version": "0.4.13", - "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.13.tgz", - "integrity": "sha1-+EQ+B0Oeb/ktmVKPSbvTScyfMGs=", - "requires": { - "sax": ">=0.6.0", - "xmlbuilder": ">=2.4.6" - } - }, - "xmlbuilder": { - "version": "13.0.2", - "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-13.0.2.tgz", - "integrity": "sha512-Eux0i2QdDYKbdbA6AM6xE4m6ZTZr4G4xF9kahI2ukSEMCzwce2eX9WlTI5J3s+NU7hpasFsr8hWIONae7LluAQ==" - }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", diff --git a/Tasks/DotNetCoreCLIV2/package.json b/Tasks/DotNetCoreCLIV2/package.json index 8516d3fcb3c1..9e69cd967fd6 100644 --- a/Tasks/DotNetCoreCLIV2/package.json +++ b/Tasks/DotNetCoreCLIV2/package.json @@ -22,7 +22,6 @@ "azure-pipelines-task-lib": "2.8.0", "packaging-common": "file:../../_build/Tasks/Common/packaging-common-1.0.1.tgz", "q": "^1.4.1", - "utility-common": "file:../../_build/Tasks/Common/utility-common-1.0.2.tgz", - "webdeployment-common": "file:../../_build/Tasks/Common/webdeployment-common-1.0.0.tgz" + "utility-common": "file:../../_build/Tasks/Common/utility-common-1.0.2.tgz" } } From b4ea9573c8d50a126a847c7391c13e1f7e5b4665 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Fri, 21 Jun 2019 13:22:43 +0530 Subject: [PATCH 05/15] Review comments --- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index f21cc5b74778..424a5397428b 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -347,13 +347,17 @@ export class dotNetExe { return projectFiles; } - private isWebSdkUsed(projectfile: string) { - var fileBuffer: Buffer = fs.readFileSync(projectfile); - var webConfigContent: string = fileBuffer.toString(); - - var projectSdkUsed: string = ltx.parse(webConfigContent).getAttr("sdk") || ltx.parse(webConfigContent).getAttr("Sdk") - - return projectSdkUsed != undefined && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web" + private isWebSdkUsed(projectfile: string): boolean { + try { + var fileBuffer: Buffer = fs.readFileSync(projectfile); + var webConfigContent: string = fileBuffer.toString(); + + var projectSdkUsed: string = ltx.parse(webConfigContent).getAttr("sdk") || ltx.parse(webConfigContent).getAttr("Sdk") + + return projectSdkUsed != undefined && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web" + } catch(error) { + tl.error(error) + } } private isPublishCommand(): boolean { From 18b34f0904b3a7215f283d2d3f1ee518489f8876 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Fri, 21 Jun 2019 13:24:01 +0530 Subject: [PATCH 06/15] Try-catch --- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index 424a5397428b..1ae81ac0eb53 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -356,7 +356,8 @@ export class dotNetExe { return projectSdkUsed != undefined && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web" } catch(error) { - tl.error(error) + tl.warning(error) + return false } } From f6fdbeaaa709a7e6a14b69c405f4ed788a4d4f14 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Fri, 21 Jun 2019 14:11:02 +0530 Subject: [PATCH 07/15] Iteratively find and check for file encodings --- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index 1ae81ac0eb53..3ed2009d7ed0 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -351,10 +351,19 @@ export class dotNetExe { try { var fileBuffer: Buffer = fs.readFileSync(projectfile); var webConfigContent: string = fileBuffer.toString(); - - var projectSdkUsed: string = ltx.parse(webConfigContent).getAttr("sdk") || ltx.parse(webConfigContent).getAttr("Sdk") - return projectSdkUsed != undefined && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web" + var fileEncodings = ['utf8', 'utf16le', 'ascii', 'base64', 'binary', 'hex'] + + for(var i = 0; i < fileEncodings.length; i++) { + tl.debug("Trying to decode with " + fileEncodings[i]) + webConfigContent = fileBuffer.toString(fileEncodings[i]) + try { + var projectSdkUsed: string = ltx.parse(webConfigContent).getAttr("sdk") || ltx.parse(webConfigContent).getAttr("Sdk") + if(projectSdkUsed != undefined && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web") return true + } catch (error) {} + } + + return false } catch(error) { tl.warning(error) return false From 230f4d8089018c77f3abdba744ae77cc67f5170b Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Fri, 21 Jun 2019 16:07:29 +0530 Subject: [PATCH 08/15] Review comments --- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index 3ed2009d7ed0..6fb6f73c84b6 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -350,7 +350,7 @@ export class dotNetExe { private isWebSdkUsed(projectfile: string): boolean { try { var fileBuffer: Buffer = fs.readFileSync(projectfile); - var webConfigContent: string = fileBuffer.toString(); + var webConfigContent: string; var fileEncodings = ['utf8', 'utf16le', 'ascii', 'base64', 'binary', 'hex'] @@ -359,7 +359,7 @@ export class dotNetExe { webConfigContent = fileBuffer.toString(fileEncodings[i]) try { var projectSdkUsed: string = ltx.parse(webConfigContent).getAttr("sdk") || ltx.parse(webConfigContent).getAttr("Sdk") - if(projectSdkUsed != undefined && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web") return true + return projectSdkUsed && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web" } catch (error) {} } From 44ab48334a1e2e36f1f45230ccb6b08545cd5e7a Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Fri, 21 Jun 2019 16:12:59 +0530 Subject: [PATCH 09/15] Supporting only utf encodings --- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index 6fb6f73c84b6..c3a10a6341c6 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -352,7 +352,7 @@ export class dotNetExe { var fileBuffer: Buffer = fs.readFileSync(projectfile); var webConfigContent: string; - var fileEncodings = ['utf8', 'utf16le', 'ascii', 'base64', 'binary', 'hex'] + var fileEncodings = ['utf8', 'utf16le'] for(var i = 0; i < fileEncodings.length; i++) { tl.debug("Trying to decode with " + fileEncodings[i]) From 98f05005b27fe00ccb1b842cee7e5df3562fabd7 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Mon, 24 Jun 2019 15:14:57 +0530 Subject: [PATCH 10/15] L0 --- Tasks/DotNetCoreCLIV2/Tests/L0.ts | 13 +++++++++++++ Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/Tasks/DotNetCoreCLIV2/Tests/L0.ts b/Tasks/DotNetCoreCLIV2/Tests/L0.ts index adc86a690a3d..4593b87c89f3 100644 --- a/Tasks/DotNetCoreCLIV2/Tests/L0.ts +++ b/Tasks/DotNetCoreCLIV2/Tests/L0.ts @@ -312,6 +312,19 @@ describe('DotNetCoreExe Suite', function () { done(); }); + + it('publish works with publishWebProjects option if .csproj have Microsoft.Net.Sdk.Web', (done: MochaDone) => { + process.env["__projects__"] = "havesdk*/*.csproj;"; + process.env["__publishWebProjects__"] = "true"; + let tp = path.join(__dirname, 'publishInputs.js') + let tr: ttm.MockTestRunner = new ttm.MockTestRunner(tp); + tr.run(); + + assert(tr.invokedToolCount == 1, 'should have invoked been invoked once'); + assert(tr.succeeded, 'task should have failed'); + done(); + }) + it('publish updates the output with the project name appended', (done: MochaDone) => { process.env["__projects__"] = "*customoutput/project.json"; process.env["__publishWebProjects__"] = "false"; diff --git a/Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts b/Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts index 2c5eab33babb..cceffb1abb0d 100644 --- a/Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts +++ b/Tasks/DotNetCoreCLIV2/Tests/publishInputs.ts @@ -88,6 +88,11 @@ let a: ma.TaskLibAnswers = { "code": 1, "stdout": "not published", "stderr": "" + }, + "dotnet publish havesdk/project.csproj": { + "code": 0, + "stdout": "published", + "stderr": "" } }, "findMatch": { @@ -98,6 +103,7 @@ let a: ma.TaskLibAnswers = { "*fail*/project.json": [], "*customoutput/project.json": ["web3/project.json", "lib2/project.json"], "dummy/project.json": ["dummy/project.json"], + "havesdk*/*.csproj": ["havesdk/project.csproj"], "" : [] } }; From ab684de95cacf3f8a09a596393e6decaa6237c93 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Mon, 24 Jun 2019 15:18:04 +0530 Subject: [PATCH 11/15] Adding semicolons --- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index c3a10a6341c6..6dee4074ac92 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -336,7 +336,7 @@ export class dotNetExe { }); if (!resolvedProjectFiles.length) { - var projectFilesUsingWebSdk = projectFiles.filter(this.isWebSdkUsed) + var projectFilesUsingWebSdk = projectFiles.filter(this.isWebSdkUsed); if(!projectFilesUsingWebSdk.length) { tl.error(tl.loc("noWebProjectFound")); } @@ -352,22 +352,20 @@ export class dotNetExe { var fileBuffer: Buffer = fs.readFileSync(projectfile); var webConfigContent: string; - var fileEncodings = ['utf8', 'utf16le'] + var fileEncodings = ['utf8', 'utf16le']; for(var i = 0; i < fileEncodings.length; i++) { - tl.debug("Trying to decode with " + fileEncodings[i]) - webConfigContent = fileBuffer.toString(fileEncodings[i]) + tl.debug("Trying to decode with " + fileEncodings[i]); + webConfigContent = fileBuffer.toString(fileEncodings[i]); try { - var projectSdkUsed: string = ltx.parse(webConfigContent).getAttr("sdk") || ltx.parse(webConfigContent).getAttr("Sdk") - return projectSdkUsed && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web" + var projectSdkUsed: string = ltx.parse(webConfigContent).getAttr("sdk") || ltx.parse(webConfigContent).getAttr("Sdk"); + return projectSdkUsed && projectSdkUsed.toLowerCase() == "microsoft.net.sdk.web"; } catch (error) {} } - - return false } catch(error) { - tl.warning(error) - return false + tl.warning(error); } + return false; } private isPublishCommand(): boolean { From 302f166df0bee0348c07f8f5616e0e116b5d6767 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Tue, 25 Jun 2019 13:33:07 +0530 Subject: [PATCH 12/15] Removing vbproj --- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index 6dee4074ac92..68984562cafc 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -322,7 +322,7 @@ export class dotNetExe { var projectPattern = this.projects; var searchWebProjects = this.isPublishCommand() && this.publishWebProjects; if (searchWebProjects) { - projectPattern = ["**/*.csproj", "**/*.vbproj", "**/*.fsproj"]; + projectPattern = ["**/*.csproj", "**/*.fsproj"]; } var projectFiles = utility.getProjectFiles(projectPattern); From 4fa6237a19df846c43331faa81afbecb6dc4f7a6 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Tue, 25 Jun 2019 14:12:12 +0530 Subject: [PATCH 13/15] Comments --- Tasks/DotNetCoreCLIV2/dotnetcore.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Tasks/DotNetCoreCLIV2/dotnetcore.ts b/Tasks/DotNetCoreCLIV2/dotnetcore.ts index 68984562cafc..ce3ab486bfd4 100644 --- a/Tasks/DotNetCoreCLIV2/dotnetcore.ts +++ b/Tasks/DotNetCoreCLIV2/dotnetcore.ts @@ -322,7 +322,7 @@ export class dotNetExe { var projectPattern = this.projects; var searchWebProjects = this.isPublishCommand() && this.publishWebProjects; if (searchWebProjects) { - projectPattern = ["**/*.csproj", "**/*.fsproj"]; + projectPattern = ["**/*.csproj", "**/*.vbproj", "**/*.fsproj"]; } var projectFiles = utility.getProjectFiles(projectPattern); @@ -348,6 +348,8 @@ export class dotNetExe { } private isWebSdkUsed(projectfile: string): boolean { + if (projectfile.endsWith('.vbproj')) return false + try { var fileBuffer: Buffer = fs.readFileSync(projectfile); var webConfigContent: string; From ce2175c1b98ae0fc8b6ceb58e4df2bc1e9925168 Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Tue, 25 Jun 2019 15:17:31 +0530 Subject: [PATCH 14/15] Updating error message --- Tasks/DotNetCoreCLIV2/task.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/DotNetCoreCLIV2/task.json b/Tasks/DotNetCoreCLIV2/task.json index 9463c75aac2a..aec42c8c940a 100644 --- a/Tasks/DotNetCoreCLIV2/task.json +++ b/Tasks/DotNetCoreCLIV2/task.json @@ -529,7 +529,7 @@ "dotnetCommandFailed": "Dotnet command failed with non-zero exit code on the following projects : %s", "noProjectFilesFound": "Project file(s) matching the specified pattern were not found.", "noPublishFolderFoundToZip": "A publish folder could not be found to zip for project file: %s.", - "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 csproj 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.", + "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.", "zipFailed": "Zip failed with error: %s", "Error_ApiKeyNotSupported": "DotNetCore currently does not support using an encrypted Api Key.", "Error_ExpectedConfigurationElement": "Invalid xml. Expected element named 'configuration'.", From 62570a9c4d3d177e4ca58557a25e4f37efa2e00e Mon Sep 17 00:00:00 2001 From: Nitin Issac Joy Date: Tue, 25 Jun 2019 15:22:54 +0530 Subject: [PATCH 15/15] Updating error message --- .../Strings/resources.resjson/en-US/resources.resjson | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tasks/DotNetCoreCLIV2/Strings/resources.resjson/en-US/resources.resjson b/Tasks/DotNetCoreCLIV2/Strings/resources.resjson/en-US/resources.resjson index 2b10b907d0b7..81eeaead68f2 100644 --- a/Tasks/DotNetCoreCLIV2/Strings/resources.resjson/en-US/resources.resjson +++ b/Tasks/DotNetCoreCLIV2/Strings/resources.resjson/en-US/resources.resjson @@ -103,7 +103,7 @@ "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 csproj 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.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'.",