I got following error while running dotnet build
command on my .NET Core project.
C:\Program Files\dotnet\sdk\2.1.2\Microsoft.Common.CurrentVersion.targets(4106,5
): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\Blog-Yantra.dll" to
"bin\Debug\netcoreapp2.0\Blog-Yantra.dll". Beginning retry 1 in 1000ms. The proc
ess cannot access the file 'E:\learn\blog\Blog-Yantra\bin\Debug\netcoreapp2.0\Bl
og-Yantra.dll' because it is being used by another process. [E:\learn\blog\Blog
-Yantra\Blog-Yantra.csproj]
And my csproj file looks like:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TypeScriptToolsVersion>2.3</TypeScriptToolsVersion>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
Most likely an open .Net core process running and blocking, if on windows, just kill it through the task manager.
The solution for me is to stop the IIS Express processes by right-clicking on the taskbar icon.
Or you can make a command line in "Pre-Build Event":
$(Solution)taskkill /FI "IMAGENAME eq iisexpress.exe" /F
Add this command in the "Properties" of your projet > "Build Events"
We don't have time to see if the command has been executed properly in "Ouput" view into "Build" section. Add this command line in "Pre-Build Event" to see the results:
cmd /c pause
You can remove this line after check...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With