microsoft / AL

Home of the Dynamics 365 Business Central AL Language extension for Visual Studio Code. Used to track issues regarding the latest version of the AL compiler and developer tools available in the Visual Studio Code Marketplace or as part of the AL Developer Preview builds for Dynamics 365 Business Central.
MIT License
744 stars 245 forks source link

System.IO.IOException: The process cannot access the file 'xxx.g.xlf' because it is being used by another process. #6239

Closed jwikman closed 2 years ago

jwikman commented 4 years ago

Describe the bug Now and then (not often at all) when compiling we get the error System.IO.IOException: The process cannot access the file '[path to my g.xlf file]' because it is being used by another process. When running locally you just try again and it works. But when this happens in a pipeline, it fails the pipeline causing som extra work for investigating the fail. Rerunning the pipeline always works...

I could implement a retry logic in our pipelines (or @freddydk could do this in Compile-AppInBcContainer ;-)) , but I rather see this being fixed in the compiler.

To Reproduce This is not happening very often, so there is no clean repro.

Below is the output in my pipeline, where you see the call to alc.exe that fails

2020-10-21T03:53:14.3475771Z Downloading symbols: Microsoft_Application_17.1.17892.0.app
2020-10-21T03:53:14.3519357Z Url : http://172.19.18.32:7049/BC/dev/packages?publisher=Microsoft&appName=Application&versionText=17.0.0.0&tenant=default
2020-10-21T03:53:15.7193890Z Adding dependency to System Application from Microsoft
2020-10-21T03:53:15.7224868Z Adding dependency to Base Application from Microsoft
2020-10-21T03:53:15.7252440Z Downloading symbols: Microsoft_System_17.0.17834.0.app
2020-10-21T03:53:15.7265494Z Url : http://172.19.18.32:7049/BC/dev/packages?publisher=Microsoft&appName=System&versionText=17.0.0.0&tenant=default
2020-10-21T03:53:16.1681563Z Downloading symbols: ThePublisher_ALibraryApp_17.0.9240.0.app
2020-10-21T03:53:16.1704586Z Url : http://172.19.18.32:7049/BC/dev/packages?publisher=ThePublisher&appName=ALibraryApp&versionText=17.0.9240.0&tenant=default
2020-10-21T03:53:16.6898202Z Downloading symbols: ThePublisher_AnotherLibraryApp_17.0.9241.0.app
2020-10-21T03:53:16.6920908Z Url : http://172.19.18.32:7049/BC/dev/packages?publisher=ThePublisher&appName=AnotherLibraryApp&versionText=17.0.9241.0&tenant=default
2020-10-21T03:53:17.1716255Z Downloading symbols: Microsoft_System Application_17.1.17892.0.app
2020-10-21T03:53:17.1738289Z Url : http://172.19.18.32:7049/BC/dev/packages?publisher=Microsoft&appName=System Application&versionText=17.1.0.0&tenant=default
2020-10-21T03:53:17.5993115Z Downloading symbols: Microsoft_Base Application_17.1.17892.0.app
2020-10-21T03:53:17.6018131Z Url : http://172.19.18.32:7049/BC/dev/packages?publisher=Microsoft&appName=Base Application&versionText=17.1.0.0&tenant=default
2020-10-21T03:53:18.3809640Z Compiling...
2020-10-21T03:53:18.3913528Z .\alc.exe /project:"C:\Agent\_work\115\s\MyAppSourceApp\App" /packagecachepath:"C:\Agent\_work\115\s\MyAppSourceApp\App\.alpackages" /out:"C:\Agent\_work\115\a\App\ThePublisher_MyAppSourceApp_17.0.11441.0.app" /analyzer:C:\build\vsix\extension\bin\Analyzers\Microsoft.Dynamics.Nav.CodeCop.dll /analyzer:C:\build\vsix\extension\bin\Analyzers\Microsoft.Dynamics.Nav.AppSourceCop.dll /analyzer:C:\build\vsix\extension\bin\Analyzers\Microsoft.Dynamics.Nav.UICop.dll /ruleset:C:\Agent\_work\115\s\MyAppSourceApp\App\.vscode\prod.ruleset.json /nowarn:AA0073,AA0205,AA0217,AA0228,AA0448,AL0604,AL0606 /assemblyprobingpaths:"C:\Program Files (x86)\Microsoft Dynamics NAV\170\RoleTailored Client","C:\Program Files\Microsoft Dynamics NAV\170\Service","C:\Program Files (x86)\Open XML SDK\V2.5\lib","c:\Windows\Microsoft.NET\Assembly","C:\Test Assemblies\Mock Assemblies"
2020-10-21T03:53:27.4254531Z Microsoft (R) AL Compiler version 6.1.5.24898
2020-10-21T03:53:27.4330720Z Copyright (C) Microsoft Corporation. All rights reserved
2020-10-21T03:53:27.4335261Z 
2020-10-21T03:53:27.4344556Z Compilation started for project 'MyAppSourceApp' containing '166' files at '5:53:19.358'.
2020-10-21T03:53:27.4347924Z 
-- 
a few lines with infos from rules removed
--
2020-10-21T03:53:27.4431656Z 
2020-10-21T03:53:27.4442641Z Compilation ended at '5:53:27.312'.
2020-10-21T03:53:27.4446316Z 
2020-10-21T03:53:27.4455952Z System.IO.IOException: The process cannot access the file 'C:\Agent\_work\115\s\MyAppSourceApp\App\Translations\MyAppSourceApp.g.xlf' because it is being used by another process.
2020-10-21T03:53:27.4465414Z    at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
2020-10-21T03:53:27.4477334Z    at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
2020-10-21T03:53:27.4489766Z    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
2020-10-21T03:53:27.4504179Z    at Microsoft.Dynamics.Nav.CodeAnalysis.FileSystem.OpenFile(String filePath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\Compilation\FileSystem.cs:line 38
2020-10-21T03:53:27.4513431Z    at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.GetLanguageFileStream(String extension) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 637
2020-10-21T03:53:27.4524608Z    at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.OutputLanguageFile(Compilation compilation, CompilerTextWriter consoleOutput, ErrorLogger errorLogger, DiagnosticBag diagnosticBag) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 601
2020-10-21T03:53:27.4532990Z    at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.GenerateLanguageFile(Compilation compilation, CompilerTextWriter consoleOutput, ErrorLogger errorLogger) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 557
2020-10-21T03:53:27.4543065Z    at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.RunCoreImpl(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, Compilation compilation, AnalyzerDriver analyzerDriver, IEnumerable`1 analyzerExceptionDiagnostics, IEnumerable`1 additionalTextFiles, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 518
2020-10-21T03:53:27.4554525Z    at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.RunCore(CompilerTextWriter consoleOutput, ErrorLogger errorLogger, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 472
2020-10-21T03:53:27.4564503Z    at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.CommonCompiler.Run(CompilerTextWriter consoleOutput, CancellationToken cancellationToken) in D:\a\1\s\source\Prod\Microsoft.Dynamics.Nav.CodeAnalysis\CommandLine\CommonCompiler.cs:line 330
2020-10-21T03:53:27.4576059Z    at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.Alc.<>c__DisplayClass1_0.<Run>b__0(CompilerTextWriter textWriterOut, CompilerTextWriter _) in D:\a\1\s\source\Prod\alc\Alc.cs:line 37
2020-10-21T03:53:27.4590319Z    at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.ConsoleUtil.RunWithOutput[T](Boolean useUtf8Encoding, Func`3 func) in D:\a\1\s\source\Prod\alc\ConsoleUtil.cs:line 25
2020-10-21T03:53:27.4601805Z    at Microsoft.Dynamics.Nav.CodeAnalysis.CommandLine.Alc.Run(String clientDirectory, String baseDirectory, String[] args, IAnalyzerAssemblyLoader analyzerLoader) in D:\a\1\s\source\Prod\alc\Alc.cs:line 37
2020-10-21T03:53:27.8099062Z ##[error]Compile-AppInBcContainer : App generation failed
At C:\Agent_AS011_scheduled_02\_work\115\s\NAB DevOps Tools\PowerShell\Compile-App.ps1:52 char:24
+ ... pFilePath = Compile-AppInBcContainer -containerName $containerName -c ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Compile-AppInBcContainer
2020-10-21T03:53:27.8121660Z ##[error]PowerShell exited with code '1'.
2020-10-21T03:53:27.8776037Z ##[section]Finishing: Compile App

Expected behavior The compilation should not fail with this error. If the file is locked (by the alc process itself, or could it be a AV scanning the file?) the compiler could wait for the file to be released...

Screenshots N/A

5. Versions: Microsoft (R) AL Compiler version 6.1.5.24898

github-actions[bot] commented 2 years ago

Hi,

Many thanks for raising this issue. Unfortunately we have not been able to get to this issue as soon as we'd have liked. Since it has been a long time since this issue was last updated, it is possible that this has been fixed by a newer release of Business Central and the AL extension for Visual Studio Code. We have thus decided to close it.

If the issue still affects you on the latest insider build of Business Central, please help us and open a new issue for us with the latest steps to reproduce the issue, and link back to this closed issue to track any comments or discussions.

Thanks,
Thaddeus

jwikman commented 2 years ago

I have not seen this error in quite some time, so I believe that it is actually resolved. 👍