Skip to content

Commit

Permalink
Modernize build system so vscode can report problems and run tests
Browse files Browse the repository at this point in the history
HebaruSan committed Nov 18, 2023
1 parent 7fe950f commit ac0966d
Showing 15 changed files with 88 additions and 59 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/_build/
/.vs/
/.vscode/
/tools
test-results
*.userprefs
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
28 changes: 2 additions & 26 deletions AutoUpdate/CKAN-autoupdate.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>CKAN-AutoUpdateHelper</AssemblyName>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' != 'Core' ">..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' == 'Core' ">..\_build\out\$(AssemblyName)\VSCodeIDE\bin\</OutputPath>
<BaseIntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
@@ -28,10 +29,6 @@
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="ILRepack" Version="2.0.18" />
<PackageReference Include="ILRepack.MSBuild.Task" Version="2.0.13" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\_build\meta\GlobalAssemblyVersionInfo.cs">
<Link>Properties\GlobalAssemblyVersionInfo.cs</Link>
@@ -48,25 +45,4 @@
<Exec Command="powershell ../build.ps1 Generate-GlobalAssemblyVersionInfo" Condition="!Exists('../_build/meta/GlobalAssemblyVersionInfo.cs') And '$(OS)' == 'Windows_NT'" />
<Exec Command="sh ../build Generate-GlobalAssemblyVersionInfo" Condition="!Exists('../_build/meta/GlobalAssemblyVersionInfo.cs') And '$(OS)' == 'Unix'" />
</Target>
<Target Name="ILRepack" AfterTargets="Build">
<ItemGroup>
<InputAssemblies Include="fr-FR\$(AssemblyName).resources.dll" />
<InputAssemblies Include="it-IT\$(AssemblyName).resources.dll" />
<InputAssemblies Include="pl-PL\$(AssemblyName).resources.dll" />
<InputAssemblies Include="pt-BR\$(AssemblyName).resources.dll" />
<InputAssemblies Include="ru-RU\$(AssemblyName).resources.dll" />
</ItemGroup>
<ILRepack OutputAssembly="AutoUpdater.exe"
MainAssembly="$(AssemblyName).exe"
InputAssemblies="@(InputAssemblies)"
OutputType="$(OutputType)"
WorkingDirectory="$(OutputPath)"
Internalize="true"
Parallel="true" />
<ItemGroup>
<Repacked Include="$(OutputPath)AutoUpdater.*" />
</ItemGroup>
<Copy SourceFiles="@(Repacked)"
DestinationFolder="..\_build\repack\$(Configuration)" />
</Target>
</Project>
3 changes: 2 additions & 1 deletion Cmdline/CKAN-cmdline.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>CKAN-CmdLine</AssemblyName>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' != 'Core' ">..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' == 'Core' ">..\_build\out\$(AssemblyName)\VSCodeIDE\bin\</OutputPath>
<BaseIntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
3 changes: 2 additions & 1 deletion ConsoleUI/CKAN-ConsoleUI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>CKAN-ConsoleUI</AssemblyName>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' != 'Core' ">..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' == 'Core' ">..\_build\out\$(AssemblyName)\VSCodeIDE\bin\</OutputPath>
<BaseIntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
3 changes: 2 additions & 1 deletion Core/CKAN-core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>CKAN</AssemblyName>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' != 'Core' ">..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' == 'Core' ">..\_build\out\$(AssemblyName)\VSCodeIDE\bin\</OutputPath>
<BaseIntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
11 changes: 10 additions & 1 deletion GUI/CKAN-GUI.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>CKAN-GUI</AssemblyName>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' != 'Core' ">..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' == 'Core' ">..\_build\out\$(AssemblyName)\VSCodeIDE\bin\</OutputPath>
<BaseIntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
@@ -22,12 +23,20 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>IDE1006</NoWarn>
<!-- dotnet build requires this and System.Resources.Extensions
to satisfy arbitrary validation checks that don't apply to us,
which helpfully break building with Mono.
https://github.com/dotnet/msbuild/issues/5787
https://stackoverflow.com/a/44966127/2422988 -->
<GenerateResourceUsePreserializedResources Condition="'$(MSBuildRuntimeType)'=='Core'">true</GenerateResourceUsePreserializedResources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="4.9.4" />
<PackageReference Include="ini-parser" Version="3.4.0" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Resources.Extensions" Version="4.6.0"
Condition="'$(MSBuildRuntimeType)'=='Core'" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
3 changes: 2 additions & 1 deletion Netkan/CKAN-netkan.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>CKAN-NetKAN</AssemblyName>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' != 'Core' ">..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' == 'Core' ">..\_build\out\$(AssemblyName)\VSCodeIDE\bin\</OutputPath>
<BaseIntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
3 changes: 2 additions & 1 deletion Tests/Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project>
<PropertyGroup>
<AssemblyName>CKAN.Tests</AssemblyName>
<OutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' !='Core' ">..\_build\out\$(AssemblyName)\$(Configuration)\bin\</OutputPath>
<OutputPath Condition=" '$(MSBuildRuntimeType)' =='Core' ">..\_build\out\$(AssemblyName)\VSCodeIDE\bin\</OutputPath>
<BaseIntermediateOutputPath>..\_build\out\$(AssemblyName)\$(Configuration)\obj\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
14 changes: 8 additions & 6 deletions build
Original file line number Diff line number Diff line change
@@ -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 $?
41 changes: 27 additions & 14 deletions build.cake
Original file line number Diff line number Diff line change
@@ -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<string, string> { { "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<DirectoryPath> { 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<DirectoryPath> { autoupdateBinDirectory.ToString() },
TargetPlatform = TargetPlatformVersion.v4
});

CopyFile(ckanFile, buildDirectory.CombineWithFilePath("ckan.exe"));
});
@@ -298,6 +310,7 @@ Task("Repack-Netkan")
new ILRepackSettings
{
Libs = new List<DirectoryPath> { 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,
8 changes: 2 additions & 6 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ac0966d

Please sign in to comment.