Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass this common property to MSBuild using TeamCity?

I am using the TeamCity Visual Studio runner. I want to add a setting that is not accessible from Visual Studio.

/Property:FileAlignment=4096

I typed that directly into the build step "Command line parameters." The build log shows the error:

MSBuild command line parameters contains "/property:" or "/p:" parameters. Please use Build Parameters instead.

I don't understand how to provide this to MSBuild from TeamCity and get rid of this warning!

1. Which kind of parameter should I use?

There are 3 kinds:

  • Configuration parameters
  • System properties
  • Environment variables.

I don't want an environment or system variable because I don't want this build to depend on anything external. I am going to try Config right now, but then I'm not sure I'm filling it in right.

2. How can I tell this parameter is actually getting used?

The build log, which seems only to have navigable/foldable xml-like levels with their program, did not say the build parameters.

like image 543
AnneTheAgile Avatar asked Jan 10 '12 21:01

AnneTheAgile


People also ask

How do I set environment variables in MSBuild?

Click on System and Security and then on System. In the left pane, click on Advanced system settings. At the very bottom of the pop up, click on Environment Variables. Edit the Path variable and append the folder's path that contains the MSBuild.exe to it (e.g., ;C:\Windows\Microsoft.NET\Framework64\v4.

How do you make a solution with MSBuild?

To build a specific target of a specific project in a solution. At the command line, type MSBuild.exe <SolutionName>. sln , where <SolutionName> corresponds to the file name of the solution that contains the target that you want to execute.

How do I run commands in MSBuild?

To enable msbuild in Command Prompt, you simply have to add the directory of the msbuild.exe install on your machine to the PATH environment variable. You can access the environment variables by: Right clicking on Computer.

What is switch in MSBuild?

When you use MSBuild.exe to build a project or solution file, you can include several switches to specify various aspects of the process. Every switch is available in two forms: -switch and /switch. The documentation only shows the -switch form. Switches are not case-sensitive.


1 Answers

You should use "System properties". Don't worry about the name, that's just how TeamCity calls it. They are regular properties. You can add them in "Edit Configuration Settings > 7. Build Parameters".

For example, you can add the system property as follows:

Name: system.FileAlignment

Type: System property (system.)

Value: 4096

Note that TeamCity will insist on the "system." prefix. It doesn't matter because the MSBuild script will still see it as $(FileAlignment).

like image 75
Alex Avatar answered Sep 28 '22 07:09

Alex