• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created about 12 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

📢 DEPRECATED

gradle-dotnet-plugin is now available for building projects via dotnet command line tool chains. The plugin supports running nunit, code coverage, nuget restore and push.

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:

Prerequisites

  • .Net Framework 4.6

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 a HintPath

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

To apply the plugin:

// Starting from gradle 2.1
plugins {
  id 'com.ullink.msbuild' version '3.15'
}

or

buildscript {
    repositories {
        url "https://plugins.gradle.org/m2/"
    }

    dependencies {
        classpath 'com.ullink.gradle:gradle-msbuild-plugin:3.15'
    }
}
apply plugin:'com.ullink.msbuild'

and configure by:

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']


  // MsBuild resolution
  // it support to search the msbuild tools from vswhere (by default it searches the latest)
  version = '15.0'
  // or define the exact msbuild dir explicity
  msbuildDir = 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\MSBuild\\15.0\\bin'


  // 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/vb

  // replaces the AssemblyVersion value in your AssemblyInfo file.
  // when explicitly set to blank, AssemblyVersion will not be updated and will keep the existing value in your AssemblyInfo file
  // TODO: not yet normalized, beware than .Net version must be X.Y.Z.B format, with Z/B optionals
  version = project.version + '.0.0'

  // replaces the AssemblyFileVersion value in your AssemblyInfo file.
  // defaults to above version, fewer restrictions on the format
  // when explicitly set to blank, AssemblyFileVersion will not be updated and will keep the existing value in your AssemblyInfo file
  fileVersion = version + '-Beta'

  // replaces the AssemblyInformationalVersion value in your AssemblyInfo file.
  // defaults to above version, fewer restrictions on the format
  // when explicitly set to blank, AssemblyInformationalVersion will not be updated and will keep the existing value in your AssemblyInfo file
  informationalVersion = version + '-Beta'

  // replaces the AssemblyDescription in the your AssemblyInfo file.
  // when set to blank (default), AssemblyDescription will not be updated and will keep the existing value in your AssemblyInfo file
  description = 'My Project Description'

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

Custom tasks

You can create custom msbuild and assemblyInfoPatcher tasks like so:

import com.ullink.Msbuild
import com.ullink.AssemblyInfoVersionPatcher

task compileFoo(type: Msbuild) {
    projectFile = "Foo.vcxproj"
    // Other properties
}

task versionPatchFoo(type: AssemblyInfoVersionPatcher) {
    projects = ['Foo']
    // Other properties
}

See also

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.

More Repositories

1

simple-slack-api

(simple) Java Slack client library
Java
470
star
2

gradle-nuget-plugin

Executes NuGet from a gradle build
Groovy
22
star
3

ordered-scheduler

Unlock code that have sequence / ordering requirements
Java
20
star
4

gradle-dotnet-plugin

Gradle plugin for interacting with dotnet cli
Kotlin
18
star
5

gradle-repositories-plugin

Gradle plugin to extend repository definition for GitHub, SourceForge, GoogleCode & NuGet
Groovy
18
star
6

gradle-nunit-plugin

A gradle plugin for launching NUnit tests
Groovy
17
star
7

gerrit-coverage-plugin

A Gerrit plugin for make coverage information available at review-time
Java
16
star
8

gradle-ikvm-plugin

Gradle plugin for IKVM artifact compilation
Java
14
star
9

git-react-client

Frontend to git-grep REST API, allows to grep through multiple bare repositories
TypeScript
9
star
10

jira-slackit

Plugin for JIRA to allow integration with Slack
JavaScript
8
star
11

slack4gerrit

Slack bot for gerrit integration
Java
7
star
12

gradle-opencover-plugin

A gradle plugin for getting test coverage using OpenCover
Groovy
6
star
13

gradle-test-export-plugin

Groovy
5
star
14

git-bare-node-rest-api

Provides a REST API over a set of bare git repositories
JavaScript
5
star
15

gradle-jibx-plugin

Groovy
4
star
16

gradle-pdbindex-plugin

Gradle plugin to run PDB indexing on debug files
Groovy
4
star
17

lunch-box

TBDNA
Java
3
star
18

performance-trends

Java
3
star
19

fix-repo

npm package for easy accessible FIX Repository information
TypeScript
2
star
20

NugetConverter

Watch and convert in realtime directories storing simples dlls hierarchically to a fully fonctionnal Nuget repository managing dependencies
C#
1
star
21

CEFPopupIntegration

Demonstrate Integration of Popup/Secondary Windows as Winform panel
C#
1
star
22

process-diagnostics

Command line utility to create memory and call stack dumps based on CLRMD
C#
1
star
23

spek-junit-rules

Library which allows limited use of JUnit 4 rules with Spek
Kotlin
1
star
24

ulodisys-client.js

UL ODISYS Node.Js client library
JavaScript
1
star
25

gradle-tools-plugin

Originates from https://github.com/gluck/gradle-scripts that have been pluginified
Groovy
1
star
26

MemoryDumpObjectsRestore

Restore objects from memory dumps
C#
1
star
27

gradle-editbin-plugin

Groovy
1
star
28

rx-shim

Rx to await for .Net 4.0
C#
1
star
29

rxjava-test-extras

Handy testing utilities for RxJava
Java
1
star
30

deadlock-free-ssl-provider

a ssl provider extracted from OpenJDK6-b27
Java
1
star
31

gradle-gallio-plugin

Gradle plugin for gallio tests execution
Groovy
1
star
32

beerbot

a beer bot for slack
Clojure
1
star