зеркало из https://github.com/microsoft/winsdkfb.git
Merge pull request #233 from Microsoft/build_script_refactor
Refactored build scripts
This commit is contained in:
Коммит
eb8d93da52
|
@ -1,113 +1,2 @@
|
|||
rem ---------------------------------------------------------------------------
|
||||
rem Script to build the Microsoft SDK for Facebook Integration. This script
|
||||
rem will build the Windows 8.1 and Windows Phone 8.1 versions of the SDK, then
|
||||
rem the Windows 10 Universal version, then package everything up with NuGet.
|
||||
rem
|
||||
rem On completion, the SDK packages should be located in the directory
|
||||
rem winsdkfb\bin under the root of the repository. A synopsis of the build will
|
||||
rem exist in the file sdk-build.log in the same directory as the build script.
|
||||
rem
|
||||
rem This script assumes it is located in the Git repository and location in
|
||||
rem which it originated. If it is moved, it will cease to function!
|
||||
rem ---------------------------------------------------------------------------
|
||||
|
||||
set starting_dir=%cd%
|
||||
set script_dir=%~dp0
|
||||
set logfile=%script_dir%\sdk-build.log
|
||||
cd /d %script_dir%\..
|
||||
|
||||
@echo Starting build... >%logfile%
|
||||
|
||||
rem ---------------------------------------------------------------------------
|
||||
rem build for Windows 8.1 and Phone 8.1
|
||||
rem ---------------------------------------------------------------------------
|
||||
call :build_one_flavor winsdkfb.sln Win32 Debug
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb.sln Win32 Release
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb.sln x64 Debug
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb.sln x64 Release
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb.sln ARM Debug
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb.sln ARM Release
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
rem ---------------------------------------------------------------------------
|
||||
rem build for Windows 10 Universal
|
||||
rem ---------------------------------------------------------------------------
|
||||
|
||||
call :build_one_flavor winsdkfb_uwp/winsdkfb_uwp.sln Win32 Debug
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb_uwp/winsdkfb_uwp.sln Win32 Release
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb_uwp/winsdkfb_uwp.sln x64 Debug
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb_uwp/winsdkfb_uwp.sln x64 Release
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb_uwp/winsdkfb_uwp.sln ARM Debug
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
call :build_one_flavor winsdkfb_uwp/winsdkfb_uwp.sln ARM Release
|
||||
if errorlevel 1 goto errorExit
|
||||
|
||||
rem ---------------------------------------------------------------------------
|
||||
rem build NuGet packages
|
||||
rem ---------------------------------------------------------------------------
|
||||
:build_nuget
|
||||
cd %script_dir%\nuget
|
||||
|
||||
rem Get version number, so we can test for packages after build attempt
|
||||
for /f "delims=" %%i in ('type VERSION') do set version=%%i
|
||||
|
||||
@echo Checking for nuget.exe... >>%logfile%
|
||||
if not exist nuget.exe call download-nuget.cmd
|
||||
if not exist nuget.exe (
|
||||
@echo Error: failed to download nuget.exe, can't package the SDK
|
||||
goto :eof
|
||||
)
|
||||
|
||||
@echo Packaging SDK... >>%logfile%
|
||||
|
||||
call build-nupkg.cmd
|
||||
if not exist ..\..\bin\winsdkfb.%version%.nupkg (
|
||||
@echo Error: failed to build SDK NuGet package
|
||||
goto :eof
|
||||
)
|
||||
|
||||
cd /d %starting_dir%
|
||||
@echo Build successful >>%logfile%
|
||||
@echo "All done!"
|
||||
goto :eof
|
||||
|
||||
rem ---------------------------------------------------------------------------
|
||||
rem Subroutine to build for one solution, platform, and configuration
|
||||
rem ---------------------------------------------------------------------------
|
||||
:build_one_flavor
|
||||
@echo Starting build for solution %1, platform %2, configuration %3 >>%logfile%
|
||||
msbuild %1 /p:Platform=%2;Configuration=%3
|
||||
if errorlevel 1 (
|
||||
@echo Error building solution %1, platform %2, configuration %3 >>%logfile%
|
||||
exit /b
|
||||
)
|
||||
@echo Completed build for solution %1, platform %2, configurattion %3 >>%logfile%
|
||||
exit /b
|
||||
|
||||
rem ---------------------------------------------------------------------------
|
||||
rem In case of build failure, err out here
|
||||
rem ---------------------------------------------------------------------------
|
||||
:errorExit
|
||||
@echo "Error: one or more targets failed to build."
|
||||
cd /d %starting_dir%
|
||||
goto :eof
|
||||
|
||||
powershell %~dp0\build-sdk.ps1
|
|
@ -0,0 +1,147 @@
|
|||
|
||||
# If you move this script, change this environment variable to point to the root
|
||||
# of the winsdkfb directory. Stuff will break if you don't!
|
||||
Set-Item -force -path "env:WinsdkfbRoot" -value "$PSScriptRoot\..\.."
|
||||
|
||||
#.SYNOPSIS
|
||||
# Grabs all environment variable set after vcvarsall.bat is called and pulls
|
||||
# them into the Powershell environment.
|
||||
function Set-MsbuildDevEnvironment()
|
||||
{
|
||||
$path = "$env:VS140COMNTOOLS\..\.."
|
||||
pushd $path
|
||||
cmd /c "vcvarsall.bat&set" | foreach {
|
||||
if ($_ -match "=")
|
||||
{
|
||||
$s = $_.Split("=");
|
||||
Set-Item -force -path "env:\$($s[0])" -value "$($s[1])"
|
||||
}
|
||||
}
|
||||
popd
|
||||
Write-Host "Dev environment variables set" -ForegroundColor Green
|
||||
}
|
||||
|
||||
#.SYNOPSIS
|
||||
# Downloads the latest version of nuget.exe.
|
||||
#
|
||||
#.PARAMETER $DownloadTargetDir
|
||||
# The directory to place nuget.exe in.
|
||||
function Get-Nuget()
|
||||
{
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[parameter(Mandatory=$true)]
|
||||
[string]$DownloadTargetDir
|
||||
)
|
||||
|
||||
$NugetDownloadUrl = 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe'
|
||||
$Downloader = New-Object System.Net.WebClient
|
||||
$Downloader.DownloadFile($NugetDownloadUrl, "$DownloadTargetDir\nuget.exe")
|
||||
}
|
||||
|
||||
#.SYNOPSIS
|
||||
# Ensures that the build tools required can be found on the system.
|
||||
function Test-BuildToolsPresent()
|
||||
{
|
||||
Set-MsbuildDevEnvironment
|
||||
if ((Get-Command "msbuild.exe" -ErrorAction SilentlyContinue) -eq $null)
|
||||
{
|
||||
Throw "msbuild.exe is not present in path"
|
||||
}
|
||||
if ((Get-Command "nuget.exe" -ErrorAction SilentlyContinue) -eq $null)
|
||||
{
|
||||
$NugetTargetDir = "$env:WinsdkfbRoot\winsdkfb\build\nuget"
|
||||
if (-not (Test-Path "$NugetTargetDir\nuget.exe"))
|
||||
{
|
||||
Write-Host "downloading latest nuget.exe..."
|
||||
Get-Nuget -DownloadTargetDir $NugetTargetDir
|
||||
}
|
||||
$env:Path += ";$NugetTargetDir;"
|
||||
}
|
||||
if ((Get-Command "TextTransform.exe" -ErrorAction SilentlyContinue) -eq $null)
|
||||
{
|
||||
$TextTemplateDir = "${env:CommonProgramFiles(x86)}\Microsoft Shared\TextTemplating\14.0"
|
||||
if (Test-Path "$TextTemplateDir\TextTransform.exe")
|
||||
{
|
||||
$env:Path += ";$TextTemplateDir;"
|
||||
}
|
||||
else
|
||||
{
|
||||
Throw "TextTransform.exe cannot be found."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#.SYNOPSIS
|
||||
# Builds a winsdkfb solution.
|
||||
#
|
||||
#.PARAMETER $SolutionName
|
||||
# The path to the solution to build.
|
||||
#
|
||||
#.PARAMETER $Platform
|
||||
# The platform to target. May be Win32, x64, ARM.
|
||||
#
|
||||
#.PARAMETER $Configuration
|
||||
# The configuration to target. May be Debug, Release.
|
||||
function Invoke-OpenConsoleBuild()
|
||||
{
|
||||
[CmdletBinding()]
|
||||
Param (
|
||||
[parameter(Mandatory=$true)]
|
||||
[string]$SolutionName,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[string]$Platform,
|
||||
|
||||
[parameter(Mandatory=$true)]
|
||||
[string]$Configuration
|
||||
)
|
||||
|
||||
Write-Host "building $SolutionName,$Platform,$Configuration"
|
||||
nuget.exe restore $SolutionName
|
||||
if (-not $?)
|
||||
{
|
||||
Throw "nuget restore failed"
|
||||
}
|
||||
msbuild.exe $SolutionName /p:Platform=$Platform /p:Configuration=$Configuration
|
||||
if (-not $?)
|
||||
{
|
||||
Throw "building $SolutionName,$Platform,$Configuration failed"
|
||||
}
|
||||
}
|
||||
|
||||
#.SYNOPSIS
|
||||
# Creates a winsdkfb nuget package.
|
||||
function Invoke-NugetPackage()
|
||||
{
|
||||
# set version number
|
||||
$Version = (Get-Content $env:winsdkfbRoot\winsdkfb\build\nuget\VERSION).ToString()
|
||||
$env:version = $Version
|
||||
# build-nupkg.cmd requires that the current working directory is the
|
||||
# directory that it sits in because it uses relative paths.
|
||||
pushd $env:winsdkfbRoot\winsdkfb\build\nuget
|
||||
& $env:WinsdkfbRoot\winsdkfb\build\nuget\build-nupkg.cmd
|
||||
if (-not (Test-Path "$env:WinsdkfbRoot\winsdkfb\bin\winsdkfb.${Version}.nupkg"))
|
||||
{
|
||||
popd
|
||||
Throw "Failed to build SDK NuGet package"
|
||||
}
|
||||
popd
|
||||
}
|
||||
|
||||
# main
|
||||
Test-BuildToolsPresent
|
||||
$SolutionFiles = @("$env:WinsdkfbRoot\winsdkfb\winsdkfb.sln", "$env:winsdkfbRoot\winsdkfb\winsdkfb_uwp\winsdkfb_uwp.sln")
|
||||
$Platforms = @("Win32", "x64", "ARM")
|
||||
$Configurations = @("Debug", "Release")
|
||||
foreach ($Solution in $SolutionFiles)
|
||||
{
|
||||
foreach ($Platform in $Platforms)
|
||||
{
|
||||
foreach ($Configuration in $Configurations)
|
||||
{
|
||||
Invoke-OpenConsoleBuild -SolutionName $Solution -Platform $Platform -Configuration $Configuration
|
||||
}
|
||||
}
|
||||
}
|
||||
Invoke-NugetPackage
|
|
@ -1 +1 @@
|
|||
powershell -command "(New-Object System.Net.WebClient).DownloadFile('http://nuget.org/nuget.exe', '%~pd0nuget.exe')"
|
||||
powershell -command "(New-Object System.Net.WebClient).DownloadFile('https://dist.nuget.org/win-x86-commandline/latest/nuget.exe', '%~pd0nuget.exe')"
|
||||
|
|
Двоичные данные
winsdkfb/build/nuget/nuget.exe
Двоичные данные
winsdkfb/build/nuget/nuget.exe
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче