title: dotnet core compile time error - System.Net.Sockets.SocketException (98): Address already in use
body: <p>Occasionally, while running build on build machine, we are getting multiple errors when trying to run 'dotnet test' command. After all, build succeeds but error is unexpected and might be confusing:</p>
  
  <pre><code>/usr/bin/dotnet test /home/vsts_agent3/VSTS-Desktop-agents/_work/15/s/Name.Tests.csproj --logger trx --results-directory /home/vsts_agent3/VSTS-Desktop-agents/_work/_temp --configuration Prod 
  MSBUILD : error MSB1025: An internal failure occurred while running MSBuild.
  System.Net.Sockets.SocketException (98): Address already in use
     at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
     at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
     at System.Net.Sockets.Socket.Bind(EndPoint localEP)
     at System.IO.Pipes.NamedPipeServerStream.SharedServer..ctor(String path, Int32 maxCount)
     at System.IO.Pipes.NamedPipeServerStream.SharedServer.Get(String path, Int32 maxCount)
     at System.IO.Pipes.NamedPipeServerStream.Create(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, HandleInheritability inheritability)
     at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize, HandleInheritability inheritability)
     at System.IO.Pipes.NamedPipeServerStream..ctor(String pipeName, PipeDirection direction, Int32 maxNumberOfServerInstances, PipeTransmissionMode transmissionMode, PipeOptions options, Int32 inBufferSize, Int32 outBufferSize)
     at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.InternalConstruct(String pipeName)
     at Microsoft.Build.Execution.OutOfProcNode.Run(Boolean enableReuse, Exception&amp; shutdownException)
     at Microsoft.Build.CommandLine.MSBuildApp.StartLocalNode(CommandLineSwitches commandLineSwitches)
     at Microsoft.Build.CommandLine.MSBuildApp.ProcessCommandLineSwitches(CommandLineSwitches switchesFromAutoResponseFile, CommandLineSwitches switchesNotFromAutoResponseFile, String&amp; projectFile, String[]&amp; targets, String&amp; toolsVersion, Dictionary`2&amp; globalProperties, ILogger[]&amp; loggers, LoggerVerbosity&amp; verbosity, List`1&amp; distributedLoggerRecords, Int32&amp; cpuCount, Boolean&amp; enableNodeReuse, TextWriter&amp; preprocessWriter, Boolean&amp; detailedSummary, ISet`1&amp; warningsAsErrors, ISet`1&amp; warningsAsMessages, Boolean&amp; enableRestore, ProfilerLogger&amp; profilerLogger, Boolean&amp; enableProfiler, Dictionary`2&amp; restoreProperties, Boolean recursing)
     at Microsoft.Build.CommandLine.MSBuildApp.Execute(String[] commandLine)
  </code></pre>
  
  <p>Error can be repeated few times, but than finally build succeeds and tests are executed:</p>
  
  <pre><code>Build started, please wait...
  Build completed.
  Test run for /home/vsts_agent3/VSTS-Desktop-agents/_work/15/s/Project.Web.Tests/bin/Prod/netcoreapp2.1/Name.Tests.dll(.NETCoreApp,Version=v2.1)
  Microsoft (R) Test Execution Command Line Tool Version 15.8.0
  Copyright (c) Microsoft Corporation.  All rights reserved.
  
  Starting test execution, please wait...
  </code></pre>
  
  <p>It looks like MSBuildApp start some server inside to compile our sources. It would be great to understand why to make sure we have a safe CI/CD pipeline.</p>
  
  <p>We are running build on Ubuntu and using dotnet core 2.1.</p>