Stop MSBuild from locking your files! Also, consider that the problem could be MSBuild or something your build is doing.
Note: Use Visual Studio Developer Command Prompt.
set MSBUILDDISABLENODEREUSE=1
devenv yourproject.csproj
msbuild yourproject.csproj /nr:false
taskkill /im msbuild.exe
Here's a handy script I use to kill various .NET processes that tend to hold onto files.
taskkill /f /im msbuild.exe
taskkill /f /im dotnet.exe
taskkill /f /im vbcscompiler.exe
taskkill /f /im omnisharp.exe