com.ullink.gradle:gradle-msbuild-plugin

Gradle plugin for MSBuild project build.

License

License

Categories

Categories

Gradle Build Tools
GroupId

GroupId

com.ullink.gradle
ArtifactId

ArtifactId

gradle-msbuild-plugin
Last Version

Last Version

2.22
Release Date

Release Date

Type

Type

jar
Description

Description

com.ullink.gradle:gradle-msbuild-plugin
Gradle plugin for MSBuild project build.
Project URL

Project URL

https://github.com/Ullink/gradle-msbuild-plugin
Source Code Management

Source Code Management

https://github.com/Ullink/gradle-msbuild-plugin.git

Download gradle-msbuild-plugin

How to add to project

<!-- https://jarcasting.com/artifacts/com.ullink.gradle/gradle-msbuild-plugin/ -->
<dependency>
    <groupId>com.ullink.gradle</groupId>
    <artifactId>gradle-msbuild-plugin</artifactId>
    <version>2.22</version>
</dependency>
// https://jarcasting.com/artifacts/com.ullink.gradle/gradle-msbuild-plugin/
implementation 'com.ullink.gradle:gradle-msbuild-plugin:2.22'
// https://jarcasting.com/artifacts/com.ullink.gradle/gradle-msbuild-plugin/
implementation ("com.ullink.gradle:gradle-msbuild-plugin:2.22")
'com.ullink.gradle:gradle-msbuild-plugin:jar:2.22'
<dependency org="com.ullink.gradle" name="gradle-msbuild-plugin" rev="2.22">
  <artifact name="gradle-msbuild-plugin" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.ullink.gradle', module='gradle-msbuild-plugin', version='2.22')
)
libraryDependencies += "com.ullink.gradle" % "gradle-msbuild-plugin" % "2.22"
[com.ullink.gradle/gradle-msbuild-plugin "2.22"]

Dependencies

compile (4)

Group / Artifact Type Version
net.java.dev.jna : jna jar 4.2.2
net.java.dev.jna : jna-platform jar 4.2.2
com.google.guava : guava jar 16.0.1
commons-io : commons-io jar 2.4

Project Modules

There are no modules declared in this project.

📢 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.7'
}

or

buildscript {
    repositories {
      mavenCentral()
    }

    dependencies {
        classpath 'com.ullink.gradle:gradle-msbuild-plugin:3.7'
    }
}
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.

com.ullink.gradle

Itiviti

Follow us on our new Github! https://github.com/Itiviti

Versions

Version
2.22
2.18
2.15
2.14
2.13
2.12
2.11
2.10
2.9
2.8
2.7
2.6
2.5
2.4
2.3
2.2
2.1
2.0
1.11
1.9
1.7
1.6
1.5
1.4
1.3
1.2
1.1