Itiviti / gradle-msbuild-plugin

Gradle plugin for msbuild execution, supports C# project files for now
Apache License 2.0
102 stars 57 forks source link

Feature request: Build multiple configurations #74

Closed MarcDahlem closed 7 years ago

MarcDahlem commented 7 years ago

At the moment it seems, that one must add a single configuration to the msbuild configuration block.

What I need is a task, which builds my visual studio solution with both configurations 'Release' and 'Debug', so that I can upload both artifacts to maven with one gradle call.

Therefore, I ask for a possibility to define multiple configurations in the msbuild configuration. e.g.:

msbuild {
  ...
  targets = ['Clean', 'Rebuild']
  configurations = ['Release', 'Debug']
}

I already tried to call msbuild mutliple times, but the latter did unforunately not work, as the task 'msbuild' is only executed once (in the example, gradle clean build builds only the msbuild with configuration Release):

task buildRelease() << {
  msbuild.configuration = 'Release'
  tasks["msbuild"].execute()
}

task buildDebug() << {
  msbuild.configuration = 'Debug'
  tasks["msbuild"].execute()
}

tasks["msbuild"].outputs.upToDateWhen { false }

tasks["build"].dependsOn buildDebug
tasks["build"].dependsOn buildRelease
buildDebug.dependsOn buildRelease
gluck commented 7 years ago

The msbuild gradle is simply a default task created of type MSBuild, as you can see here but you can create others:

project.task('msbuild2', type: MSBuild) {
    configuration = 'Release'
}

Gradle is not ant or make, you have a configuration phase before the execution, and in the later, altering configuration is no longer supported.

MarcDahlem commented 7 years ago

Ah nice, I didn't check your code. Thanks a lot.

This solution works (mostly): Only the clear command does not clear the solutions output directories, then.

Thunderforge commented 5 years ago

For the benefit of anybody going down the same rabbit hole I went down, you have to add import com.ullink.Msbuild before this will work.

Full solution:

import com.ullink.Msbuild

task compileFoo(type: Msbuild) {
    projectFile = "foo.vcxproj"
    targets = ["Build"]
    // other properties
}