vsSolutionBuildEvent CI.MSBuild

Utility to support the CI /Build servers for work with vsSolutionBuildEvent via msbuild.exe (Microsoft Build Tools)

see Devenv Command-Line if you need command-line mode of Visual Studio(devenv.exe /.com)

How to get & Install

Use get.CIM.bat (~10 Kb) to get it in one click. (Compiled by GetNuTool)

How to configure project that does not use Visual Studio at all.

Currently the CI.MSBuild it's only additional wrapper (~50 kb) for work with vsSolutionBuildEvent plugin through API. You should also have this library for work it means.

However, variant with NuGet is also provides main libraries for complete work. Use any convenient variant for you!

Variant with NuGet package

nuget vsSBE.CI.MSBuild

vsSBE.CI.MSBuild - Full version (with all main libraries), just get and use…

nuget install vsSBE.CI.MSBuild

for example: nuget install vsSBE.CI.MSBuild -ExcludeVersion -OutputDirectory C:\projectX\bin\

or add for your .sln (see Managing Packages for the Solution):

  • In Visual Studio: right click on solution -> Manage NuGet Packages for Solution...

GetNuTool

You can get package with lightweight non-binary tool - GetNuTool ~10 Kb

gnt /p:ngpackages="vsSBE.CI.MSBuild"
msbuild.exe gnt.core /p:ngpackages="vsSBE.CI.MSBuild/1.6.12010"

Custom variant

For advanced usage, for example, with own private server, custom libraries etc.

How to use

Ok, now you're ready to use the vsSolutionBuildEvent engine with MSBuild Tools, for example:

msbuild.exe "<SolutionFile>.sln" /l:"<fullpath_to>\CI.MSBuild.dll"

Also you can set other path to library with lib key as: /l:"<path_to>\CI.MSBuild.dll";lib=<path_to_directory>, for example: /l:"D:\CI\CI.MSBuild.dll";lib=D:\lib\

You can also use the /verbosity key for details information from vsSolutionBuildEvent - /verbosity:detailed or /verbosity:diagnostic (debug mode for vsSolutionBuildEvent), for example:

msbuild.exe "<SolutionFile>.sln" /v:detailed /m:4 /l:"<path_to>\CI.MSBuild.dll" /nologo /noconlog

Use the CI.MSBuild.bat helper (it already included with latest assemblies):

<fullpath_to>\CI.MSBuild" <SolutionFile.sln> <optional_keys>
> bin\CI.MSBuild ConsoleApplication1.sln

Example of work

Keys to CI.MSBuild

name description sample
lib Path to main library - vsSolutionBuildEvent.dll /l:"CI.MSBuild.dll";lib=D:\bin\
culture v1.3+ Culture for the current thread culture=ru-RU
cultureUI v1.3+ Culture used by the Resource Manager to look up culture-specific resources at run time. For example - console messages from msbuild engine etc. cultureUI=en-US

Samples:

  • "D:\projects\App1.sln" /l:"CI.MSBuild.dll";lib=D:\bin\vsSolutionBuildEvent\;cultureUI=en-US /v:detailed /t:Rebuild /p:Configuration=Debug;Platform="Any CPU" /m:8

Note for the culture keys: You can also change active console code page with chcp [nnn] command:

  • United States: chcp 437
  • Russian: chcp 866 (oem dos)

If you want disable all msbuild-messages (i.e. allow messages only from vsSolutionBuildEvent), use /noconsolelogger key to msbuild.exe. The levels of messages from library are managed by .vssbe.user file.

Additional MSBuild Properties

List of properties that available as the MSBuild Properties (e.g. $(name))

name description sample of value availability
vsSolutionBuildEvent The version of the vsSolutionBuildEvent engine. 0.12.6.19789 v1.6+
vssbeCIM The version of the CI.MSBuild 1.5.0.19789 v1.6+

Keys to msbuild.exe

Use msbuild.exe /? to look all available keys or see MSDN documentation

