diff --git a/Tasks/AzureRmWebAppDeployment/Tests/L0.ts b/Tasks/AzureRmWebAppDeployment/Tests/L0.ts index 145704208a5e..47a0bda87637 100644 --- a/Tasks/AzureRmWebAppDeployment/Tests/L0.ts +++ b/Tasks/AzureRmWebAppDeployment/Tests/L0.ts @@ -458,4 +458,13 @@ describe('AzureRmWebAppDeployment Suite', function() { done(); }); + it('Validate webdeployment-common.utility.copyDirectory()', (done:MochaDone) => { + let tp = path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L0CopyDirectory.js'); + let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp); + tr.run(); + + assert(tr.stdout.search('## Copy Files Successful ##') >=0, 'should have copied the files'); + assert(tr.stdout.search('## mkdir Successful ##') >= 0, 'should have created dir including dest folder'); + done(); + }); }); diff --git a/Tasks/AzureRmWebAppDeployment/task.json b/Tasks/AzureRmWebAppDeployment/task.json index 19d5617968b4..9d101b3a916c 100644 --- a/Tasks/AzureRmWebAppDeployment/task.json +++ b/Tasks/AzureRmWebAppDeployment/task.json @@ -16,7 +16,7 @@ "version": { "Major": 3, "Minor": 0, - "Patch": 7 + "Patch": 8 }, "preview": "true", "releaseNotes": "What's new in Version 3.0:
  Supports File Transformations (XDT)
  Supports Variable Substitutions(XML, JSON)
Click [here](https://aka.ms/azurermwebdeployreadme) for more Information.", diff --git a/Tasks/AzureRmWebAppDeployment/task.loc.json b/Tasks/AzureRmWebAppDeployment/task.loc.json index fb16de8f8fa3..1492cdc2aacf 100644 --- a/Tasks/AzureRmWebAppDeployment/task.loc.json +++ b/Tasks/AzureRmWebAppDeployment/task.loc.json @@ -16,7 +16,7 @@ "version": { "Major": 3, "Minor": 0, - "Patch": 7 + "Patch": 8 }, "preview": "true", "releaseNotes": "What's new in Version 3.0:
  Supports File Transformations (XDT)
  Supports Variable Substitutions(XML, JSON)
Click [here](https://aka.ms/azurermwebdeployreadme) for more Information.", diff --git a/Tasks/Common/webdeployment-common/Tests/L0CopyDirectory.ts b/Tasks/Common/webdeployment-common/Tests/L0CopyDirectory.ts new file mode 100644 index 000000000000..82ed38b23299 --- /dev/null +++ b/Tasks/Common/webdeployment-common/Tests/L0CopyDirectory.ts @@ -0,0 +1,59 @@ +var mockery = require('mockery'); +mockery.enable({ + useCleanCache: true, + warnOnReplace: false, + warnOnUnregistered: false +}); + +var fileList = ["C:/vinca/path", "C:/vinca/path/myfile.txt", + "C:/vinca/path/New Folder", "C:/vinca/path/New Folder/Another New Folder", + "C:/vinca/New Folder/anotherfile.py", "C:/vinca/New Folder/Another New Folder/mynewfile.txt"]; + +var mkdirPCount = 0; +var cpfilesCount = 0; +mockery.registerMock('vsts-task-lib/task', { + exist: function (path) { + console.log("exist : " + path); + }, + find: function (path) { + console.log("find : " + path); + return fileList; + }, + mkdirP: function (path) { + mkdirPCount += 1; + console.log("mkdirp : " + path); + }, + cp: function (source, dest, options, continueOnError) { + if(fileList.indexOf(source)!= -1) { + cpfilesCount += 1; + console.log('cp ' + source + ' to ' + dest); + } + }, + stats: function (path) { + return { + isDirectory: function() { + if(path.endsWith('.py') || path.endsWith('.txt')) { + return false; + } + return true; + } + }; + }, + debug: function(message) { + console.log(message); + } +}); +var utility = require('webdeployment-common/utility.js'); +utility.copyDirectory('C:/vinca/path', 'C:/vinca/path/destFolder'); + +if(cpfilesCount === 3) { + console.log('## Copy Files Successful ##'); +} +/** + * 7 dir to be created including dest dir + * Hash is not created to check already created dir, for testing purpose + */ +if(mkdirPCount === 7) { + console.log('## mkdir Successful ##'); +} + diff --git a/Tasks/Common/webdeployment-common/deployusingmsdeploy.ts b/Tasks/Common/webdeployment-common/deployusingmsdeploy.ts index c3ba4f252382..080cca7c3c96 100644 --- a/Tasks/Common/webdeployment-common/deployusingmsdeploy.ts +++ b/Tasks/Common/webdeployment-common/deployusingmsdeploy.ts @@ -34,7 +34,7 @@ export async function DeployUsingMSDeploy(webDeployPkg, webAppName, publishingPr setParametersFileName = setParametersFile.slice(setParametersFile.lastIndexOf('\\') + 1, setParametersFile.length); } var isParamFilePresentInPackage = isFolderBasedDeployment ? false : await utility.isMSDeployPackage(webDeployPkg); - var msDeployPath = await msDeployUtility.getMSDeployFullPath(); + var msDeployCmdArgs = msDeployUtility.getMSDeployCmdArgs(webDeployPkg, webAppName, publishingProfile, removeAdditionalFilesFlag, excludeFilesFromAppDataFlag, takeAppOfflineFlag, virtualApplication, setParametersFileName, additionalArguments, isParamFilePresentInPackage, isFolderBasedDeployment, useWebDeploy); diff --git a/Tasks/Common/webdeployment-common/fileTransformationsUtility.ts b/Tasks/Common/webdeployment-common/fileTransformationsUtility.ts index 2c500c2f472c..10f972ac2099 100644 --- a/Tasks/Common/webdeployment-common/fileTransformationsUtility.ts +++ b/Tasks/Common/webdeployment-common/fileTransformationsUtility.ts @@ -13,14 +13,12 @@ export async function fileTransformations(isFolderBasedDeployment: boolean, JSON var folderPath = utility.generateTemporaryFolderOrZipPath(tl.getVariable('System.DefaultWorkingDirectory'), true); if(isFolderBasedDeployment) { - tl.debug('Copying Folder: ' + webDeployPkg + ' to temporary location: ' + folderPath); - tl.cp(path.join(webDeployPkg, '/*'), folderPath, '-rf', false); - tl.debug('Copied Folder: ' + webDeployPkg + ' to temporary location: ' + folderPath + ' successfully.'); + tl.debug('Copying Web Packge: ' + webDeployPkg + ' to temporary location: ' + folderPath); + utility.copyDirectory(webDeployPkg, folderPath); + tl.debug('Copied Web Package: ' + webDeployPkg + ' to temporary location: ' + folderPath + ' successfully.'); } else { - tl.debug('Extracting Web Deploy Package: ' + webDeployPkg + ' to temporary location: ' + folderPath); await zipUtility.unzip(webDeployPkg, folderPath); - tl.debug('Extracted Web Deploy Package: ' + webDeployPkg + ' to temporary location: ' + folderPath + ' successfully.'); } if(xmlTransformation) { diff --git a/Tasks/Common/webdeployment-common/msdeployutility.ts b/Tasks/Common/webdeployment-common/msdeployutility.ts index 3f4ff00812c4..05e434d0961e 100644 --- a/Tasks/Common/webdeployment-common/msdeployutility.ts +++ b/Tasks/Common/webdeployment-common/msdeployutility.ts @@ -106,7 +106,7 @@ export async function getMSDeployFullPath() { return msDeployFullPath; } catch(error) { - tl.warning(error); + tl.debug(error); return path.join(__dirname, "..", "..", "MSDeploy3.6", "msdeploy.exe"); } } diff --git a/Tasks/Common/webdeployment-common/utility.ts b/Tasks/Common/webdeployment-common/utility.ts index 1a280bdc14c2..799a8e2f29c9 100644 --- a/Tasks/Common/webdeployment-common/utility.ts +++ b/Tasks/Common/webdeployment-common/utility.ts @@ -153,4 +153,25 @@ export async function isMSDeployPackage(webAppPackage: string ) { } tl.debug("Is the package an msdeploy package : " + isParamFilePresent); return isParamFilePresent; +} + +export function copyDirectory(sourceDirectory: string, destDirectory: string) { + if(!tl.exist(destDirectory)) { + tl.mkdirP(destDirectory); + } + var listSrcDirectory = tl.find(sourceDirectory); + for(var srcDirPath of listSrcDirectory) { + var relativePath = srcDirPath.substring(sourceDirectory.length); + var destinationPath = path.join(destDirectory, relativePath); + if(tl.stats(srcDirPath).isDirectory()) { + tl.mkdirP(destinationPath); + } + else { + if(!tl.exist(path.dirname(destinationPath))) { + tl.mkdirP(path.dirname(destinationPath)); + } + tl.debug('copy file from: ' + srcDirPath + ' to: ' + destinationPath); + tl.cp(srcDirPath, destinationPath, '-f', false); + } + } } \ No newline at end of file diff --git a/Tasks/Common/webdeployment-common/ziputility.ts b/Tasks/Common/webdeployment-common/ziputility.ts index 4c2722e80437..98e10a29c9d3 100644 --- a/Tasks/Common/webdeployment-common/ziputility.ts +++ b/Tasks/Common/webdeployment-common/ziputility.ts @@ -17,6 +17,7 @@ export async function unzip(zipLocation, unzipLocation) { defer.reject(error); }); unzipper.on('extract', function (log) { + tl.debug('extracted ' + zipLocation + ' to ' + unzipLocation + ' Successfully'); defer.resolve(unzipLocation); }); unzipper.extract({ diff --git a/Tasks/IISWebAppDeploymentOnMachineGroup/Tests/L0.ts b/Tasks/IISWebAppDeploymentOnMachineGroup/Tests/L0.ts index 63887f04b17b..ded7c2fbbf5d 100644 --- a/Tasks/IISWebAppDeploymentOnMachineGroup/Tests/L0.ts +++ b/Tasks/IISWebAppDeploymentOnMachineGroup/Tests/L0.ts @@ -210,4 +210,13 @@ describe('IISWebsiteDeploymentOnMachineGroup test suite', function() { done(); }); + it('Validate webdeployment-common.utility.copyDirectory()', (done:MochaDone) => { + let tp = path.join(__dirname, "..", "node_modules", "webdeployment-common", "Tests", 'L0CopyDirectory.js'); + let tr : ttm.MockTestRunner = new ttm.MockTestRunner(tp); + tr.run(); + + assert(tr.stdout.search('## Copy Files Successful ##') >=0, 'should have copied the files'); + assert(tr.stdout.search('## mkdir Successful ##') >= 0, 'should have created dir including dest folder'); + done(); + }); }); diff --git a/Tasks/IISWebAppDeploymentOnMachineGroup/task.json b/Tasks/IISWebAppDeploymentOnMachineGroup/task.json index 4cfb60a66b14..594b18198f1e 100644 --- a/Tasks/IISWebAppDeploymentOnMachineGroup/task.json +++ b/Tasks/IISWebAppDeploymentOnMachineGroup/task.json @@ -15,7 +15,7 @@ "version": { "Major": 0, "Minor": 0, - "Patch": 9 + "Patch": 10 }, "demands": [], "minimumAgentVersion": "2.104.1", diff --git a/Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json b/Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json index 9bdac9f6c369..916972c8dedc 100644 --- a/Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json +++ b/Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json @@ -15,7 +15,7 @@ "version": { "Major": 0, "Minor": 0, - "Patch": 9 + "Patch": 10 }, "demands": [], "minimumAgentVersion": "2.104.1",