mirror of
https://github.com/zoriya/octokit.net.git
synced 2025-12-06 07:16:09 +00:00
Migrate dotnetcore to vs2017 tooling (#1567)
* convert to VS2017 * rework cake.frosting build to latest cake vs2017 "template" example * fix clean task and version suffix * add arg to DotNetCorePack so it uses the correct version * fix appveyor * is there an easier way to test appveyor? * ok travis, let's do this * after reading the travis repo, this seems to be the version we want for vs201/csproj tool support * msbuild complaining about arguments - we can use defaults anyhow so remove $@ from build.sh script * add workaround for msbuild/travis, as mentioned on aspnet Mvc repo * cmon travis * perhaps tee isnt needed afterall * travis permission denied when trying to install tools in build script... i feel dirty but need to see if sudo will fix it! * could it be folder permissions of /build ? * Try 777 for NuGet.exe permissions rather than 644 * remove windows platform restriction on GitVersion call * Add a wrapper script for GitVersion on non windows * fix wrapper script name * add debug * let's see if we are running the script at all! * run mono gitversion direclty from travis.yml, for science * see if we can run bin/sh and prepend an argument to our shell script * remove echos from wrapper script * Ensure full git repo include more than 50 commits and all tags are fetched, as GitVersion was failing on TravisCI * only build netstandard framework on non windows * revert overriding the target framework when building the solution * Unix being case-sensitive, adjust app.config file name in csproj files * set FrameworkPathOverride to point to different folders on macOS and Linux * Remove NuGet.exe from the repo. On Windows, it will be installed by the Frosting bootstrapper script. On Unix/macOS, cake has smarts to look for mono- and Linux-specific executables * tidy up GitVersion logic into a GitVersionRunner class * apply workaround for osx dotnet restore "too many open files" errors * update test project references to latest official versions * doesnt seem to be a reason for overriding the implicit reference * remove extra whitespace and unused namespace
This commit is contained in:
119
build.ps1
Normal file
119
build.ps1
Normal file
@@ -0,0 +1,119 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
This is a Powershell script to bootstrap a Cake.Frosting build.
|
||||
.DESCRIPTION
|
||||
This Powershell script will download NuGet if missing, restore NuGet tools (including Cake)
|
||||
and execute your Cake build script with the parameters you provide.
|
||||
.PARAMETER Target
|
||||
The build script target to run.
|
||||
.PARAMETER Configuration
|
||||
The build configuration to use.
|
||||
.PARAMETER Verbosity
|
||||
Specifies the amount of information to be displayed.
|
||||
.PARAMETER WhatIf
|
||||
Performs a dry run of the build script.
|
||||
No tasks will be executed.
|
||||
.PARAMETER ScriptArgs
|
||||
Remaining arguments are added here.
|
||||
.LINK
|
||||
https://github.com/cake-build/frosting
|
||||
#>
|
||||
|
||||
[CmdletBinding()]
|
||||
Param(
|
||||
[string]$Target = "Default",
|
||||
[ValidateSet("Release", "Debug")]
|
||||
[string]$Configuration = "Release",
|
||||
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
|
||||
[string]$Verbosity = "Verbose",
|
||||
[switch]$WhatIf,
|
||||
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
|
||||
[string[]]$ScriptArgs
|
||||
)
|
||||
|
||||
$DotNetChannel = "preview";
|
||||
$DotNetVersion = "1.0.1";
|
||||
$DotNetInstallerUri = "https://raw.githubusercontent.com/dotnet/cli/rel/1.0.1/scripts/obtain/dotnet-install.ps1";
|
||||
$NugetUrl = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
|
||||
|
||||
# Make sure tools folder exists
|
||||
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
|
||||
$ToolPath = Join-Path $PSScriptRoot "tools"
|
||||
if (!(Test-Path $ToolPath)) {
|
||||
Write-Verbose "Creating tools directory..."
|
||||
New-Item -Path $ToolPath -Type directory | out-null
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
# INSTALL .NET CORE CLI
|
||||
###########################################################################
|
||||
|
||||
Function Remove-PathVariable([string]$VariableToRemove)
|
||||
{
|
||||
$path = [Environment]::GetEnvironmentVariable("PATH", "User")
|
||||
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
|
||||
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "User")
|
||||
$path = [Environment]::GetEnvironmentVariable("PATH", "Process")
|
||||
$newItems = $path.Split(';') | Where-Object { $_.ToString() -inotlike $VariableToRemove }
|
||||
[Environment]::SetEnvironmentVariable("PATH", [System.String]::Join(';', $newItems), "Process")
|
||||
}
|
||||
|
||||
# Get .NET Core CLI path if installed.
|
||||
$FoundDotNetCliVersion = $null;
|
||||
if (Get-Command dotnet -ErrorAction SilentlyContinue) {
|
||||
$FoundDotNetCliVersion = dotnet --version;
|
||||
}
|
||||
|
||||
if($FoundDotNetCliVersion -ne $DotNetVersion) {
|
||||
$InstallPath = Join-Path $PSScriptRoot ".dotnet"
|
||||
if (!(Test-Path $InstallPath)) {
|
||||
mkdir -Force $InstallPath | Out-Null;
|
||||
}
|
||||
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallerUri, "$InstallPath\dotnet-install.ps1");
|
||||
& $InstallPath\dotnet-install.ps1 -Channel $DotNetChannel -Version $DotNetVersion -InstallDir $InstallPath;
|
||||
|
||||
Remove-PathVariable "$InstallPath"
|
||||
$env:PATH = "$InstallPath;$env:PATH"
|
||||
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
|
||||
$env:DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
# INSTALL NUGET
|
||||
###########################################################################
|
||||
|
||||
# Make sure nuget.exe exists.
|
||||
$NugetPath = Join-Path $ToolPath "nuget.exe"
|
||||
if (!(Test-Path $NugetPath)) {
|
||||
Write-Host "Downloading NuGet.exe..."
|
||||
(New-Object System.Net.WebClient).DownloadFile($NugetUrl, $NugetPath);
|
||||
}
|
||||
|
||||
###########################################################################
|
||||
# RUN BUILD SCRIPT
|
||||
###########################################################################
|
||||
|
||||
# Build the argument list.
|
||||
$Arguments = @{
|
||||
target=$Target;
|
||||
configuration=$Configuration;
|
||||
verbosity=$Verbosity;
|
||||
dryrun=$WhatIf;
|
||||
}.GetEnumerator() | %{"--{0}=`"{1}`"" -f $_.key, $_.value };
|
||||
|
||||
# Start Cake
|
||||
Push-Location
|
||||
Set-Location build
|
||||
Write-Host "Restoring packages..."
|
||||
Invoke-Expression "dotnet restore"
|
||||
if($LASTEXITCODE -ne 0) {
|
||||
Pop-Location;
|
||||
exit $LASTEXITCODE;
|
||||
}
|
||||
Write-Host "Running build..."
|
||||
Invoke-Expression "dotnet run -- $Arguments"
|
||||
if($LASTEXITCODE -ne 0) {
|
||||
Pop-Location;
|
||||
exit $LASTEXITCODE;
|
||||
}
|
||||
Pop-Location
|
||||
Reference in New Issue
Block a user