How to use "Build Parameters" instead of "/property:" for MSBuild commandline param?

Hi! I'm simply using the Teamcity-provided visual studio runner. I want to add the commandline parameter setting, ie an msbuild parameter that is not accessible via the GUI. The specific one of interest is; /P:filealignment=4096

When I directly type that into "Command line parameters:" the build log shows the error;
MSBuild command line parameters contains "/property:" or "/p:" parameters. Please use Build Parameters instead.

So I tried adding the first kind of parameter, a config. It did not seem to help, but also the documentation was not clear on what it would do in the first place. Also, I don't know what is a spec?

This msbuild option causes very subtle differences, and it seemed that the Teamcity log file did not add my additional  commandline parameters to the run? It should say so, right? It does show msbuild is being called/wrapped.

So if that is not the right kind, then which kind of parameter should I use? There are 3 kinds of /Configuration Steps / Build Parameters /; 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.

How should I be able to tell when 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.

Finally, I am really disappointed in the Teamcity documentation, maybe I'm overlooking a great source, so please feel free to point me in the proper directions for best googling. Usually when I google I get 5 duplicate hits on the same page of documentation. Then reading that page uses terms that are not cross-linked and yet very common, eg "build" which could refer to a vast number of things.

Thank you so much in advance for your help!!

12 comments
Comment actions Permalink

Did you tried system.filealignment=4096 ? This should be defined in Build Parameters->System Properties.

0
Comment actions Permalink

hi Danch, thank you so much for your reply!

I tried using the system property, as follows, to no avail. Do you have an example?

Here is what I did with your idea. I'm showing  the project config file's node, to make it clear what TC thinks it is doing.

eg path; ...\config\MY-PROJECT-NAME\project-config.xml

1.Test1; Same error as above; Using no ampersands, which I didn't think would work but just fyi;

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

Input;

      <build-runners>
        <runner id="RUNNER_1" name="MsBuildSln_Pom" type="VS.Solution">
          <parameters>
            <param name="build-file-path" value="/keepfocused-47837-src/KeepFocused.sln" />
            <param name="msbuild.prop.Configuration" value="Release" />
            <param name="msbuild_version" value="3.5" />
            <param name="run-platform" value="x86" />
            <param name="runnerArgs" value="/verbosity:diagnostic /property:system.filealignment=4096" />
            <param name="targets" value="Rebuild" />
            <param name="toolsVersion" value="3.5" />
            <param name="vs.version" value="vs2008" />
          </parameters>
        </runner>
      </build-runners>

2.Test2; Error no compatible agents, so cannot start the build, using ampersands to indicate a parameter.

Input;

      <build-runners>
        <runner id="RUNNER_1" name="MsBuildSln_Pom" type="VS.Solution">
          <parameters>
            <param name="build-file-path" value="/keepfocused-47837-src/KeepFocused.sln" />
            <param name="msbuild.prop.Configuration" value="Release" />
            <param name="msbuild_version" value="3.5" />
            <param name="run-platform" value="x86" />
            <param name="runnerArgs" value="/verbosity:diagnostic /property:%system.filealignment%=4096" />
            <param name="targets" value="Rebuild" />
            <param name="toolsVersion" value="3.5" />
            <param name="vs.version" value="vs2008" />
          </parameters>
        </runner>
      </build-runners>

0
Comment actions Permalink

First of all I see that you are using Visual Studio (sln) runner type  (  <runner id="RUNNER_1" name="MsBuildSln_Pom" type="VS.Solution">  ). I do not have experience with that type of runner because I'm only  using msbuild type. However syntax should be similar.

I also see that you added "/property:system.filealignment=4096" to runner configuration page in field described as "Enter additional command line parameters to MSBuild.exe."

This  is not the right place. Please leave this field empty and in Configuration Steps go to Build Paramters. Then choose "Add new  parameter", select "System property" as Type, in Name field add  "filealignment" (system. should be already there) and in Value fields  type "4096", then save.

In project-config.xml build  parameters are stored in <parameters> node and you should see  there new entry <param name="system.filealignment" value="4096"  />.
You can also check what parametes where sent to build  runner by looking in <build agent directory>\temp\buildTmp . In  that directory check for teamcity.build<some number>.properties or teamcity.build<some number>.properties.xml files.

I hope that helps.

0
Comment actions Permalink

hi Danch!

Thank you! I tried that and it did work, but I am still baffled as how to double check that the properties were actually passed to the MSBuild command. I see no evidence they were.

Also, I can't do the system property trick for a verification test, ie like call msbuild /help, since it's not the /p option.

This question stems from a problem whereby, likely due to file alignment, our build exe/dll sizes do not match our pre-existing ie GUI-built binaries. Part of the problem is VS2008 but part of the problem is not being able to set these properties.

Also, as I mentioned above, I would be happy to call msbuild directly if only I could get the Treeview on the log.

ps I got some help on Stackoverflow as well;

http://stackoverflow.com/questions/8810860/how-do-i-pass-this-common-property-to-msbuild-using-teamcity

0
Comment actions Permalink

Posting reply so Yegor can see it, per private email.

0
Comment actions Permalink

Anne,

danch was perfect in the advices in this thread.

Could you please be more specific on "I tried that and it did work" ?
To check what is actually passed into the build script you can probably print all MSBuild properties in it.

0
Comment actions Permalink

