0

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.

Amir
  • 399
  • 1
  • 7
  • 25

2 Answers2

1

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
Sara Liu - MSFT
  • 6,007
  • 1
  • 21
  • 27
  • So what setup do I need to run the build on Windows server 2012 (not R2)? I need to use dotnet msbuild. The project was originally build with ms build tools 2017 and .net framework 4.8 – Amir Apr 21 '21 at 08:44
  • 1
    Actually, it is quite different. Since VS2017 build tool and VS2019 build tool do not support Windows Server 2012. Your OS is quite special. See [this document](https://learn.microsoft.com/en-us/visualstudio/releases/2019/system-requirements#microsoft-visual-studio-build-tools-2019-system-requirements), the build tool is the same requirements as VS IDE and it also supports some other systems, but there is no windows server 2012. So in your side, you could not use Build Tool for VS2017 and VS2019. – Sara Liu - MSFT Apr 22 '21 at 06:33
  • 1
    And VS2015 build tool supports Windows Server 2012 and it only build non-sdk net framework projects rather than net core projects. Besides, `dotnet cli 5.x` also does not support windows server 2012. Only [net core 2.1 does](https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=netcore21). However, that is too old. – Sara Liu - MSFT Apr 22 '21 at 07:19
  • 1
    To use VS2015 build tool, you have to [download VS2015 build tool](https://www.microsoft.com/en-us/download/details.aspx?id=48159) on Windows Server 2012. And then you will find it. Then, use "C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" xxx.csproj for non-sdk net framework projects and use `dotnet build xxx.csproj for new-sdk projects`.(dotnet cli 2.x). – Sara Liu - MSFT Apr 22 '21 at 07:20
  • maybe I had to mention that there are sqlproj in the solution. And based on this answer https://stackoverflow.com/a/62124722/10159346 its not possible to build it with this setup. – Amir Apr 22 '21 at 08:34
  • 1
    If so, you should download the whole VS2015 IDE update 3(contain the sqlserver project workload). the pure VS2015 build tool does not contain the sql server build tool. So if you want the `C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe` could build sqlproj files, you have to install VS2015(at least it supports Windows Server 2012). dotnet build and build tool for VS2017 and VS2019 cannot realize that project. You have to use that. But that full ide is too large and it may not satisfy you, but there is no any other ways:) I should let you know that. – Sara Liu - MSFT Apr 23 '21 at 09:47
1

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\\"
demp
  • 12,665
  • 2
  • 23
  • 17