dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.23k stars 1.35k forks source link

MSBuild locks xunit assemblies during compilation of some specs #3417

Closed Aaronontheweb closed 6 years ago

Aaronontheweb commented 6 years ago

Steps to reproduce

Clone a copy of the Akka.NET project from here: https://github.com/akkadotnet/akka.net

Open the project in Visual Studio or JetBrains Rider.

Select the following project: https://github.com/akkadotnet/akka.net/tree/dev/src/core/Akka.Cluster.Tests

Attempt to build it while the IDE is open.

Expected behavior

Project compiles with no issues and unit tests can be run / debugged from the Visual Studio test runner.

Actual behavior

Looks as though the file gets locked by the Visual Studio testhost.x86 process.

7>Akka.Cluster.Tests -> D:\olympus\akka.net\src\core\Akka.Cluster.Tests\bin\Debug\netcoreapp1.1\Akka.Cluster.Tests.dll
7>Done building project "Akka.Cluster.Tests.csproj".
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): warning MSB3026: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Beginning retry 2 in 1000ms. The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): warning MSB3026: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Beginning retry 3 in 1000ms. The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): warning MSB3026: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Beginning retry 4 in 1000ms. The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): warning MSB3026: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Beginning retry 5 in 1000ms. The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): warning MSB3026: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Beginning retry 6 in 1000ms. The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): warning MSB3026: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Beginning retry 7 in 1000ms. The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): warning MSB3026: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Beginning retry 8 in 1000ms. The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): warning MSB3026: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Beginning retry 9 in 1000ms. The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): warning MSB3026: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Beginning retry 10 in 1000ms. The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): error MSB3027: Could not copy "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". Exceeded retry count of 10. Failed. The file is locked by: "testhost.x86 (20612)"
7>F:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(4343,5): error MSB3021: Unable to copy file "C:\Users\aaron\.nuget\packages\xunit.abstractions\2.0.1\lib\net35\xunit.abstractions.dll" to "bin\Debug\net452\xunit.abstractions.dll". The process cannot access the file 'bin\Debug\net452\xunit.abstractions.dll' because it is being used by another process.

If you try running a command line build, i.e. c:\akkadotnet\src> dotnet build you'll see a variation of this error occur from the CLI so long as the IDE is also open at the same time.

Environment data

dotnet --version: 2.0.0

VS Info:

Microsoft Visual Studio Professional 2017 
Version 15.7.3
VisualStudio.15.Release/15.7.3+27703.2026
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Professional

ASP.NET and Web Tools 2017   15.0.40522.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   15.7.31476
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017   5.2.60419.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.40424.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.3.3000.2
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools   15.0.40424.0
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio   2.3.3000.2
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools   2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

ILSpy.AddIn   1.0
Integration of the ILSpy Decompiler into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

JetBrains ReSharper Ultimate 2018.1.2    Build 112.0.20180530.113618
JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2018 JetBrains, Inc.

Microsoft Azure HDInsight Azure Node   2.3.3000.2
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.3.3000.2
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio   2.1
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service   2.3.3000.2
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.10420.2

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

NuGet Package Manager   4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Redgate SQL Search   2.4.2.1439
Search functionality for SQL Server databases, from within Visual Studio

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools   15.1.61804.210
Microsoft SQL Server Data Tools

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript Tools   15.7.20419.2003
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   2.8.3-beta6-62923-07. Commit Hash: 7aafab561e449da50712e16c9e81742b8e7a2969
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.1 for F# 4.1   15.7.0.0.  Commit Hash: 2527e6829ecdc8281ee60d83be8cfd0fa720a648.
Microsoft Visual F# Tools 10.1 for F# 4.1

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

OS info:

Windows 10 Pro Version: 1803 OS Build: 17134.112

Aaronontheweb commented 6 years ago

Weird part about this is, I can sometimes compile other Test projects but never the Akka.Cluster.Tests project I linked to earlier.

cdmihai commented 6 years ago

This does not look like an msbuild issue, but rather an IDE one. Can you please open the issue against Visual Studio (https://docs.microsoft.com/en-us/visualstudio/ide/how-to-report-a-problem-with-visual-studio-2017)?

Aaronontheweb commented 6 years ago

Looks like this may have been the root cause of this issue: https://github.com/xunit/xunit/issues/1644