Skip to content

Commit 5f92c18

Browse files
authored
Ensure func_env is in .funcignore (#637)
1 parent 4ccfc67 commit 5f92c18

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/commands/createNewProject/PythonProjectCreator.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export class PythonProjectCreator extends ScriptProjectCreatorBase {
8080
this.deploySubpath = `${path.basename(this.functionAppPath)}.zip`;
8181
// func host task requires this
8282
await makeVenvDebuggable(this.functionAppPath);
83+
// func pack task may fail with "The process cannot access the file because it is being used by another process." unless venv is in '.funcignore' file
84+
await this.ensureVenvInFuncIgnore();
8385
const funcPackCommand: string = 'func pack';
8486
const funcHostStartCommand: string = 'func host start';
8587
const funcExtensionsCommand: string = 'func extensions install';
@@ -173,6 +175,23 @@ export class PythonProjectCreator extends ScriptProjectCreatorBase {
173175
await fsUtil.writeFormattedJson(localSettingsPath, localSettings);
174176
}
175177
}
178+
179+
private async ensureVenvInFuncIgnore(): Promise<void> {
180+
const funcIgnorePath: string = path.join(this.functionAppPath, '.funcignore');
181+
let funcIgnoreContents: string | undefined;
182+
if (await fse.pathExists(funcIgnorePath)) {
183+
funcIgnoreContents = (await fse.readFile(funcIgnorePath)).toString();
184+
if (funcIgnoreContents && !funcIgnoreContents.includes(funcEnvName)) {
185+
funcIgnoreContents = funcIgnoreContents.concat(`${os.EOL}${funcEnvName}`);
186+
}
187+
}
188+
189+
if (!funcIgnoreContents) {
190+
funcIgnoreContents = funcEnvName;
191+
}
192+
193+
await fse.writeFile(funcIgnorePath, funcIgnoreContents);
194+
}
176195
}
177196

178197
/**

0 commit comments

Comments
 (0)