I found the system  property on Teamcity properties page.

However in build log, the wrapped msbuild command did not have the option.

How would I  print all MSBuild properties when Teamcity not I am actually running the call to msbuild.exe?

0
Comment actions Permalink

To concretize what "worked" but did not apparently do what I want;

Here is the section of project-config.xml for the build that successfully runs, but does not appear to do what I want;

        <runner id="RUNNER_1" name="MsBuildSln_Pom" type="VS.Solution">
          <parameters>
            <param name="build-file-path" value="/keepfocused-47837-src/KeepFocused.sln" />
            <param name="msbuild.prop.Configuration" value="Release" />
            <param name="msbuild_version" value="3.5" />
            <param name="run-platform" value="x86" />
            <param name="runnerArgs" value="/Property:FileAlignment=%system.filealignment%" />
            <param name="targets" value="Rebuild" />
            <param name="toolsVersion" value="3.5" />
            <param name="vs.version" value="vs2008" />

Here is a section of the build log showing the warning and msbuild;

[09:21:37]: Starting: xxxx\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:xxxx\ZCIB.zTrialsPom /msbuildPath:C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe
#[09:21:37]: in directory: xxx\ZCIB.zTrialsPom
#[09:21:39]: keepfocused-47837-src\KeepFocused.sln.teamcity: Build target: TeamCity_Generated_Build (2s)
#[09:21:38]: MSBuild command line parameters contains "/property:" or "/p:" parameters. Please use Build Parameters instead.
#[09:21:39]: keepfocused-47837-src\KeepFocused\KeepFocused.csproj: Build target: Rebuild (2s)

0
Comment actions Permalink

I was able to get this to work properly, although I think teamcity's devenv runner might not have been able to override settings that were in the csproj files.With that caveat, here is what I found.

C#-TIP: How to ensure FileAlignment=512 via three ways to build;
1.CLI Msbuild ..\..\docuity.sln /target:Clean;Build /p:Configuration=Release /p:Platform="Any CPU" /p:Filealignment=512
2.CLI Devenv ....\docuity.sln /Rebuild /Property:Config=Release;Platform=AnyCPU;Filealignment=512

3.Teamcity's "Visual Studio Build":
3a.For Command line parameters, enter: /Property:FileAlignment=filealignment v:diag
3b.The output tab for Build Parameters shows: User Defined Parameters:
system.filealignment = 512
system.verbosity = diagnostic
3c.The resultant build file eg on the diff, will have this section. Note how the syntax differs from my failing trial.

      <runner id="RUNNER_13" name="vs2010" type="VS.Solution">
        <parameters>
          <param name="build-file-path" value="try.sln" />
          <param name="msbuild.prop.Configuration" value="Release" />
          <param name="msbuild_version" value="4.0" />
          <param name="run-platform" value="x86" />
          <param name="runnerArgs"><![CDATA[system.filealignment = 512
system.verbosity = diagnostic]]></param>
          <param name="targets" value="Rebuild" />
          <param name="toolsVersion" value="4.0" />
          <param name="vs.version" value="vs2010" />
        </parameters>
      </runner>

0
Comment actions Permalink

Danch and Yegor, It was in the Build Step's Command line parameters, not in the Parameters tab where this seems to work.

0
Comment actions Permalink

Hi,
I have related issue. I'm using build properties as suggested above and everything is just fine. But, I have a problem here, One of the steps run a debug build with /PROFILE linker option for Debug configuration, however, once I use system property this linker option will apply to all other steps which use msbuild/VS project. Ok, I can overcome it by splitting my build configuration into several build configuration which have only one build step which uses MSBuild. So far so good. But consider following scenario. My build configuration have a step "Build Release Server with Profile Guided Optomization" which requres LinkTimeCodeGeneration=PGInstrument property, next step deploys the server and run execution scenarios on it. When it finishes following build step should collect PGC files, copy it back to binary output folder and build the SAME solution, now with option LinkTimeCodeGeneration=PGOptimization. Obviously, I cannot split this task into two build configurations (well, I guess I can, producing artifact which will include all source, intemediate files and binaries, which means hundreds of megabytes or even gygabytes) and cannot use two values for one property. How do I resolve this problem?

0
Comment actions Permalink

Hello,

The 3C is totally incorrect as you put unsupported values as MSBuild.exe commandline parameters.

TeamCity calls the following command from VS.Solution/MSBuild runners:

MSBuild.exe <path to your .sln file> /target:<target> <extract>

Where <extra> contains:
- all system properties (with 'system.' prefix removed) that were defined in "Properties and Environemnt variables" of Build Configuration settings or inherited
- string of custom commandline parameters as was defined in runner settings.

So you have only 2 options to specify MSBuild properties:
1) add system property in "Properties and Environemnt variables" of Build Configuration settings
2) add commandline parameter like /p:a=b or /property:c=d

The only benefit from 1) is that TeamCity will take care to quete name and values in to proper way in commandline. That was why we used to show the warning.
I removed the warning in newer builds of TeamCity.
The drawback of 2) approach is that you may break MSBuild commandline by unquoted (improperly quoted) custom parameters.


Could you please first make sure if

MSBuild.exe <path to your .sln file> /target:Rebuild /p:FileAlignment=512

works right on the agent machine.
If not, this is not the issue in TeamCity, this is the issue with MSBuild.

0

Please sign in to leave a comment.