1
votes

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.

Below is some text extracted from the Build log:

[MyWebProject.csproj] PrepareForBuilBd
[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".
3

3 Answers

1
votes

My source code does not have a bin file.

There're someone get the same issue with me, and the error happens when there're Post-Build event setup in the project, because TeamCity does not build the dependency projects in the expected orders, see this http://social.msdn.microsoft.com/Forums/vstudio/en-US/46685782-ec0b-4df0-9132-88ef7e355600/msbuild-with-webapplication-error-msb3191-unable-to-create-directory-bin?forum=msbuild.

I don't want to remove the Post-build events, so I've found a workaround for that: just simply include the bin folder into CVS but not the inside output files. So that when TeamCity call CVS to update source code, the bin folder is already created so it won't create a bin file. I know It's a bad practice to include the bin directory into CVS (even just the folder, not the inside files), but it works for my problem now. I've also posted a question to TeamCity community, http://devnet.jetbrains.com/thread/451001, waiting TeamCity to fix the error. But in the while time my work around works for me.

0
votes

It sounds like there a bin file in your source control that gets checked out by teamcity which is why you have your issue.

Otherwise, you could add a new build step that occurs directly after the checkout that will remove the folder like:

DEL /Q bin

That will just delete it then the build can continue on.

0
votes

Welsh, setting up another build step right after checkout step to delete the bin file would be also a good work around. Will try, thanks Welsh.