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

后端 未结 4 923
半阙折子戏
半阙折子戏 2021-02-19 06:10

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

相关标签:
4条回答
  • 2021-02-19 06:57

    (This is -754 chars for a comment so must be typed as a post)

    hi Anthony, Thank you for replying! Yes, msbuild on the commandline works fine for me as well and project files may store FileAlignment properties. In our case, upon discussion with Microsoft, it appears necessary that I specify the solution-wide aka build-wide alignment, ie in the command arguments, in addition to fixing the projects (which I have already done).

    No parameter that I specify on the GUI item ( /Build Step / Command line parameters/ ) will appear on the tab /Build Parameters/. Of course some will not compile at all.

    Also I have even more weird behavior where using /verbosity:diagnostic vs /verbosity:minimal causes a longer build log for the minimal! It appears diagnostic is hiding the details inside of a special task, which is part of Teamcity and not me; [16:24:05]: Overriding target "SatelliteDllsProjectOutputGroup" in project "C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets" with target "SatelliteDllsProjectOutputGroup" from project "C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.WinFX.targets". I am struggling with this because the Teamcity-generated build output log is so nice to have as a TreeView. That works with the SLN build but using any bat file cannot produce log file with the pretty (xml, presumably) tree-format.

    If you have further ideas I will love to hear them, and thank you for your edits! :)

    0 讨论(0)
  • 2021-02-19 06:59

    The TeamCity documentation defines Build Parameters as "a convenient way of passing generic or environment-specific settings into the build script". Configuration parameters provide a way to override some settings in a build configuration inherited from a template. They are never passed to a build. System and Environment parameters are provided to your build script. Environment variables are actually set on the system (I can't find any documentation for this). System parameters are passed to the script engine.

    TeamCity automatically provides System variables to the actual command line (it looks like the Visual Studio runner runs msbuild.exe and not devenv.exe). I guess that TeamCity is constructing a command like

    cmd> msbuild.exe my-solution.sln /p:FileAlignment=4096
    

    I tried this on my command line, just to make sure that it should work (I added the /v:diagnostic flag). The diagnostic verbosity makes msbuild print all of it's properties to the console. I verified that FileAlignment=4096 was in there.

    That /FileAlignment property appears to be a special property that's automatically in any .csproj file. So you should be good to go. You can check the actual parameters that were passed to the build by clicking on any build and viewing the 'Build Parameters' tab. There's a section that shows the "Actual Parameters on Agent".

    0 讨论(0)
  • 2021-02-19 07:10

    This was solved. To clarify, Anthony told how to solve the problem in the commandline using MSBuild. It can also be solved on the commandline using devenv, per a ticket with Microsoft, the syntax is:

     devenv ..\..\mysolution.sln /Rebuild /Property:Config=Release;Platform=AnyCPU;Filealignment=512
    

    What I wanted, however, was to get Teamcity's "Visual Studio Build" to accept the parameter. This was achieved as follows. In the box for Command line parameters, I entered:

    /Property:FileAlignment=filealignment v:diag
    

    Then the output tab for Build Parameters shows:

    User Defined Parameters
    Name                    Value passed to build
    system.filealignment    512
    system.verbosity        diagnostic
    
    0 讨论(0)
  • 2021-02-19 07:16

    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).

    0 讨论(0)
提交回复
热议问题