Skip to content

Commit

Permalink
Try faster compression when publishing from vsix by just extracting t…
Browse files Browse the repository at this point in the history
…he manifest files
  • Loading branch information
jessehouwing committed Dec 29, 2022
1 parent e7ec6df commit e0fd393
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 39 deletions.
88 changes: 64 additions & 24 deletions BuildTasks/PublishExtension/v4/vsixeditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,52 +111,92 @@ export class VSIXEditor {
tl.debug("Editing started");
}

private extractArchive(input: string, output: string): void {
if (tl.osType() === "Windows_NT") {
private extractArchive(vsix: string, tmpPath: string): void {
const cwd = tl.cwd();

if (tl.getPlatform() === tl.Platform.Windows) {
const sevenZip = require("7zip-bin-win");
const zip = new tr.ToolRunner(sevenZip.path7za);
zip.arg("x");
zip.arg(input); // file to extract
zip.arg(`-o${output}`); // redirect output to dir
zip.arg("-y"); // assume yes on all queries
zip.arg("-spd"); // disable wildcards
zip.arg("-aoa"); // overwrite all

if (tl.getVariable("PREVIEW_FAST_UPDATE") === "true")
{
zip.arg("x");
zip.arg(vsix); // file to extract
zip.arg(`-o${tmpPath}`); // redirect output to dir
zip.arg("task.json");
zip.arg("task.loc.json");
zip.arg("extension.vsixmanifest");
zip.arg("extension.vsomanifest");
zip.arg("-y"); // assume yes on all queries
zip.arg("-r"); // recurse
zip.arg("-bd"); // disable progress indicator
zip.arg("-aoa"); // overwrite all
zip.arg("-spd"); // disable wildcards
}
else
{
zip.arg("x");
zip.arg(vsix); // file to extract
zip.arg(`-o${tmpPath}`); // redirect output to dir
zip.arg("-y"); // assume yes on all queries
zip.arg("-spd"); // disable wildcards
zip.arg("-aoa"); // overwrite all
}
zip.execSync();
}
else {
const zip = new tr.ToolRunner(tl.which("unzip", true));
zip.arg("-o"); // overwrite all
zip.arg("-d"); // redirect output to
zip.arg(output); // output directory
zip.arg(input); // file to extract
zip.arg(tmpPath); // output directory
zip.arg(vsix); // file to extract
zip.execSync();
}
tl.cd(cwd);
}

private createArchive(input: string, output: string): void {
if (tl.osType() === "Windows_NT") {
private createArchive(originalVsix: string, tmpPath: string, targetVsix: string): void {
const cwd = tl.cwd();

if (tl.getPlatform() === tl.Platform.Windows) {
const sevenZip = require("7zip-bin-win");
const zip = new tr.ToolRunner(sevenZip.path7za);
zip.arg("a");
zip.arg(output); // redirect output to file
zip.arg(path.join(input, "\\*"));
zip.arg("-r"); // recursive
zip.arg("-y"); // assume yes on all queries
zip.arg("-tzip"); // zip format
zip.arg("-mx9"); // max compression level

if (tl.getVariable("PREVIEW_FAST_UPDATE") === "true")
{
if (originalVsix !== targetVsix) { tl.cp(originalVsix, targetVsix, "-f"); }
zip.arg("u");
zip.arg(targetVsix); // redirect output to file
zip.arg(path.join(tmpPath, "\\*"));
zip.arg("-r"); // recursive
zip.arg("-y"); // assume yes on all queries
zip.arg("-tzip"); // zip format
zip.arg("-mx9"); // max compression level
zip.arg("-bd"); // disable progress indicator

}
else
{
zip.arg("a");
zip.arg(targetVsix); // redirect output to file
zip.arg(path.join(tmpPath, "\\*"));
zip.arg("-r"); // recursive
zip.arg("-y"); // assume yes on all queries
zip.arg("-tzip"); // zip format
zip.arg("-mx9"); // max compression level
}
zip.execSync();
}
else {
const zip = new tr.ToolRunner(tl.which("zip", true));
const cwd = tl.cwd();
tl.cd(input);
zip.arg(path.join(cwd, output)); // redirect output to file
tl.cd(tmpPath);
zip.arg(path.join(cwd, targetVsix)); // redirect output to file
zip.arg(".");
zip.arg("-r"); // recursive
zip.arg("-9"); // max compression level
zip.execSync();
tl.cd(cwd);
}
tl.cd(cwd);
}

public async endEdit(): Promise<string> {
Expand Down Expand Up @@ -193,7 +233,7 @@ export class VSIXEditor {
})
.then((manifestData: ManifestData) => {
tl.debug(`Creating final archive file at ${this.outputPath}`);
this.createArchive(manifestData.dirPath, manifestData.outputFileName);
this.createArchive(this.inputFile, manifestData.dirPath, manifestData.outputFileName);
tl.debug("Final archive file created");
return Promise.resolve(manifestData.outputFileName);
}).catch(err => { return Promise.reject(err); });
Expand Down
29 changes: 14 additions & 15 deletions test-publishing.cmd
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
SET AGENT_WORKFOLDER=c:\temp
SET SYSTEM_DEFAULTWORKINGDIRECTORY=C:\Users\jesse\source\repos\vsts-ping-task-demo
set INPUT_CWD=C:\Users\jesse\source\repos\vsts-ping-task-demo
set INPUT_ROOTFOLDER=C:\Users\jesse\source\repos\vsts-ping-task-demo
SET AGENT_WORKFOLDER=%temp%
SET SYSTEM_DEFAULTWORKINGDIRECTORY=C:\Users\JesseHouwing\source\azure-pipelines-variable-tasks\
set INPUT_CWD=C:\Users\JesseHouwing\source\azure-pipelines-variable-tasks\
set INPUT_ROOTFOLDER=C:\Users\JesseHouwing\source\azure-pipelines-variable-tasks\
set INPUT_VSIXFILE=C:\Users\JesseHouwing\source\azure-pipelines-variable-tasks\jessehouwing.jessehouwing-vsts-variable-tasks-3.0.0.vsix
SET INPUT_CONNECTTO=VsTeam
SET INPUT_FILETYPE=vsix
SET INPUT_EXTENSIONVISIBILITY=default
SET INPUT_EXTENSIONVERSION=1.2.3
SET INPUT_EXTENSIONVERSION=3.26.27
SET INPUT_UPDATETASKSVERSION=true
SET INPUT_UPDATETASKSVERSIONTYPE=major
SET INPUT_UPDATETASKSVERSIONTYPE=minor
SET INPUT_CONNECTEDSERVICENAME=A
SET ENDPOINT_URL_A=https://marketplace.visualstudio.com
SET ENDPOINT_AUTH_A={ "parameters": { "apitoken": "token", "username": "user", "password": "password" }, "Scheme": "basic" }
SET INPUT_VSIXFILE=C:\Users\jesse\source\repos\vsts-ping-task-demo\jessehouwing.jessehouwing-vsts-ping-task-2.1.2.vsix

set NODE_ENV=production
set NO_UPDATE_NOTIFIER=true

cmd /c "npm run build:tasks"
fnm use v16

pushd BuildTasks\TfxInstaller\TfxInstaller
node TfxInstaller.js
popd
cmd /c "npm run build:tasks"

set __TFXPATH=c:\temp\agent\tools\tfx\0.7.11\x64
set __TFXPATH=C:\Users\JesseHouwing\AppData\Local\fnm_multishells\5548_1672346643184

pushd BuildTasks\PublishExtension\v4\PublishExtension\v4
SET PREVIEW_FAST_UPDATE=false
node PublishExtension.js

pushd BuildTasks\PublishExtension\PublishExtension
c:\TfsData\jessehouwing\externals.2.111.1\node\bin\node.exe PublishExtension.js
c:\TfsData\jessehouwing\externals.2.136.1\node\bin\node.exe PublishExtension.js
SET PREVIEW_FAST_UPDATE=true
node PublishExtension.js
popd

0 comments on commit e0fd393

Please sign in to comment.