Skip to content

Commit

Permalink
⚰️Remove checked-in tools requiring Git LFS (#1052)
Browse files Browse the repository at this point in the history
GitHub currently charges $5 / month due to high bandwidth of downloading
tools, of which most tools are not even used except NuGet.exe.

Also, checkout requires everyone to have Git LFS plugin installed.

### Changes
- Delete checked in Tools folder
- Download NuGet.exe in `init.ps1` script to new `.tools` folder
- Change `dotnet tool install` to use `.tools` folder
- Ignore `.tools` folder in Git
- Update init/build/clean scripts to use NuGet.exe in new location

---------

Co-authored-by: Andreas Gullberg Larsen <[email protected]>
  • Loading branch information
tmilnthorp and angularsen authored Jul 11, 2023
1 parent 9f6c315 commit 43b2c07
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 617 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,4 @@ Artifacts

# Build server tooling
/secure-file
/Tools/reportgenerator.exe
/Tools/.store/
/Tools/Temp
/.tools/
28 changes: 13 additions & 15 deletions Build/build-functions.psm1
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
$root = "$PSScriptRoot\.."
$root = (Resolve-Path "$PSScriptRoot\..").Path
$artifactsDir = "$root\Artifacts"
$nugetOutDir = "$root\Artifacts\NuGet"
$logsDir = "$root\Artifacts\Logs"
$testReportDir = "$root\Artifacts\TestResults"
$testCoverageDir = "$root\Artifacts\Coverage"
$nuget = "$root\Tools\NuGet.exe"
$nugetOutDir = "$artifactsDir\NuGet"
$logsDir = "$artifactsDir\Logs"
$testReportDir = "$artifactsDir\TestResults"
$testCoverageDir = "$artifactsDir\Coverage"
$toolsDir = "$root\.tools"

$nuget = "$toolsDir\NuGet.exe"
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$msbuildPath = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath

if ($msbuildPath) {
$msbuild = join-path $msbuildPath 'MSBuild\Current\Bin\MSBuild.exe'
$msbuildx64 = join-path $msbuildPath 'MSBuild\Current\Bin\amd64\MSBuild.exe'
}

Expand All @@ -34,11 +36,7 @@ function Start-Build([boolean] $IncludeNanoFramework = $false) {

$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$logsDir\UnitsNet.msbuild.log"

$appVeyorLoggerDll = "C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
$appVeyorLoggerNetCoreDll = "C:\Program Files\AppVeyor\BuildAgent\dotnetcore\Appveyor.MSBuildLogger.dll"
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerNetCoreDll") { "/logger:$appVeyorLoggerNetCoreDll" } else { "" }

dotnet build --configuration Release /p:ContinuousIntegrationBuild=true "$root\UnitsNet.sln" $fileLoggerArg $appVeyorLoggerArg
dotnet build --configuration Release /p:ContinuousIntegrationBuild=true "$root\UnitsNet.sln" $fileLoggerArg
if ($lastexitcode -ne 0) { exit 1 }

if (-not $IncludeNanoFramework)
Expand All @@ -49,12 +47,12 @@ function Start-Build([boolean] $IncludeNanoFramework = $false) {
{
write-host -foreground green "Build .NET nanoFramework."
$fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$logsDir\UnitsNet.NanoFramework.msbuild.log"
$appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerDll") { "/logger:$appVeyorLoggerDll" } else { "" }

# msbuild does not auto-restore nugets for this project type
& "$nuget" restore "$root\UnitsNet.NanoFramework\GeneratedCode\UnitsNet.nanoFramework.sln"

# now build
& "$msbuildx64" "$root\UnitsNet.NanoFramework\GeneratedCode\UnitsNet.nanoFramework.sln" /verbosity:minimal /p:Configuration=Release /p:Platform="Any CPU" /p:ContinuousIntegrationBuild=true $fileLoggerArg $appVeyorLoggerArg
& "$msbuildx64" "$root\UnitsNet.NanoFramework\GeneratedCode\UnitsNet.nanoFramework.sln" /verbosity:minimal /p:Configuration=Release /p:Platform="Any CPU" /p:ContinuousIntegrationBuild=true $fileLoggerArg
if ($lastexitcode -ne 0) { exit 1 }
}

Expand Down Expand Up @@ -95,7 +93,7 @@ function Start-Tests {
}

# Generate a summarized code coverage report for all test projects
& "Tools/reportgenerator.exe" -reports:"$root/Artifacts/Coverage/*.coverage.xml" -targetdir:"$root/Artifacts/Coverage" -reporttypes:HtmlSummary
& "$toolsDir/reportgenerator.exe" -reports:"$testCoverageDir/*.coverage.xml" -targetdir:"$testCoverageDir" -reporttypes:HtmlSummary

write-host -foreground blue "Run tests...END`n"
}
Expand Down
5 changes: 3 additions & 2 deletions Build/build-pack-nano-nugets.psm1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$root = "$PSScriptRoot\.."
$root = (Resolve-Path "$PSScriptRoot\..").Path
$nugetOutDir = "$root\Artifacts\NuGet"
$nuget = "$root\Tools\NuGet.exe"
$toolsDir = "$root\.tools"
$nuget = "$toolsDir\NuGet.exe"

function Invoke-BuildNanoNugets {

Expand Down
15 changes: 12 additions & 3 deletions Build/clean.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Don't allow using undeclared variables
Set-Strictmode -version latest

$root = "$PSScriptRoot\.."
$root = (Resolve-Path "$PSScriptRoot\..").Path
$artifactsDir = "$root\Artifacts"
$toolsDir = "$root\.tools"

Write-Host -Foreground Blue "Delete .tools"
Remove-Item -Recurse -Force -ErrorAction Ignore "$toolsDir"

Write-Host -Foreground Blue "Delete Artifacts"
Remove-Item -Recurse -Force -ErrorAction Ignore "$artifactsDir"

Write-Host -Foreground Blue "Delete dirs: bin, obj"

[int]$deleteCount = 0
Expand All @@ -20,8 +29,8 @@ if ($failedToDeleteDirs) {
$failCount = $failedToDeleteDirs.Count
Write-Host ""
Write-Host -Foreground Red "Failed to delete $failCount dirs:"
$failedToDeleteDirs | %{
$failedToDeleteDirs | %{
Write-Host -Foreground Red $_.FullName
}
exit /B 1
}
}
22 changes: 16 additions & 6 deletions Build/init.ps1
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
# Don't allow using undeclared variables
Set-Strictmode -version latest

$root = "$PSScriptRoot\.."
$root = (Resolve-Path "$PSScriptRoot\..").Path
$nugetPath = "$root/.tools/NuGet.exe"

Write-Host -Foreground Blue "Initializing..."

# Ensure temp dir exists
$tempDir = "$root/Tools/Temp"
$tempDir = "$root/.tools/temp_init"
[system.io.Directory]::CreateDirectory($tempDir) | out-null

if (-not (Test-Path "$root/Tools/reportgenerator.exe")) {
Write-Host -Foreground Blue "Download dotnet-reportgenerator-globaltool..."
dotnet tool install dotnet-reportgenerator-globaltool --tool-path Tools
Write-Host -Foreground Green "Download dotnet-reportgenerator-globaltool...OK."
# Report generator for unit test coverage reports.
if (-not (Test-Path "$root/.tools/reportgenerator.exe")) {
Write-Host -Foreground Blue "Install dotnet-reportgenerator-globaltool..."
dotnet tool install dotnet-reportgenerator-globaltool --tool-path .tools
Write-Host -Foreground Green "✅ Installed dotnet-reportgenerator-globaltool"
}

# NuGet.exe for non-SDK style projects, like UnitsNet.nanoFramework.
if (-not (Test-Path "$nugetPath")) {
Write-Host -Foreground Blue "Downloading NuGet.exe..."
Invoke-WebRequest -Uri https://dist.nuget.org/win-x86-commandline/latest/nuget.exe -OutFile $nugetPath
Write-Host -Foreground Green "✅ Downloaded NuGet.exe: $nugetPath"
}

###################################################
Expand Down
4 changes: 2 additions & 2 deletions CodeGen/Generators/NanoFrameworkGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static bool UpdateNanoFrameworkDependencies(
{
StartInfo = new ProcessStartInfo
{
FileName = Path.Combine(rootDir, "Tools/nuget.exe"),
FileName = Path.Combine(rootDir, ".tools/nuget.exe"),
Arguments = $"restore {path}\\UnitsNet.nanoFramework.sln",
UseShellExecute = false,
CreateNoWindow = true,
Expand Down Expand Up @@ -188,7 +188,7 @@ public static bool UpdateNanoFrameworkDependencies(
{
StartInfo = new ProcessStartInfo
{
FileName = Path.Combine(rootDir, "Tools/nuget.exe"),
FileName = Path.Combine(rootDir, ".tools/NuGet.exe"),
Arguments = $"update {path}\\UnitsNet.nanoFramework.sln -PreRelease",
UseShellExecute = false,
CreateNoWindow = true,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ Read the wiki on [Serializing to JSON, XML and more](https://github.com/angulars
### Continuous Integration

[AppVeyor](https://ci.appveyor.com/project/angularsen/unitsnet) performs the following:
[Azure DevOps](https://dev.azure.com/unitsnet/Units.NET/) performs the following:
* Build and test all branches
* Build and test pull requests, notifies on success or error
* Deploy nugets on master branch, if nuspec versions changed
Expand Down
Binary file removed Tools/7-zip/7-zip.chm
Binary file not shown.
3 changes: 0 additions & 3 deletions Tools/7-zip/7za.exe

This file was deleted.

Loading

0 comments on commit 43b2c07

Please sign in to comment.