Could not copy the file "XXXX\apphost.exe" because it was not found
See original GitHub issueIssue Description
Running dotnet publish after deleting obj and bin directories fails until I taskkill the dotnet process.
Steps to Reproduce
- Download the latest SDK installer build (I’m using 7.0.100-rtm.22470.23)
- Unzip it to e.g. C:\dotnet7 and then run the following exact steps:
cd c:\dotnet7
set path=%cd%;%path%
dotnet new console -o test
cd test
dotnet publish -r win-x64 -c Release
rmdir /S /Q obj
rmdir /S /Q bin
dotnet publish -r win-x64 -c Release
Expected Behavior
The second publish succeeds, same as the first.
Actual Behavior
C:\dotnet7\sdk\7.0.100-rtm.22470.23\Microsoft.Common.CurrentVersion.targets(5145,5): error MSB3030: Could not copy the
file "C:\dotnet7\test\obj\Release\net7.0\win-x64\apphost.exe" because it was not found. [C:\dotnet7\test\test.csproj]
Analysis
Something with the dotnet.exe process that hangs around after the first publish. If I taskkill /im dotnet.exe /f before the second publish, it works. It took a while to figure that out.
Here’s the binlog from the failed attempt: msbuild.zip
Versions & Configurations
7.0.100-rtm.22470.23
Issue Analytics
- State:
- Created a year ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
c# - Visual Studio "Could not copy" .... during build
For me it was caused by manually launched .exe in the Release directory. The problem was that VS cannot copy over an executable...
Read more >Could not copy the file "obj\x64\Debug\Management.exe" ...
Hello, few times in day I get error “Could not copy the file “obj\x64\Debug\Management.exe” because it was not found.” while i try to...
Read more >Visual Studio Build Error: Could not copy the file because it ...
Recently we got a bunch of errors when building a project in Visual Studio 2013, complaining about missing content files: Could not copy...
Read more >[SOLVED] Unable to copy a file from obj - Winform Visual Studio
... file "obj\Debug\xxxx. exe " to "bin\Debug\xxxx. exe Unable to copy from obj\debug to bin\debug - MSDN - Microsoft Visual Studio " Could...
Read more >Unable to copy a file from obj\Debug to bin\Debug - YouTube
Could not copy "obj\Debug\xyz. exe " to "bin\Debug\xyz. exe ". Exceeded retry count of 10. Failed. CAN't debug the program cant build the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am closing this issue. We do not believe it impact enough people. We unblocked Michal with workaround and we can do same if other people experience this issue. Feel free to reopen it if needed.
I’m inclined to agree. This is the first time I’ve heard of folks making projects inside an SDK directory (though of course such a thing is possible), and I don’t want to over correct on a solution without a few more data points.