name description sample
/noconlog To disable all msbuild-messages. Is a short form of /noconsolelogger. /noconlog
/v:level Information to display in the build log. Levels: q[uiet], m[inimal], n[ormal]. Starting with d[etailed] and diag[nostic] is also turns on the debug mode for vsSolutionBuildEvent. /v:diag
/m[:num] The maximum number of concurrent processes to use when building. /m:16

Could not load file or assembly … or one of its dependencies.

MSBUILD : error MSB4017: The build stopped unexpectedly because of an unexpected logger failure.
...

Our NuGet Package is already contains most required libraries for working.

However, the various environments for CI has a different configuration and if you see similar problem and list of this:

Could not load file or assembly ... or one of its dependencies.

You can try add this manually into /bin folder.

If you see any problem with installing and/or using, please report here

Some references can be removed later special for CI.MSBuild version and/or some libraries can be added later in our package directly or as dependencies to full automation.

Configuring

Notes:

  • For nuget clients:
    • Use key -ExcludeVersion for path without version number, e.g.: vsSBE.CI.MSBuild\bin\CI.MSBuild.dll
    • You can simply use it with one command - nuget restore <SolutionFile>.sln… if the CI.MSBuild added for .sln it's easy and useful (see in 'How to get & Install' above)
  • For GetNuTool:
    • Use version & output keys for managing paths.

Example for AppVeyor

  • http://www.appveyor.com

AppVeyor is also provides the private NuGet hosting, and you can use own packages of the vsSolutionBuildEvent CI.MSBuild (related topic)

Example with AppVeyor

With AppVeyor NuGet server

See also AppVeyor documentation & Creating and Publishing a Package

  • On AppVeyor: Project - Settings - NuGet - enable the Account feed
  • Go to the folder with libraries CI.MSBuild (see above - Install->Manually variant)
  • Execute the command nuget spec CI.MSBuild.dll
    • should create the CI.MSBuild.dll.nuspec file, change this file as you want (nuget doc).
  • Then pack this with command: nuget pack CI.MSBuild.dll.nuspec
  • On AppVeyor: go to - Account NuGet feed and get you API key or full command.
  • Push your packet on AppVeyor server: nuget push CI.MSBuild.dll.<ver>.nupkg -ApiKey <API key> -Source <Account feed URL>/api/v2/package
  • On AppVeyor: Projects - Build - set as script and use next script for example:
nuget install CI.MSBuild -OutputDirectory C:\projects\<your_project>\Build\bin\ -Source https://ci.appveyor.com/nuget/<your_id> 
  & nuget restore <SolutionFile>.sln 
  & "C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe" "<SolutionFile>.sln" /verbosity:detailed /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /l:"C:\projects\<your_project>\Build\bin\vsSBE.CI.MSBuild.<ver>\bin\CI.MSBuild.dll" /m

With our NuGet package

Similar as above:

  • On AppVeyor: Projects - Build - set as script and use next script for example:
nuget install vsSBE.CI.MSBuild -OutputDirectory C:\projects\<your_project>\Build\bin\  
  & nuget restore <SolutionFile>.sln 
  & "C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe" "<SolutionFile>.sln" /verbosity:detailed /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /l:"C:\projects\<your_project>\Build\bin\vsSBE.CI.MSBuild.<ver>\bin\CI.MSBuild.dll" /m

Yes, that's all.

Example for TeamCity

  • https://www.jetbrains.com/teamcity/

Similar as for AppVeyor above:

  • Build Configuration Settings - Build Step - Command Line - Custom script
nuget install vsSBE.CI.MSBuild -OutputDirectory C:\projects\<your_project>\Build\bin\  
  & nuget restore <SolutionFile>.sln 
  & "C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe" "<SolutionFile>.sln" /verbosity:detailed /l:"C:\projects\<your_project>\Build\bin\vsSBE.CI.MSBuild.<ver>\bin\CI.MSBuild.dll" /m:4 /nologo

For additional NuGet server, use command:

  • nuget sources add -Name <FriendlyName> -Source <URL>
  • For private: nuget sources add -Name <FriendlyName> -Source <URL> -UserName <user> -Password <pass>

Example of work

References