7
votes

I am trying to build a project within teamcity. It will do the checkout of TFS and the files are locally on the build server. If I manually run the build command on the server it works:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe C:\TeamCity\buildAgent\work\3446a5bd436eea87\Dev\Dev\project\myproj\myproj.csproj /t:build

Within Teamcity I have a Build step of MSBuild:

the build fie path is: Dev\Dev\project\myproj\myproj.csproj" working directory left blank mbuild version: microsoft .net framework 4.0 msbuild toolsversion: 4.0 run platform: X86 targets: I have tried build "build" and left blank command line params left blank

if I create a command line build task and run the above command line it works. I am not sure what differences there are between the command line and msbuild task within teammcity.

EDIT

I have tried a few variations on the working directory:

The output path in project is set to ..\Build\Tools\myproj\

So I have set the working directory in teamcity to: Dev\Dev\project\Build\Tools\myproj\

This didn't help.

Here is the exact output from teamcity:

Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\work\3446a5bd436eea87\Dev\Dev\project\Build\Tools\myproj /msbuildPath:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
in directory: C:\TeamCity\buildAgent\work\3446a5bd436eea87\Dev\Dev\project\Build\Tools\myproj


Failed to start MSBuild.exe. Illegal characters in path.
System.ArgumentException: Illegal characters in path.
   at System.IO.Path.CheckInvalidPathChars(String path)
   at System.IO.Path.IsPathRooted(String path)
   at JetBrains.TeamCity.Utils.FileUtil.MakeFullPath(String path, String workDir) in         c:\BuildAgent\work\c2314fd21f15dc97\src\Utils\src\FileUtil.cs:line 48
   at JetBrains.BuildServer.MSBuildBootstrap.RunArgs.get_ProjectFile() in     c:\BuildAgent\work\c2314fd21f15dc97\src\MSBuildBootstrap\src\RunArgs.cs:line 156
   at     JetBrains.BuildServer.MSBuildBootstrap.Impl.MSBuildBootstrapFactory.Create(IClientRunArgs     args) in     c:\BuildAgent\work\c2314fd21f15dc97\src\MSBuildBootstrap.Core\src\Impl\MSBuildBootstrapFact    ory.cs:line 29
   at JetBrains.BuildServer.MSBuildBootstrap.Program.Run(String[] _args) in     c:\BuildAgent\work\c2314fd21f15dc97\src\MSBuildBootstrap\src\Program.cs:line 67
4
Specify build working directoryKMoraz
Have you checked the build log for the exact command team city is runnng?Mike Two

4 Answers

1
votes

Try editing the build configuration and remove the quotes from the Build file path option.

If you have:

"Dev\Dev\project\myproj\myproj.csproj"

Just let:

Dev\Dev\project\myproj\myproj.csproj

I hope this help.

1
votes

In TeamCity, when you are using parameters for your path, or a portion of the path, it is easy to paste in a folder and not notice that it has a New Line or Carriage Return on the end (as I found from painful experience). It could show up in TeamCity as the value for a parameter:

\Folder1\NewlyPastedInFolder \ExistingFolder\BuildScripts

What looks like a word-wrapped value is actually a parameter with a carriage return in the middle. Check it by editing it, and see if you can delete the character to make it into a single-line value.

0
votes

This questions seems very similar:

What's the illegal character in this string ? I'm getting MSBUILD : error MSB3095

In addition to this question, take a look at:

What is a dll.refresh file in ASP.Net?

On this question, this answer is of interest:

In an ASP.NET project, adding a file-based reference will add a .refresh file in the Bin folder. When the project is under source control, this file is then added to source control. *.dll.refresh files that litter the bin directory. Every time you add an external reference, you'll find a dll.refresh file right next to it. These dll.refresh files are an exception to the rule, and they should go into source control. Its the only way your web project will know where its references live.

If you don't have this in source control, it could explain the problem you are seeing. It sounds like the error message is potentially misleading and this is related to a reference not being resolved on the build machine.

With regards to why it works from the command line, is it possible that when you are building from TeamCity it is cleaning the output directory before building? If when you run from the command line binaries have already been output from the partially failed build which are referenced as file references, this would succeed.

To identify if this is the case - if you do a completely clean checkout and then run the MSBuild step from the command line, does it still succeed?

-1
votes

I ran into this error message from TeamCity and it turned out that a space in the solution file was causing it (the solution file referenced in the Visual Studio Build Steps had double quotes around it and that didn't seem to help. Perhaps it was those quotes that was blowing it up?). I suppose there is some way to handle the space character, but it was easier to just rename the solution file without the space and that solved the problem.