Warm tip: This article is reproduced from serverfault.com, please click

TeamCity .NET Runner is incorrectly quoting Platform property when Any CPU used

发布于 2020-08-21 08:52:22

I have some .NET Framework projects being built by TeamCity 2020 (latest version). Currently the "MSBuild" Runner type is used - as this is deprecated, I'm trying to convert the build tasks to use the new ".NET" Runner type. When trying to set the Platform property to "Any CPU" in the parameters, TeamCity ends up quoting the entire parameter and this causes MSBuild to fail.

I'm setting the following properties for this runner:

  • Command: msbuild
  • Projects: [solution file name]
  • MSBuild version: MSBuild 2019
  • Configuration: %BuildConfiguration% (parameter value)
  • Command line parameters: -property:Platform="Any CPU" -verbosity:minimal -nodeReuse:false

When this build runs, it fails. In the log you can see the MSBuild command being run:
MSBuild.exe [solution file] /p:Configuration=[config parameter] "-property:Platform="Any CPU"" -verbosity:minimal -nodeReuse:false

Because TeamCity is putting double-quotes around the -property:Platform parameter, MSBuild doesn't recognise this and thinks that multiple project files are being supplied, so it exits.

I've tried using single quotes for 'Any CPU', removing the space, using the /p:Platform syntax... same result.

How do I use the .NET Runner to build .NET Framework projects for the "Any CPU" platform?

Questioner
Graham Clark
Viewed
0
Graham Clark 2020-08-21 23:22:49

The solution that eventually worked for me was to create a new Solution Platform which was based on the existing "Any CPU" one but instead called AnyCpu. Now there's no spaces or quotes to confuse things.