Graham Clark
Graham Clark

Reputation: 12966

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

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:

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?

Upvotes: 4

Views: 2458

Answers (4)

Dominik
Dominik

Reputation: 11

Another option would be that Jetbrains will fix this wired behavior.

As far as I see the logic of dotnet runner is following: If there is any white space in a text field (tested with parameters and build configuration) then the whole string will be surrounded with quotes. But IMHO this should only be done if there is no other quote present. If there is at least one quote, then the user added it by intention and TC should assume that the user knows why the quotes were added.

The mentioned "MSBuild" Runner is handling parameters with white spaces properly. Maybe its code should be checked.

And when the whole command line parameters are quoted, then only one parameter can be used. Joining more than one per ; would fail then.

Update:
As of June 2021 and TeamCity version 2021.1 following command line config works now: "/P:Platform=Mixed Platforms" /P:OutputPath=..\build -restore
and
"/P:Platform=Mixed Platforms;OutputPath=..\build" -restore

Upvotes: 1

NikolayP
NikolayP

Reputation: 389

The best option is to pass parameters through the TeamCity system parameters.

In your case it is: system.Platform=Any CPU.

Another option is to completely wrap the command line parameter: "/p:Platform=Any CPU"

Upvotes: 0

JBartlau
JBartlau

Reputation: 802

Just stumbled accross this post after encountering a similar problem with TeamCity. We're using the property switch to pass a reference path to the build process. The full switch is

/property:ReferencePath="\\dllserver\referenceroot\.NET Framework 4"

which then results in the notorious error message

msb1008: only one project can be specified

What worked on my end is to put the quotes around the whole setting, not just the part containing blanks - like so:

"/property:ReferencePath=\\dllserver\referenceroot\.NET Framework 4"

Maybe this is useful for others, too.

Upvotes: 5

Graham Clark
Graham Clark

Reputation: 12966

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.

Upvotes: 0

Related Questions