Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
Build solution files
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate McMaster committed Feb 9, 2017
1 parent f57e6fc commit 4778c94
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 301 deletions.
35 changes: 18 additions & 17 deletions build/KoreBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

param([parameter(ValueFromRemainingArguments=$true)][string[]] $allparams)

function exec($cmd) {
$cmdName = [IO.Path]::GetFileName($cmd)
Write-Host -ForegroundColor Cyan "> $cmdName $args"
& $cmd @args
$exitCode = $LASTEXITCODE
if($exitCode -ne 0) {
throw "'$cmdName $args' failed with exit code: $exitCode"
}
}

$repoFolder = $env:REPO_FOLDER
if (!$repoFolder) {
throw "REPO_FOLDER is not set"
Expand Down Expand Up @@ -85,42 +95,33 @@ if (!($env:Path.Split(';') -icontains $dotnetLocalInstallFolder))
$sharedPath = (Join-Path (Split-Path ((get-command dotnet.exe).Path) -Parent) "shared");
(Get-ChildItem $sharedPath -Recurse *dotnet.exe) | %{ $_.FullName } | Remove-Item;

if (!(Test-Path "$koreBuildFolder\Sake"))
{
$toolsProject = "$koreBuildFolder\tools.proj"
&dotnet restore "$toolsProject" --packages "$PSScriptRoot" -v Minimal
# We still nuget because dotnet doesn't have support for pushing packages
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/v3.5.0-beta2/NuGet.exe" -OutFile "$koreBuildFolder/nuget.exe"
}
# We still nuget because dotnet doesn't have support for pushing packages
# TODO remove. dotnet nuget push now exists
Invoke-WebRequest "https://dist.nuget.org/win-x86-commandline/v4.0.0-rc3/NuGet.exe" -OutFile "$koreBuildFolder/nuget.exe"

$env:KOREBUILD_FOLDER=$koreBuildFolder
$makeFileProj = "$koreBuildFolder/targets/makefile.proj"
$makeFileProj = "$koreBuildFolder/makefile.proj"
exec dotnet restore "$makeFileProj"

$msbuildArtifactsDir = "$repoFolder/artifacts/msbuild"
$msbuildLogFilePath = "$msbuildArtifactsDir/msbuild.log"
$msBuildResponseFile = "$msbuildArtifactsDir/msbuild.rsp"

if ($allparams)
{
$targets += "/t:$($allparams.Replace(' ', ';'))"
}

$msBuildArguments = @"
/nologo
/m
/detailedsummary
"$makeFileProj"
/p:KoreBuildDirectory="$koreBuildFolder/"
/p:RepositoryRoot="$repoFolder/"
/fl
/flp:LogFile="$msbuildLogFilePath";Verbosity=diagnostic;Encoding=UTF-8
$targets
/p:SakeTargets=$($allparams -replace ' ',':')
"@


if (!(Test-Path $msbuildArtifactsDir))
{
mkdir $msbuildArtifactsDir | Out-Null
}
$msBuildArguments | Out-File -Encoding ASCII -FilePath $msBuildResponseFile

dotnet msbuild `@"$msBuildResponseFile"
exec dotnet build `@"$msBuildResponseFile"
53 changes: 34 additions & 19 deletions build/KoreBuild.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
#!/usr/bin/env bash

# Colors
GREEN="\033[1;32m"
CYAN="\033[0;36m"
RESET="\033[0m"
RED="\033[0;31m"

# functions

__exec() {
local cmd=$1
shift

local cmdname=$(basename $cmd)
echo -e "${CYAN}> $cmdname $@${RESET}"
$cmd "$@"

local exitCode=$?
if [ $exitCode -ne 0 ]; then
echo -e "${RED}'$cmdname $@' failed with exit code $exitCode${RESET}" 1>&2
exit $exitCode
fi
}

targets=""
repoFolder=""
while [[ $# > 0 ]]; do
Expand All @@ -10,9 +33,9 @@ while [[ $# > 0 ]]; do
;;
*)
if [ -z "$targets" ]; then
targets="/t:$1"
targets="$1"
else
targets+=";$1"
targets+=":$1"
fi
;;
esac
Expand Down Expand Up @@ -96,28 +119,22 @@ if [ "$(uname)" == "Darwin" ]; then
fi

netfxversion='4.6.1'
netFrameworkFolder=$repoFolder/$koreBuildFolder/netframeworkreferenceassemblies
netFrameworkContentDir=$netFrameworkFolder/$netfxversion/content
sakeFolder=$koreBuildFolder/sake
if [ ! -d $sakeFolder ]; then
toolsProject="$koreBuildFolder/tools.proj"
dotnet restore "$toolsProject" --packages $scriptRoot -v Minimal "/p:NetFxVersion=$netfxversion"
# Rename the project after restore because we don't want it to be restore afterwards
mv "$toolsProject" "$toolsProject.norestore"
if [ "$NUGET_PACKAGES" == "" ]; then
NUGET_PACKAGES="$HOME/.nuget/packages"
fi

export ReferenceAssemblyRoot=$netFrameworkContentDir
export ReferenceAssemblyRoot=$NUGET_PACKAGES/netframeworkreferenceassemblies/$netfxversion/content

nugetPath="$koreBuildFolder/nuget.exe"
if [ ! -f $nugetPath ]; then
nugetUrl="https://dist.nuget.org/win-x86-commandline/v3.5.0-beta2/NuGet.exe"
nugetUrl="https://dist.nuget.org/win-x86-commandline/v4.0.0-rc3/NuGet.exe"
wget -O $nugetPath $nugetUrl 2>/dev/null || curl -o $nugetPath --location $nugetUrl 2>/dev/null
fi

export KOREBUILD_FOLDER="$koreBuildFolder"
makeFileProj="$koreBuildFolder/makefile.proj"

__exec dotnet restore "$makeFileProj" "/p:NetFxVersion=$netfxversion"

makeFileProj="$koreBuildFolder/targets/makefile.proj"
msbuildArtifactsDir="$repoFolder/artifacts/msbuild"
msbuildResponseFile="$msbuildArtifactsDir/msbuild.rsp"
msbuildLogFile="$msbuildArtifactsDir/msbuild.log"
Expand All @@ -129,13 +146,11 @@ fi
cat > $msbuildResponseFile <<ENDMSBUILDARGS
/nologo
/m
/detailedsummary
"$makeFileProj"
/p:KoreBuildDirectory="$koreBuildFolder/"
/p:RepositoryRoot="$repoFolder/"
/fl
-flp:LogFile="$msbuildLogFile";Verbosity=diagnostic;Encoding=UTF-8
$targets
/flp:LogFile="$msbuildLogFile";Verbosity=diagnostic;Encoding=UTF-8
/p:SakeTargets=$targets
ENDMSBUILDARGS

dotnet msbuild @"$msbuildResponseFile"
__exec dotnet msbuild @"$msbuildResponseFile"
2 changes: 1 addition & 1 deletion build/cli.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0-rc4-004757
1.0.0-rc4-004777
4 changes: 0 additions & 4 deletions build/contentFiles/cs/any/AssemblyInfo.Serviceable.cs

This file was deleted.

36 changes: 36 additions & 0 deletions build/makefile.proj
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<Project>
<PropertyGroup>
<LifecycleType>Legacy</LifecycleType>
<!-- TFM used only for the purpose of restoring build tools. It does not affect the TFM of projects -->
<TargetFramework>netcoreapp1.0</TargetFramework>
<SakeVersion>0.2.2</SakeVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="NETFrameworkReferenceAssemblies" Version="$(NetFxVersion)" Condition="'$(NetFxVersion)'!=''" />
<PackageReference Include="NuGetPackageVerifier" Version="1.0.2-*"/>
<PackageReference Include="Sake" Version="$(SakeVersion)" />
</ItemGroup>

<Import Project="$(MSBuildThisFileDirectory)\targets\common.props" />

<ItemGroup>
<Solutions Include="$(RepositoryRoot)\*.sln" />
</ItemGroup>

<!-- import Microsoft.Common targets which will import NuGet-->
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />

<!-- undo some special Microsoft.Common properties since this isn't a normal project -->
<PropertyGroup>
<_InvalidConfigurationWarn>false</_InvalidConfigurationWarn>
<_InvalidConfigurationError>false</_InvalidConfigurationError>
</PropertyGroup>

<Import Project="$(RepositoryRoot)build\repo.props" Condition="Exists('$(RepositoryRoot)build\repo.props')" />

<Import Project="$(MSBuildThisFileDirectory)\targets\legacy-lifecycle.targets" Condition="'$(LifecycleType)'=='Legacy'" />
<Import Project="$(MSBuildThisFileDirectory)\targets\standard-lifecycle.targets" Condition="'$(LifecycleType)'=='Standard'" />

<Import Project="$(RepositoryRoot)build\repo.targets" Condition="Exists('$(RepositoryRoot)build\repo.targets')" />
</Project>
10 changes: 0 additions & 10 deletions build/restore.proj

This file was deleted.

81 changes: 17 additions & 64 deletions build/shade/_k-standard-goals.shade
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,8 @@ use-ci-loggers
default BASE_DIR='${Directory.GetCurrentDirectory()}'
default TARGET_DIR='${Path.Combine(BASE_DIR, "artifacts")}'
default BUILD_DIR='${Path.Combine(TARGET_DIR, "build")}'
default TEST_DIR='${Path.Combine(TARGET_DIR, "test")}'
default Configuration='${E("Configuration")}'
default PACKAGELIST_JSON_FILENAME = 'NuGetPackageVerifier.json'
default SRC_PROJECT_GLOB = "src/*/*.csproj"
default TEST_PROJECT_GLOB = "test/*/*.csproj"
default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"

@{
if (string.IsNullOrEmpty(E("BuildNumber")))
Expand All @@ -32,6 +28,18 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"
}
}

functions
@{
// convenince method as we incrementally move to MSBuild standard lifecycle
void MSBuild(string arguments)
{
Dotnet("msbuild /nologo"
+ " \"" + Path.Combine(Directory.GetCurrentDirectory(), ".build/makefile.proj") + "\""
+ " \"/p:LifecycleType=Standard;Configuration=" + E("Configuration") + "\""
+ " " + arguments);
}
}

#--for-ci
@{
Configuration = "Release";
Expand Down Expand Up @@ -76,15 +84,10 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"
-// Target order is important because clean-npm-modules may (re)create bin folder.
#deep-clean .clean-npm-modules .clean-bin-folder description='Clean folders that may cause problems for `git clean`.'

#repo-initialize target='initialize'
#repo-initialize target='initialize' if='!NoRestore'
use-volatile-feed
-//dotnet-restore if='!NoRestore'
@{
// workaround https://github.com/Microsoft/msbuild/issues/1587
if (!NoRestore)
{
Dotnet("msbuild \"" + Path.Combine(BASE_DIR, ".build/restore.proj") + "\"");
}
MSBuild("/t:Restore");
}

#target-dir-clean target='clean'
Expand Down Expand Up @@ -114,57 +117,15 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"

#build-compile target='compile'
@{
var projectGlobs = new List<string>();
List<string> srcProjects = null;

if (Directory.Exists("src"))
{
Directory.CreateDirectory(TARGET_DIR);
srcProjects = Files.Include(SRC_PROJECT_GLOB).ToList();
projectGlobs.AddRange(srcProjects);
}

if (!BuildSrcOnly && Directory.Exists("test"))
{
projectGlobs.AddRange(Files.Include(TEST_PROJECT_GLOB).ToList());
}

if (!BuildSrcOnly && Directory.Exists("samples"))
{
projectGlobs.AddRange(Files.Include(SAMPLES_PROJECT_GLOB).ToList());
}

if (projectGlobs.Any())
{
foreach (var project in projectGlobs)
{
DotnetBuild(project, Configuration, BuildFramework);
}
}
MSBuild("/t:Rebuild");
}

#run-api-check .build-compile target='compile' description='Checks the compiled assemblies against a baseline for potential breaking changes'
api-check

#build-pack .build-compile target='compile'
@{
if (Directory.Exists("src"))
{
Directory.CreateDirectory(BUILD_DIR);
var srcProjects = Files.Include(SRC_PROJECT_GLOB).ToList();
if (srcProjects != null && srcProjects.Count > 0)
{
srcProjects.ForEach(projectFile =>
{
DotnetPack(projectFile, BUILD_DIR, Configuration, E("KOREBUILD_DOTNET_PACK_OPTIONS") + " --no-build");
});

foreach (var nupkg in Files.Include(Path.Combine(BUILD_DIR, "*/" + Configuration + "/*.nupkg")))
{
File.Copy(nupkg, Path.Combine(BUILD_DIR, Path.GetFileName(nupkg)), true);
}
}
}
MSBuild("/t:Pack");
}

#native-compile target='compile' if='!IsLinux && Directory.Exists(Path.Combine(BASE_DIR, "src"))'
Expand Down Expand Up @@ -210,15 +171,7 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"

#nuget-verify target='package' description='Verify if all the packages are generated properly'
@{
if (Directory.Exists("src") && File.Exists(PACKAGELIST_JSON_FILENAME))
{
var verifierDirectory = Directory.EnumerateDirectories(Path.Combine(KoreBuildFolderPath, "nugetpackageverifier")).First();
Dotnet(
string.Format("\"{0}\" \"{1}\" \"{2}\"",
Path.Combine(verifierDirectory, "NuGetPackageVerifier.dll"),
BUILD_DIR.TrimEnd(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }),
Path.Combine(BASE_DIR, PACKAGELIST_JSON_FILENAME)));
}
MSBuild("/t:VerifyPackages");
}

#nuget-install target='install' description='Install NuGet packages to local repo'
Expand Down
5 changes: 3 additions & 2 deletions build/targets/common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>
<PropertyGroup>
<BuildDir>$(RepositoryRoot)\build</BuildDir>
<ArtifactsDir>$(BuildDir)\artifacts</ArtifactsDir>
<RepositoryRoot Condition="'$(RepositoryRoot)'==''">$(MSBuildThisFileDirectory)..\..\</RepositoryRoot>
<ArtifactsDir>$(RepositoryRoot)artifacts\</ArtifactsDir>
<BuildDir>$(ArtifactsDir)build\</BuildDir>
</PropertyGroup>
</Project>
Loading

0 comments on commit 4778c94

Please sign in to comment.