I'm working with a Genexus KB 18 Upgrade5, generating for .NET. It's a small KB (less than 1000 objects), and it uses GAM.
When I execute a 'build all', intermittently but very frequently, I encounter the following error:
Success: Default (.NET) Generation
Compressing static files...Success
========== DeveloperMenu Compilation for Default (.NET) started ==========
dotnet build -nologo -c Debug /v:q /m /p:Configuration=Debug /p:GxExternalReference=GeneXus.Security.API.Common.dll "D:\KBs\GX18\MT18_v6\Pro\build\LastBuild.sln"
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: The "ResolveAssemblyReference" task failed unexpectedly. [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: System.IO.IOException: The process cannot access the file 'D:\KBs\GX18\MT18_v6\Pro\web\bin\Microsoft.Identity.Client.dll' because it is being used by another process. [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at System.IO.File.OpenRead(String path) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Shared.AssemblyNameExtension.GetAssemblyNameEx(String path) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.ResolveAssemblyReference.<>c.<Execute>b__255_3(String p) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.SystemState.GetAssemblyName(String path) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.Resolver.FileMatchesAssemblyName(AssemblyNameExtension assemblyName, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, Boolean allowMismatchBetweenFusionNameAndFileName, String pathToCandidateAssembly, ResolutionSearchLocation searchLocation) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.Resolver.ResolveAsFile(String fullPath, AssemblyNameExtension assemblyName, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, Boolean allowMismatchBetweenFusionNameAndFileName, List`1 assembliesConsideredAndRejected) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.Resolver.ResolveFromDirectory(AssemblyNameExtension assemblyName, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, String[] executableExtensions, String directory, List`1 assembliesConsideredAndRejected) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.DirectoryResolver.Resolve(AssemblyNameExtension assemblyName, String sdkName, String rawFileNameCandidate, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, String[] executableExtensions, String hintPath, String assemblyFolderKey, List`1 assembliesConsideredAndRejected, String& foundPath, Boolean& userRequestedSpecificFile) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.AssemblyResolution.ResolveReference(IEnumerable`1 jaggedResolvers, AssemblyNameExtension assemblyName, String sdkName, String rawFileNameCandidate, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, String[] executableExtensions, String hintPath, String assemblyFolderKey, List`1 assembliesConsideredAndRejected, String& resolvedSearchPath, Boolean& userRequestedSpecificFile) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.ReferenceTable.ResolveReference(AssemblyNameExtension assemblyName, String rawFileNameCandidate, Reference reference) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.ReferenceTable.ResolveAssemblyFilenames() [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure() [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.ReferenceTable.ComputeClosure(IEnumerable`1 remappedAssembliesValue, ITaskItem[] referenceAssemblyFiles, ITaskItem[] referenceAssemblyNames, List`1 exceptions) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute(FileExists fileExists, DirectoryExists directoryExists, GetDirectories getDirectories, GetAssemblyName getAssemblyName, GetAssemblyMetadata getAssemblyMetadata, GetLastWriteTime getLastWriteTime, GetAssemblyRuntimeVersion getRuntimeVersion, GetAssemblyPathInGac getAssemblyPathInGac, IsWinMDFile isWinMDFile, ReadMachineTypeFromPEHeader readMachineTypeFromPEHeader) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute() [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
C:\Program Files\dotnet\sdk\6.0.308\Microsoft.Common.CurrentVersion.targets(2302,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [D:\KBs\GX18\MT18_v6\Pro\build\global.usuario.aexportreportwwusuario\global.usuario.aexportreportwwusuario.csproj]
Build FAILED.
The issues seem to arise with Microsoft.Identity.Client.dll and also with BouncyCastle.Crypto.dll.
Repeating the 'build all' operation sometimes resolves the error temporarily.
It feels like there's some concurrency issue with multiple dotnet tasks being run by Genexus. I'm struggling to find a way to work efficiently without these interruptions. Does anyone have insights on how to address this issue?
You could try changing parallel compilation to serial using parameter /m:1 More information: Concurrent Access Issue during .NET Build in KB with GeneXus 18 Upgrade 5