Marv
Marv

Reputation: 758

Pass msbuild properties to devenv.exe on the command line

I am building a solution automatically with devenv.exe on our CI server, this works totally fine. For deployment purposes I added a nuget package (namely OctoPack). Its documentation tells me to pass properties to MSBuild when building, but as I am using devenv, that is not possible.

Through research, I learned that I can add a PropertyGroup to the the .csproj of the project, to add these properties. I would prefer not to do that, as I need to replace certain values (like the version number) in those properties, so I do not want to put placeholders into those strings. Additionally, I would need to be able to have those PropertyGroups only active when building on the CI server, not when developing and building locally.

This ultimately leads to my question: Can I somehow pass those properties, which are usually passed to MSBuild (via /p:), to devenv on the command line?

Upvotes: 1

Views: 2692

Answers (2)

guppy81
guppy81

Reputation: 91

As stated here devenv.exe does not provide any command-line switch for setting msbuild properties.

As stated in the other answer and comments, for modern projects, it would be better to use msbuild.exe instead of directly calling devenv.exe.

But if you need to use devenv.exe for building project-types which are not supported by msbuild (e.g. *.vdproj = Windows installer projects) you can set any msbuild-property right before calling devenv.exe by setting an environment variable:

/property:name=value or /p:name=value

results in

set name=value

In a subsequent call, then execute devenv.exe.

Upvotes: 0

granadaCoder
granadaCoder

Reputation: 27842

(I'm posting an answer so that this question can be closed out).

  1. I'd suggest not using devenv.exe on your CI server.

  2. Start using msbuild.exe.

  3. Pass in parameters using the

/property:name=value /p:name=value

  1. use nuget.exe restore MySolution.sln to restore packages.

Upvotes: 4

Related Questions