rhautefeuille / gradle-msbuild-plugin

Gradle plugin for msbuild execution, supports C# project files for now

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gradle MsBuild Plugin Build status Build Status

This plugin allows to compile an MsBuild project. It also supports project file parsing, and some basic up-to-date checks to skip the build. I doubt it'll work on anything else than .csproj files right now, but adding support for more will be easy.

Plugin applies the base plugin automatically, and hooks msbuild output folders into the clean task process. Below tasks are provided by the plugin:

msbuild

Prior to execution, this task will parse the provided project file and gather all its inputs (which are added to the task inputs):

  • included files (Compile, EmbeddedResource, None, Content)
  • ProjectReference (recursively gathers its inputs) // TODO: should use outputs instead ?
  • References with an HintPath

OutputPath (e.g. bin/Debug) & Intermediary (e.g. obj/Debug) are set as output directories for the task.

Sample usage:

buildscript {
    repositories {
      mavenCentral()
    }

    dependencies {
        classpath "com.ullink.gradle:gradle-msbuild-plugin:2.16"
    }
}

apply plugin:'msbuild'

msbuild {
  // mandatory (one of those)
  solutionFile = 'my-solution.sln'
  projectFile = file('src/my-project.csproj')
  
  // MsBuild project name (/p:Project=...)
  projectName = project.name
  
  // Verbosity (/v:detailed, by default uses gradle logging level)
  verbosity = 'detailed'
  
  // targets to execute (/t:Clean;Rebuild, no default)
  targets = ['Clean', 'Rebuild']
  
  // Below values can override settings from the project file
  
  // overrides project OutputPath
  destinationDir = 'build/msbuild/bin'
  
  // overrides project IntermediaryOutputPath
  intermediateDir = 'build/msbuild/obj'
  
  // Generates XML documentation file (from javadoc through custom DocLet)
  generateDoc = false
  
  // Other msbuild options can be set:
  // loggerAssembly, generateDoc, debugType, optimize, debugSymbols, configuration, platform, defineConstants ...
  
  // you can also provide properties by name (/p:SomeProperty=Value)
  parameters.SomeProperty = 'Value'
  
  // Or, if you use built-in msbuild parameters that aren't directly available here,
  // you can take advantage of the ExtensionAware interface
  ext["flp1"] = "LogFile=" + file("${project.name}.errors.log").path + ";ErrorsOnly;Verbosity=diag"
}

assemblyInfoPatcher {
  // mandatory if you want to patch your AssemblyInfo.cs/fs
  // TODO: not yet normalized, beware than .Net version must be X.Y.Z.B format, with Z/B optionals
  version = project.version + '.0.0'

  // defaults to above version, fewer restrictions on the format
  fileVersion = version + '-Beta'

  // default to msbuild main project (of solution)
  projects = [ 'MyProject1', 'MyProject2' ]
}

See also

Gradle PdbIndex plugin - Allows to source index generated PDB files.

Gradle NuGet plugin - Allows to restore NuGet packages prior to building the projects with this plugin, and to pack&push nuget packages.

Gradle NUnit plugin - Allows to execute NUnit tests from CI (used with this plugin to build the projects prior to UT execution)

Gradle OpenCover plugin - Allows to execute the UTs through OpenCover for coverage reports.

You can see these 4 plugins in use on ILRepack project (build.gradle).

License

All these plugins are licensed under the Apache License, Version 2.0 with no warranty (expressed or implied) for any purpose.

About

Gradle plugin for msbuild execution, supports C# project files for now

License:Apache License 2.0


Languages

Language:Groovy 62.7%Language:C# 37.3%