title: Msbuild Task on Azure Devops: Cannot create /bin/debug because a file or directory with the same name already exists. (MSB3021, MSB3026, MSB3027)
body: <p>I am running an <strong>MSbuild</strong> task for my solution (with many projects) on <strong>Azure Devops</strong> but the build failed at some steps named <strong>_CopyFilesMarkedCopyLocal</strong> and (_CopyFilesMarkedCopyLocal target). </p>
  
  <p>At these steps, the build attempted to create a 'bin/debug' folder before doing the copy but this failed with the error codes MSB3021, MSB3026 and MSB3027.
  Here's a part of my log file where this issue occurs.</p>
  
  <pre><code>##_CopyFilesMarkedCopyLocal:
    Creating directory "bin\Debug".
    Creating directory "bin\Debug".
    Creating directory "bin\Debug".
    Creating directory "bin\Debug
  
  ##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(4384,5): Error MSB3027: Could not copy "d:\a\1\s\WWSS\packages\CrystalDecisions.Windows.Forms.1.0.0\lib\CrystalDecisions.Windows.Forms.dll" to "bin\Debug\CrystalDecisions.Windows.Forms.dll". Exceeded retry count of 10. Failed. 
  
  ##[d:\a\1\s\my\project\path\M1.csproj]
  </code></pre>
  
  <p>The content of my yaml file is:</p>
  
  <pre><code>- task: NuGetCommand@2
    inputs:
      command: 'restore'
      restoreSolution: '**/Mach1.sln'
      feedsToUse: 'select'
      vstsFeed: '93d16ac6-dhfjjj-43cb-89d5-e6a-41d0-b752-khf0e84jbf'
  
  
  - task: MSBuild@1
    inputs:
      solution: '**/Mach1.sln'
      msbuildArchitecture: 'x64'
      platform: 'Any CPU'
      configuration: 'Debug' 
  </code></pre>
  
  <p>The solutions I found after searching for those error codes were only for scenarios where the files to be copied were locked, but not where the bin/debug folder already exists. 
  From the build log, similar _CopyFilesMarkedCopyLocal steps on some projects in the solution ran successfully but I can't explain why it failed in other places.</p>
  
  <p>I need a way to make the build continue even when the bin/debug folder already exists but I don't know where to make this setting.</p>
  
  <p>Some of the links I've visited are listed below but none has been helpful</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/2625239/unable-to-copy-a-file-from-obj-debug-to-bin-debug">Unable to copy a file from obj\Debug to bin\Debug</a></li>
  <li><a href="https://stackoverflow.com/questions/18102859/visual-studio-could-not-copy-during-build">Visual Studio &quot;Could not copy&quot; .... during build</a></li>
  <li><a href="https://github.com/dotnet/sdk/issues/1707" rel="nofollow noreferrer">https://github.com/dotnet/sdk/issues/1707</a></li>
  </ul>