MSBuild fail to build because a file named "bin" is created instead of the bin directory

Hi everyone,
I have a problem with my .NET project on TeamCity. Everything is working OK except for sometimes MSBuild fails to build because a file named "bin" is created in the project folder instead of a bin directory. I try to delete the "bin" file and re-run the configuration then it works OK, but sometimes when TeamCity does a clean checkout and rebuild the solution then the problem happens again: a file named "bin" has been already created so that MSBuild can not create a bin directory and copy output files to that directory.

I've attached a screen shot of my checkout folder during the build, and below is some text extracted from the Build log

[MyWebProject.csproj] PrepareForBuild
[21:06:46][PrepareForBuild] MakeDir
[21:06:46][MakeDir] Creating directory "bin\".
[21:06:46][MakeDir] C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(932, 5): warning MSB3191: Unable to create directory "bin\". Cannot create "E:\TeamCity\VCS\MyWebProject\MyWebProject\bin" because a file or directory with the same name already exists.
[21:06:46][MakeDir] The previous error was converted to a warning because the task was called with ContinueOnError=true.
[21:06:46][MakeDir] Creating directory "Help\".
[21:06:46][MakeDir] Build continuing because "ContinueOnError" on the task "MakeDir" is set to "True".

Please help me, thanks in advanced

Comment actions Permalink

The file could be created by a previous build step, or by incorrect artifact dependency.
I would use Process Monitor to determine its origin.

Comment actions Permalink

OK I'll try it.

But I've found a work around to the error: just simply include the bin folder into VCS but not the output files inside the foder. So that when TeamCity call VCS to update the source code, the bin directory is already there so it won't create another bin file. I know it's a bad practice to inlude the bin directory into VCS but it works for me now.

With my work around above, do you think it's a bug in TeamCity ?

Comment actions Permalink

Until we found an origin of the issue, I cannot confirm it as a TeamCity bug.
Now with your workaround somewhere must be an error message with unability to create 'bin' file. Do you see it?

Comment actions Permalink

Michael, I've double checked but there's no such log message.

There're someone get the same issue with me, and the error happens when there're Post-Build events setup in the project, because TeamCity does not build the dependency projects in the expected orders, see this


Please sign in to leave a comment.