-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Steps to reproduce
-
Clone my repro repository: https://github.com/cjablonski76/dotnetCoreBuildIssue.git
-
Restart your machine (this was the only consistent way I could repro the issue).
-
open command prompt, navigate to the cloned repo location
-
run
dotnet build ./WebApplication1/WebApplication1.sln --framework netcoreapp2.1- Removing the
--frameworkoption seems to build without any "Cannot open" errors.
- Removing the
-
build command will error with:
CSC : error CS2012: Cannot open 'c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\obj\Debug\netcoreapp2.1\ClassLibrary1.dll' for writing -- 'The process cannot access the file 'c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\obj\Debug\netcoreapp2.1\ClassLibrary1.dll' because it is being used by another process.' [c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\ClassLibrary1.csproj]
NOTE: you must restart the machine each time you wish to reproduce the error. During my testing, after the first run on a fresh restart dotnet build --framework netcoreapp2.1 ran successfully. I'm sure there is a way to get into the bad state without restarting the machine, but this was the simplest thing I could find with my knowledge around the build process. When running on our CI servers, they tend to fail with a project like this a majority of the time if we build with the --framework flag.
Expected behavior
Successful build of the solution.
Actual behavior
Errors on build with output:
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 57.46 ms for c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\ClassLibrary1.csproj.
Restore completed in 259.57 ms for c:\src\dotnetCoreBuildIssue\WebApplication1\WebApplication1\WebApplication1.csproj.
ClassLibrary1 -> c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\bin\Debug\netcoreapp2.1\ClassLibrary1.dll
CSC : error CS2012: Cannot open 'c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\obj\Debug\netcoreapp2.1\ClassLibrary1.dll' for writing -- 'The process cannot access the file 'c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\obj\Debug\netcoreapp2.1\ClassLibrary1.dll' because it is being used by another process.' [c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\ClassLibrary1.csproj]
WebApplication1 -> c:\src\dotnetCoreBuildIssue\WebApplication1\WebApplication1\bin\Debug\netcoreapp2.1\WebApplication1.dll
Build FAILED.
CSC : error CS2012: Cannot open 'c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\obj\Debug\netcoreapp2.1\ClassLibrary1.dll' for writing -- 'The process cannot access the file 'c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\obj\Debug\netcoreapp2.1\ClassLibrary1.dll' because it is being used by another process.' [c:\src\dotnetCoreBuildIssue\WebApplication1\ClassLibrary1\ClassLibrary1.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:02.97
Environment data
dotnet --info output:
Version: 2.1.403
Commit: 04e15494b6
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.403\
Host (useful for support):
Version: 2.1.5
Commit: 290303f510
.NET Core SDKs installed:
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.3-servicing-26724-03 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]