One of the teams I work with uses this release task in their pipelines.
However, they get the error below (path to temp file amended):
2022-12-02T12:06:37.1806973Z ##[error]System.IO.IOException: The process cannot access the file '\\server\share\folder\Web.config.tmp' because it is being used by another process.
2022-12-02T12:06:37.1806973Z at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
2022-12-02T12:06:37.1806973Z at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
2022-12-02T12:06:37.1806973Z at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
2022-12-02T12:06:37.1806973Z at Microsoft.PowerShell.Commands.FileSystemProvider.ClearContent(String path)
This issue began shortly after the solution was migrated to a VM hosted on Azure, running Windows Defender.
One of the teams I work with uses this release task in their pipelines. However, they get the error below (path to temp file amended):
This issue began shortly after the solution was migrated to a VM hosted on Azure, running Windows Defender.
I believe the issue is caused by the AV process getting a lock on the newly created file, whilst
tokenization.ps1
is still trying to use it. Specifically https://github.com/TotalALM/VSTS-Tasks/blob/master/Tasks/Tokenization/task/tokenization.ps1#L38 creates the temp file by copying an existing file; but then releases the lock it holds on this newly created file. Once the lock is released, the AV sees the new file and locks it whilst it scans it. Later the script tries to write back to the file: https://github.com/TotalALM/VSTS-Tasks/blob/master/Tasks/Tokenization/task/tokenization.ps1#L61 At this point, if the AV has taken and not yet released its lock, the script will produce the above error.