Skip to content

Commit

Permalink
Added built-in support to download, install and use dotnet core from …
Browse files Browse the repository at this point in the history
…Gradle directly
  • Loading branch information
juanmuscaria committed Feb 8, 2024
1 parent e960b68 commit 2f3b83c
Show file tree
Hide file tree
Showing 4 changed files with 3,467 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ bin
obj
packages
/.idea/
/dotnet/sdk/
44 changes: 43 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ plugins {

version = "0.1"
group = "com.juanmuscaria"
var os = DefaultNativePlatform.currentOperatingSystem

repositories {
mavenCentral()
Expand Down Expand Up @@ -52,7 +53,6 @@ micronaut {

tasks.register("compileModloader", Exec) {
setWorkingDir("$rootProject.projectDir/modloader")
OperatingSystem os = DefaultNativePlatform.currentOperatingSystem
if (os.isLinux()) {
setCommandLine('/usr/bin/msbuild')
} else {
Expand Down Expand Up @@ -101,6 +101,48 @@ tasks.register("repackBepInEx") {
dependsOn("repackBepInExUnix", "repackBepInExWin")
}

tasks.register("installDotnetSdk", Exec) {
group('dotnet')

workingDir = "$projectDir/dotnet"
if (os.isWindows()) {
commandLine 'cmd', '/c', 'Powershell -File dotnet-install.ps1'
} else {
commandLine './dotnet-install.sh'
}

// dotnet-install.sh accepts the same arguments as the powershell version, but not the other way around...
args += ['-InstallDir', 'sdk', '-NoPath', '-Channel', '6.0']
}

tasks.register("updateNuGetDependencies", Exec) {
group('dotnet')
dependsOn('installDotnetSdk')

workingDir = "$projectDir/modloader"
if (os.isWindows()) {
commandLine 'cmd', '/c', file("$projectDir/dotnet/sdk/dotnet.exe").getAbsolutePath()
} else {
commandLine file("$projectDir/dotnet/sdk/dotnet").getAbsolutePath()
}

args += ['restore']
}

tasks.register("buildModloader", Exec) {
group('dotnet')
dependsOn('updateNuGetDependencies')

workingDir = "$projectDir/modloader"
if (os.isWindows()) {
commandLine 'cmd', '/c', file("$projectDir/dotnet/sdk/dotnet.exe").getAbsolutePath()
} else {
commandLine file("$projectDir/dotnet/sdk/dotnet").getAbsolutePath()
}

args += ['msbuild']
}

processResources {
dependsOn("repackBepInEx")
from("$buildDir/repack")
Expand Down
Loading

0 comments on commit 2f3b83c

Please sign in to comment.