0

I am migrating a few solutions into azure devops and want to use the MSBuild Task to build them.

The are currently build using devenv with the following commands:

devenv.com file.vcxproj /rebuild "unittest debug" /project project_name

I thought I would try with

msbuild.exe file.vcxproj /p:Project=project_name /p:configuration="unittest debug"

But I am getting the error that the project does not contains the "unittest debug"

I would appreaciate any help I could get.

Thanks for reading,

user25470
  • 585
  • 4
  • 17

1 Answers1

1

The devenv command line you are using doesn't make complete sense.

file.vcxproj is a C++ project. If it were a solution, e.g. somesolution.sln, then the /project switch would make sense, e.g. if somesolution.sln included file.vcxproj then the following command would build file.vcxproj.

devenv.com somesolution.sln /project file

Solutions and projects have a 'configuration' and a 'platform'. "unittest debug" looks like an attempt to specify this information but the syntax is not correct. The correct syntax is

<configuration>|<platform>

The default configuratuion values are Debug and Release.

I suspect that

"unittest debug"

should be

"debug|unittest".

The original devenv command line can probably be rewritten as

devenv.com file.vcxproj /rebuild "debug|unittest"

The MSBuild equivalent is

msbuild.exe file.vcxproj /t:rebuild /p:configuration=debug;platform=unittest

The /build, /clean, and /rebuild switches on devenv map to MSBuild targets in the C++ project. The C++ project also expects configuration and platform as separate properties.

Jonathan Dodds
  • 2,654
  • 1
  • 10
  • 14
  • Thanks! I will try it tomorrow. The original devenv command works, but there are some weird stuff going on so it might be buggy – user25470 Jan 19 '23 at 15:14
  • I accept that the devenv command works, but I don't why it works. I can imagine that the `/project` switch is accepted as valid by the command line parsing validation but subsequently ignored because the file is not a solution. More interesting is that `"unittest debug"` is accepted. Maybe, internal to devenv, only `unittest` is used? Debug is usually the default configuration when none is specified. But I don't know and this is just speculation. – Jonathan Dodds Jan 19 '23 at 15:40