Amir
Amir

Reputation: 441

Define Path with space for an Argument for MSBuild in teamcity

I am working on a Build step in teamcity where I have to give an alternative Path for MSBuildExtensionsPath. The MS build has to build a solution. In the command line parameters I tried to give the path as followed:

/p:MSBuildExtensionsPath=C:\Program Files (x86)\MSBuild
/p:MSBuildExtensionsPath=C:\Program Files (x86)\MSBuild\
/p:MSBuildExtensionsPath="C:\Program Files (x86)\MSBuild"
/p:MSBuildExtensionsPath="C:\Program Files (x86)\MSBuild\"

None of them seem to work. First it comes

Starting: .NET SDK 5.0.202 "C:\Program Files\dotnet\dotnet.exe" msbuild C:\BuildAgent\work\69c3cf0148257793\WorkProject\DWH.sln /p:Configuration=Release @C:\BuildAgent\temp\agentTmp\1.rsp "/p:MSBuildExtensionsPath="C:\Program Files (x86)\MSBuild\""

Then the error

MSBUILD : error MSB1008: Only one project can be specified. Switch: Files

Somehow the whole "/p:MSBuildExtensionsPath="C:\Program Files (x86)\MSBuild"" is in quoten marked.

Upvotes: 1

Views: 1308

Answers (2)

demp
demp

Reputation: 12813

This may be due to how java-based command line parser works in TeamCity. May look counter-intuitive, but try enclosing whole definition in quotes. This worked for me. So in your case it will look like

"/p:MSBuildExtensionsPath=C:\Program Files (x86)\MSBuild"

Note that if you need trailing slash in the path then it needs to be doubled, like in

"/p:MSBuildExtensionsPath="C:\Program Files (x86)\MSBuild\\"

Upvotes: 2

Sara Liu - MSFT
Sara Liu - MSFT

Reputation: 6218

Your command has some errors, you should not add "" for /p:MSBuildExtensionsPath=xxx. And do not add \. Use C:\Program Files (x86)\MSBuild.

Try this:

msbuild C:\BuildAgent\work\69c3cf0148257793\WorkProject\DWH.sln /p:Configuration=Release @C:\BuildAgent\temp\agentTmp\1.rsp /p:MSBuildExtensionsPath="C:\Program Files (x86)\MSBuild"

Besides, if you change the MSBuildExtensionsPath property, you should note these tips:

The C:\Program Files (x86)\MSBuild is old VS2015 or previous MSBuild path. And if your solution contains new-sdk net core projects, it cannot build it since Net core is added >=VS2017. And Net 5.0 is supported after VS2019 16.8. You should note that.

If your solution all are non-sdk net framework projects, you can use your method.

Update

Your OS is quite strange. And Build Tool for VS2017 and VS2019 do not support Windows Server 2012.

And VS2015 build tool supports Windows Server 2012 and it only build non-sdk net framework projects rather than net core projects.

Also, net core 5.x does not support Windows Server 2012. Only Net core 2.1 does. However, that is too old and might not work well with your new-sdk projects.

If you still insist on it, you could try these:

Download VS2015 build tool, and download Net Core 2.1 Sdk and that. When you use this under your Windows Server 2012, you should uninstall any other net core sdk.

Use a bat file and then split your solution and build each project with a different MSBuild. You can use the BAT file instead.

"C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" xxx.csproj -t:build //for non-sdk projects

dotnet build xxx.csproj // for new-sdk projects

Upvotes: 1

Related Questions