Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recursive Copy Fix & MSdeploy Changes #3618

Merged
merged 9 commits into from
Feb 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Tasks/AzureRmWebAppDeployment/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,13 @@ describe('AzureRmWebAppDeployment Suite', function() {
done();
});

it('Validate webdeployment-common.utility.copyDirectory()', (done:MochaDone) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add the same test in IISWebAppDeploymentOnMachineGroup task as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added L0 Test for IIS App Deploy

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();
});
});
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeployment/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 3,
"Minor": 0,
"Patch": 7
"Patch": 8
},
"preview": "true",
"releaseNotes": "What's new in Version 3.0: <br/>&nbsp;&nbsp;Supports File Transformations (XDT) <br/>&nbsp;&nbsp;Supports Variable Substitutions(XML, JSON) <br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more Information.",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeployment/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"version": {
"Major": 3,
"Minor": 0,
"Patch": 7
"Patch": 8
},
"preview": "true",
"releaseNotes": "What's new in Version 3.0: <br/>&nbsp;&nbsp;Supports File Transformations (XDT) <br/>&nbsp;&nbsp;Supports Variable Substitutions(XML, JSON) <br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more Information.",
Expand Down
59 changes: 59 additions & 0 deletions Tasks/Common/webdeployment-common/Tests/L0CopyDirectory.ts
Original file line number Diff line number Diff line change
@@ -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 ##');
}

2 changes: 1 addition & 1 deletion Tasks/Common/webdeployment-common/deployusingmsdeploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Tasks/Common/webdeployment-common/msdeployutility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down
21 changes: 21 additions & 0 deletions Tasks/Common/webdeployment-common/utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, can you add L0 for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L0 Test added.

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);
}
}
}
1 change: 1 addition & 0 deletions Tasks/Common/webdeployment-common/ziputility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
9 changes: 9 additions & 0 deletions Tasks/IISWebAppDeploymentOnMachineGroup/Tests/L0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
2 changes: 1 addition & 1 deletion Tasks/IISWebAppDeploymentOnMachineGroup/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 9
"Patch": 10
},
"demands": [],
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 9
"Patch": 10
},
"demands": [],
"minimumAgentVersion": "2.104.1",
Expand Down