diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02f427bdcd..ec8310ef1c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,6 +36,10 @@ jobs: run: | apt-get update || true apt-get install -y apt-transport-https + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '7' - name: Installing build dependencies run: apt-get update && apt-get install -y git - name: Install runtime dependencies diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 85603e7f00..9b6e93b8c4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,6 +31,10 @@ jobs: echo 'odd_build=true' >> $GITHUB_OUTPUT fi + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '7' - name: Installing build dependencies run: apt-get update && apt-get install -y git make sed gzip fakeroot lintian dpkg-dev gpg createrepo - name: Installing runtime dependencies diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a917fcbc18..719ae366bf 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -15,6 +15,10 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Setup .NET Core + uses: actions/setup-dotnet@v3 + with: + dotnet-version: '7' - name: Installing build dependencies run: apt-get update && apt-get install -y git make sed libplist-utils xorriso gzip fakeroot lintian rpm wget jq dpkg-dev gpg createrepo - name: Installing runtime dependencies diff --git a/.gitignore b/.gitignore index 8fa9db1fb8..d66419ff80 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /_build/ /.vs/ -/.vscode/ /tools test-results *.userprefs diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..f7c9752af9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,17 @@ +{ + "dotnet.preferCSharpExtension": false, + "dotnet.server.useOmnisharp": true, + "dotnet.defaultSolution": "CKAN.sln", + "dotnet.automaticallyCreateSolutionInWorkspace": false, + "dotnet.backgroundAnalysis.analyzerDiagnosticsScope": "fullSolution", + "dotnet.backgroundAnalysis.compilerDiagnosticsScope": "fullSolution", + "omnisharp.useModernNet": false, + "omnisharp.projectLoadTimeout": 600, + "python.defaultInterpreterPath": "py", + "files.watcherExclude": { + "**/_build/**": true + }, + "nunitTestRunner.projectsPatterns": [ + "_build/out/**/*.Tests.dll" + ] +} diff --git a/AutoUpdate/CKAN-autoupdate.csproj b/AutoUpdate/CKAN-autoupdate.csproj index 49fecaac18..9d65829fc2 100644 --- a/AutoUpdate/CKAN-autoupdate.csproj +++ b/AutoUpdate/CKAN-autoupdate.csproj @@ -1,7 +1,8 @@ CKAN-AutoUpdateHelper - ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\VSCodeIDE\bin\ ..\_build\out\$(AssemblyName)\$(Configuration)\obj\ @@ -28,10 +29,6 @@ - - - - Properties\GlobalAssemblyVersionInfo.cs @@ -48,25 +45,4 @@ - - - - - - - - - - - - - - diff --git a/Cmdline/CKAN-cmdline.csproj b/Cmdline/CKAN-cmdline.csproj index caa42b629a..10f9de0ec8 100644 --- a/Cmdline/CKAN-cmdline.csproj +++ b/Cmdline/CKAN-cmdline.csproj @@ -1,7 +1,8 @@ CKAN-CmdLine - ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\VSCodeIDE\bin\ ..\_build\out\$(AssemblyName)\$(Configuration)\obj\ diff --git a/ConsoleUI/CKAN-ConsoleUI.csproj b/ConsoleUI/CKAN-ConsoleUI.csproj index 446cbabeea..634c192ed8 100644 --- a/ConsoleUI/CKAN-ConsoleUI.csproj +++ b/ConsoleUI/CKAN-ConsoleUI.csproj @@ -1,7 +1,8 @@ CKAN-ConsoleUI - ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\VSCodeIDE\bin\ ..\_build\out\$(AssemblyName)\$(Configuration)\obj\ diff --git a/Core/CKAN-core.csproj b/Core/CKAN-core.csproj index 9c3f6d12a4..6bb5d4e083 100644 --- a/Core/CKAN-core.csproj +++ b/Core/CKAN-core.csproj @@ -1,7 +1,8 @@ CKAN - ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\VSCodeIDE\bin\ ..\_build\out\$(AssemblyName)\$(Configuration)\obj\ diff --git a/GUI/CKAN-GUI.csproj b/GUI/CKAN-GUI.csproj index 0d18e79b25..6a0e37ee50 100644 --- a/GUI/CKAN-GUI.csproj +++ b/GUI/CKAN-GUI.csproj @@ -1,7 +1,8 @@ CKAN-GUI - ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\VSCodeIDE\bin\ ..\_build\out\$(AssemblyName)\$(Configuration)\obj\ @@ -22,12 +23,20 @@ prompt 4 IDE1006 + + true + diff --git a/Netkan/CKAN-netkan.csproj b/Netkan/CKAN-netkan.csproj index e54a5b3715..8706031022 100644 --- a/Netkan/CKAN-netkan.csproj +++ b/Netkan/CKAN-netkan.csproj @@ -1,7 +1,8 @@ CKAN-NetKAN - ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\VSCodeIDE\bin\ ..\_build\out\$(AssemblyName)\$(Configuration)\obj\ diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 3722502311..841472a06d 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -1,7 +1,8 @@ CKAN.Tests - ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\$(Configuration)\bin\ + ..\_build\out\$(AssemblyName)\VSCodeIDE\bin\ ..\_build\out\$(AssemblyName)\$(Configuration)\obj\ diff --git a/build b/build index 5d7ade48cf..a4a8b19371 100755 --- a/build +++ b/build @@ -25,11 +25,7 @@ rootDir=$(dirname $0) scriptFile="$rootDir/build.cake" buildDir="$rootDir/_build" toolsDir="$buildDir/tools" -packagesDir="$buildDir/lib/nuget" nugetExe="$toolsDir/NuGet/$nugetVersion/nuget.exe" -packagesConfigFile="$rootDir/packages.config" -cakeVersion="$(sed -nE "/id=\"Cake\"/s/.*version=\"(.+)\".*/\1/p" $packagesConfigFile)" -cakeExe="$packagesDir/Cake.$cakeVersion/Cake.exe" nugetDir="$(dirname $nugetExe)" if [ ! -d "$nugetDir" ]; then @@ -40,7 +36,12 @@ if [ ! -f "$nugetExe" ]; then curl -L "https://dist.nuget.org/win-x86-commandline/v${nugetVersion}/nuget.exe" --output "$nugetExe" fi -mono "$nugetExe" restore "$packagesConfigFile" -OutputDirectory "$packagesDir" +# dotnet tool install idiotically returns failure if already installed, +# so we have to ignore all errors from it +# https://github.com/dotnet/sdk/issues/9500 +set +e +dotnet tool install --global Cake.Tool +set -e cakeArgs="" @@ -59,5 +60,6 @@ if $useExperimental; then cakeArgs="$cakeArgs --experimental" fi -mono "$cakeExe" "$scriptFile" $cakeArgs $remainingArgs +export PATH="$PATH:$HOME/.dotnet/tools" +dotnet cake "$scriptFile" $cakeArgs $remainingArgs exit $? diff --git a/build.cake b/build.cake index 60dd88baf0..93178cf425 100644 --- a/build.cake +++ b/build.cake @@ -205,20 +205,15 @@ Task("Build-DotNet") .IsDependentOn("Restore-Nuget") .IsDependentOn("Generate-GlobalAssemblyVersionInfo") .WithCriteria(() => buildFramework == buildNetFramework) - .Does(() => -{ - MSBuild(solution, settings => - { - settings.Configuration = configuration; - }); -}); + .Does(() => MSBuild(solution, + settings => settings.SetConfiguration(configuration))); Task("Restore-DotNetCore") .Description("Intermediate - Download dependencies with NuGet when building for .NET Core.") .WithCriteria(() => buildFramework == buildNetCore) .Does(() => { - DotNetCoreRestore(solution, new DotNetCoreRestoreSettings + DotNetRestore(solution, new DotNetRestoreSettings { ConfigFile = "nuget.config", EnvironmentVariables = new Dictionary { { "Configuration", configuration } } @@ -232,7 +227,7 @@ Task("Build-DotNetCore") .WithCriteria(() => buildFramework == buildNetCore) .Does(() => { - DotNetCoreBuild(solution, new DotNetCoreBuildSettings + DotNetBuild(solution, new DotNetBuildSettings { Configuration = configuration, NoRestore = true @@ -273,14 +268,31 @@ Task("Repack-Ckan") "{0}/*/*.resources.dll", outDirectory.Combine("CKAN-CmdLine").Combine(configuration).Combine("bin").Combine(buildNetFramework) ))); - - ILRepack(ckanFile, cmdLineBinDirectory.CombineWithFilePath("CKAN-CmdLine.exe"), assemblyPaths, + ILRepack( + ckanFile, + cmdLineBinDirectory.CombineWithFilePath("CKAN-CmdLine.exe"), + assemblyPaths, new ILRepackSettings { Libs = new List { cmdLineBinDirectory.ToString() }, TargetPlatform = TargetPlatformVersion.v4 - } - ); + }); + + var autoupdateBinDirectory = outDirectory.Combine("CKAN-AutoUpdateHelper") + .Combine(configuration) + .Combine("bin") + .Combine(buildNetFramework); + ILRepack( + repackDirectory.Combine(configuration) + .CombineWithFilePath("AutoUpdater.exe"), + autoupdateBinDirectory.CombineWithFilePath("CKAN-AutoUpdateHelper.exe"), + GetFiles(string.Format("{0}/*/*.resources.dll", + autoupdateBinDirectory)), + new ILRepackSettings + { + Libs = new List { autoupdateBinDirectory.ToString() }, + TargetPlatform = TargetPlatformVersion.v4 + }); CopyFile(ckanFile, buildDirectory.CombineWithFilePath("ckan.exe")); }); @@ -298,6 +310,7 @@ Task("Repack-Netkan") new ILRepackSettings { Libs = new List { netkanBinDirectory.ToString() }, + TargetPlatform = TargetPlatformVersion.v4 } ); @@ -353,7 +366,7 @@ Task("Test-UnitTests+Only-DotNetCore") CreateDirectory(nunitOutputDirectory); - DotNetCoreTest(solution, new DotNetCoreTestSettings { + DotNetTest(solution, new DotNetTestSettings { NoBuild = true, Configuration= configuration, ResultsDirectory = nunitOutputDirectory, diff --git a/build.ps1 b/build.ps1 index de41982290..e7e202c1b2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -23,11 +23,7 @@ $RootDir = "${PSScriptRoot}" $ScriptFile = "${RootDir}/build.cake" $BuildDir = "${RootDir}/_build" $ToolsDir = "${BuildDir}/tools" -$PackagesDir = "${BuildDir}/lib/nuget" $NugetExe = "${ToolsDir}/NuGet/${NugetVersion}/nuget.exe" -$PackagesConfigFile = "${RootDir}/packages.config" -$CakeVersion = (Select-Xml -Xml ([xml](Get-Content $PackagesConfigFile)) -XPath "//package[@id='Cake'][1]/@version").Node.Value -$CakeExe = "${PackagesDir}/Cake.${CakeVersion}/Cake.exe" # Download NuGet $NugetDir = Split-Path "$NugetExe" -Parent @@ -42,7 +38,7 @@ if (!(Test-Path "$NugetExe")) { } # Install build packages -Invoke-Expression "& '${NugetExe}' restore `"${PackagesConfigFile}`" -OutputDirectory `"${PackagesDir}`"" +dotnet tool install --global Cake.Tool # Build args $cakeArgs = @() @@ -60,5 +56,5 @@ if ($UseExperimental) { } # Run Cake -Invoke-Expression "& '${CakeExe}' '${ScriptFile}' ${cakeArgs} ${RemainingArgs}" +dotnet cake "${ScriptFile}" ${cakeArgs} ${RemainingArgs} exit $LASTEXITCODE