A Maven plugin for building dotnet projects based on .csproj
or project.json
files.
This plugin lets you use the power of Maven to drive .NET core builds.
- Drives the invocation of
dotnet
andnuget
command line tools for build, test, deploy of .NET core projects. - Runs unittests via
dotnet test
on projects that have a defined Test Runner. - Offers a
mvn clean
option which arguably is currently missing from thedotnet
CLI tools. - Propagates versioning scheme from Maven parent to the
.csproj
orproject.json
files of the modules. - Supports two project layouts: A pom-per-dotnet-module or a single-pom-for-all-dotnet-modules approach. See example projects.
- The plugin has Maven extensions, allowing it to be idiomatically bound to standard Maven phases by declaring certain packging types:
<packaging>dotnet</packaging>
will bind relevant Maven phases for dotnet component and application projects, includingdotnet pack
,dotnet publish
anddotnet nuget add
.- If a
<repository>
element is defined in the projects configuration,dotnet nuget push
is also bound to themvn deploy
phase.
- If a
<packaging>dotnet-library</packaging>
will bind relevant Maven phases for dotnet class libraries, i.e. excludingdotnet publish
.<packaging>dotnet-test</packaging>
will bind relevant Maven phases for dotnet test-only projects, includingdotnet test
.<packaging>dotnet-integration-test</packaging>
will bind Maven phaseintegration-test
todotnet test
and Maven phase toverify
to the gathering/evaluation of those results, allowing forpost-integration-test
clean-up tasks to take place exiting on test failures.- All above packaging types also have
clean
,restore
,build
bindings
The plugin leverages the dotnet
(required) and nuget
(optional) command line tools, which have to be installed prior to usage of the plugin.
The simples use-case it to simply define your project with the packaging type, dotnet
and enabled it with a plugin in pom.xml
like this:
<project>
[...]
<packaging>dotnet</packaging>
[...]
<build>
<plugins>
<plugin>
<groupId>org.eobjects.build</groupId>
<artifactId>dotnet-maven-plugin</artifactId>
<version>0.24</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
[...]
</project>
Should you want to, you can configure many aspects of the dotnet
and nuget
invocations. The following should provide a handy overview by example:
<plugin>
<groupId>org.eobjects.build</groupId>
<artifactId>dotnet-maven-plugin</artifactId>
<version>0.23</version>
<extensions>true</extensions>
<configuration>
<buildConfiguration>Release</buildConfiguration>
<buildEnabled>true</buildEnabled>
<cleanEnabled>true</cleanEnabled>
<environment>
<MY_ENVVAR_1>hello</MY_ENVVAR_1>
<MY_ENVVAR_2>world</MY_ENVVAR_2>
</environment>
<integrationTestRunEnabled>true</integrationTestRunEnabled>
<integrationTestVerifyEnabled>true</integrationTestVerifyEnabled>
<nugetAddEnabled>true</nugetAddEnabled>
<nugetAddSource>~/.nuget/Packages</nugetAddSource>
<nugetPushEnabled>true</nugetPushEnabled>
<packEnabled>true</packEnabled>
<packOutput>bin</packOutput>
<publishEnabled>true</publishEnabled>
<publishOutput>bin/my-publish-output</publishOutput>
<repository>https://path/to/repository</repository>
<restoreEnabled>true</restoreEnabled>
<testEnabled>true</testEnabled>
</configuration>
</plugin>
Take a look at the Example projects for more inspiration.