зеркало из https://github.com/aspnet/KoreBuild.git
Merge branch 'dev' into feature/msbuild
This commit is contained in:
Коммит
87a5f7f557
|
@ -0,0 +1,37 @@
|
||||||
|
build2/Tools
|
||||||
|
project.lock.json
|
||||||
|
|
||||||
|
[Oo]bj/
|
||||||
|
[Bb]in/
|
||||||
|
TestResults/
|
||||||
|
.nuget/
|
||||||
|
_ReSharper.*/
|
||||||
|
packages/
|
||||||
|
artifacts/
|
||||||
|
PublishProfiles/
|
||||||
|
*.user
|
||||||
|
*.suo
|
||||||
|
*.cache
|
||||||
|
*.docstates
|
||||||
|
_ReSharper.*
|
||||||
|
nuget.exe
|
||||||
|
*net45.csproj
|
||||||
|
*net451.csproj
|
||||||
|
*k10.csproj
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.pidb
|
||||||
|
*.userprefs
|
||||||
|
*DS_Store
|
||||||
|
*.ncrunchsolution
|
||||||
|
*.*sdf
|
||||||
|
*.ipch
|
||||||
|
*.sln.ide
|
||||||
|
project.lock.json
|
||||||
|
.vs
|
||||||
|
.build/
|
||||||
|
.testPublish/
|
||||||
|
|
||||||
|
# Korebuild logs
|
||||||
|
korebuild.msbuild.log
|
||||||
|
korebuild.log
|
|
@ -0,0 +1,32 @@
|
||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 14
|
||||||
|
VisualStudioVersion = 14.0.25123.0
|
||||||
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D699E09D-B449-4972-BD19-EFDC9AB86E7E}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A48035F2-5091-49F3-9947-D517163B4F77}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
global.json = global.json
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNetCore.Build", "src\Microsoft.AspNetCore.Build\Microsoft.AspNetCore.Build.xproj", "{84B12F71-EFB3-4C41-907A-512EBF22CA84}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{84B12F71-EFB3-4C41-907A-512EBF22CA84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{84B12F71-EFB3-4C41-907A-512EBF22CA84}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{84B12F71-EFB3-4C41-907A-512EBF22CA84}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{84B12F71-EFB3-4C41-907A-512EBF22CA84}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{84B12F71-EFB3-4C41-907A-512EBF22CA84} = {D699E09D-B449-4972-BD19-EFDC9AB86E7E}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<clear />
|
||||||
|
<add key="aspnetcore-tools" value="https://dotnet.myget.org/F/aspnetcore-tools/api/v3/index.json" />
|
||||||
|
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
|
@ -1,3 +1,5 @@
|
||||||
|
#requires -version 4
|
||||||
|
|
||||||
$repoFolder = $env:REPO_FOLDER
|
$repoFolder = $env:REPO_FOLDER
|
||||||
if (!$repoFolder) {
|
if (!$repoFolder) {
|
||||||
throw "REPO_FOLDER is not set"
|
throw "REPO_FOLDER is not set"
|
||||||
|
@ -28,6 +30,17 @@ if (!$dotnetLocalInstallFolder)
|
||||||
{
|
{
|
||||||
$dotnetLocalInstallFolder = "$env:LOCALAPPDATA\Microsoft\dotnet\"
|
$dotnetLocalInstallFolder = "$env:LOCALAPPDATA\Microsoft\dotnet\"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function InstallSharedRuntime([string] $version, [string] $channel)
|
||||||
|
{
|
||||||
|
$sharedRuntimePath = [IO.Path]::Combine($dotnetLocalInstallFolder, 'shared', 'Microsoft.NETCore.App', $version)
|
||||||
|
# Avoid redownloading the CLI if it's already installed.
|
||||||
|
if (!(Test-Path $sharedRuntimePath))
|
||||||
|
{
|
||||||
|
& "$koreBuildFolder\dotnet\dotnet-install.ps1" -Channel $channel -SharedRuntime -Version $version -Architecture x64
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$newPath = "$dotnetLocalInstallFolder;$env:PATH"
|
$newPath = "$dotnetLocalInstallFolder;$env:PATH"
|
||||||
if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1")
|
if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1")
|
||||||
{
|
{
|
||||||
|
@ -39,6 +52,16 @@ else
|
||||||
{
|
{
|
||||||
# Install the version of dotnet-cli used to compile
|
# Install the version of dotnet-cli used to compile
|
||||||
& "$koreBuildFolder\dotnet\dotnet-install.ps1" -Channel $dotnetChannel -Version $dotnetVersion -Architecture x64
|
& "$koreBuildFolder\dotnet\dotnet-install.ps1" -Channel $dotnetChannel -Version $dotnetVersion -Architecture x64
|
||||||
|
InstallSharedRuntime '1.1.0' 'release/1.1.0'
|
||||||
|
if ($env:KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION)
|
||||||
|
{
|
||||||
|
$channel = 'master'
|
||||||
|
if ($env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL)
|
||||||
|
{
|
||||||
|
$channel = $env:KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL
|
||||||
|
}
|
||||||
|
InstallSharedRuntime $env:KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION $channel
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!($env:Path.Split(';') -icontains $dotnetLocalInstallFolder))
|
if (!($env:Path.Split(';') -icontains $dotnetLocalInstallFolder))
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,6 +36,18 @@ version=$(<$versionFile)
|
||||||
[ -z "$KOREBUILD_DOTNET_CHANNEL" ] && KOREBUILD_DOTNET_CHANNEL=rel-1.0.0
|
[ -z "$KOREBUILD_DOTNET_CHANNEL" ] && KOREBUILD_DOTNET_CHANNEL=rel-1.0.0
|
||||||
[ -z "$KOREBUILD_DOTNET_VERSION" ] && KOREBUILD_DOTNET_VERSION=$version
|
[ -z "$KOREBUILD_DOTNET_VERSION" ] && KOREBUILD_DOTNET_VERSION=$version
|
||||||
|
|
||||||
|
install_shared_runtime() {
|
||||||
|
eval $invocation
|
||||||
|
|
||||||
|
local version=$1
|
||||||
|
local channel=$2
|
||||||
|
|
||||||
|
local sharedRuntimePath="$DOTNET_INSTALL_DIR/shared/Microsoft.NETCore.App/$version"
|
||||||
|
if [ ! -d "$sharedRuntimePath" ]; then
|
||||||
|
$koreBuildFolder/dotnet/dotnet-install.sh --shared-runtime --channel $channel --version $version
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ ! -z "$KOREBUILD_SKIP_RUNTIME_INSTALL" ]; then
|
if [ ! -z "$KOREBUILD_SKIP_RUNTIME_INSTALL" ]; then
|
||||||
echo "Skipping runtime installation because KOREBUILD_SKIP_RUNTIME_INSTALL is set"
|
echo "Skipping runtime installation because KOREBUILD_SKIP_RUNTIME_INSTALL is set"
|
||||||
|
|
||||||
|
@ -52,6 +64,12 @@ else
|
||||||
|
|
||||||
# Install the version of dotnet-cli used to compile
|
# Install the version of dotnet-cli used to compile
|
||||||
$koreBuildFolder/dotnet/dotnet-install.sh --channel $KOREBUILD_DOTNET_CHANNEL --version $KOREBUILD_DOTNET_VERSION
|
$koreBuildFolder/dotnet/dotnet-install.sh --channel $KOREBUILD_DOTNET_CHANNEL --version $KOREBUILD_DOTNET_VERSION
|
||||||
|
install_shared_runtime '1.1.0' 'release/1.1.0'
|
||||||
|
if [ ! -z "$KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION" ]; then
|
||||||
|
channel="$KOREBUILD_DOTNET_SHARED_RUNTIME_CHANNEL"
|
||||||
|
[ -z "$channel" ] && channel="master"
|
||||||
|
install_shared_runtime $KOREBUILD_DOTNET_SHARED_RUNTIME_VERSION $channel
|
||||||
|
fi
|
||||||
|
|
||||||
# Add .NET installation directory to the path if it isn't yet included.
|
# Add .NET installation directory to the path if it isn't yet included.
|
||||||
[[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$DOTNET_INSTALL_DIR:$PATH"
|
[[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$DOTNET_INSTALL_DIR:$PATH"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
rtm
|
preview1
|
|
@ -1 +1 @@
|
||||||
1.0.0-preview4-004233
|
1.0.0-preview4-004233
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
default PROJECT_JSON="project.json"
|
||||||
|
|
||||||
|
@{
|
||||||
|
|
||||||
|
var srcRoot = Path.Combine(BASE_DIR, "src");
|
||||||
|
var srcFolders = Directory.Exists(srcRoot) ? Directory.EnumerateDirectories(srcRoot) : Enumerable.Empty<string>();
|
||||||
|
|
||||||
|
var fullFrameworkMonikerPrefix = new string[] { "net45", "net46" };
|
||||||
|
var coreMonikerPrefix = new string[] { "netcoreapp", "netstandard" };
|
||||||
|
|
||||||
|
var generateApiListing = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APICHECK_GENERATE_BASELINE"));
|
||||||
|
var excludePublicInternalTypes = string.IsNullOrEmpty(Environment.GetEnvironmentVariable("APICHECK_INCLUDE_PUBLIC_INTERNAL_TYPES"));
|
||||||
|
|
||||||
|
foreach (var srcProjectPath in srcFolders)
|
||||||
|
{
|
||||||
|
var srcDirectory = new DirectoryInfo(srcProjectPath);
|
||||||
|
if (!srcDirectory.Exists)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var projectJson = new FileInfo(Path.Combine(srcDirectory.FullName, PROJECT_JSON));
|
||||||
|
if (!projectJson.Exists)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsLinux)
|
||||||
|
{
|
||||||
|
RunApiCheck(srcDirectory, projectJson.FullName, Configuration, fullFrameworkMonikerPrefix, "net45", generateApiListing, excludePublicInternalTypes);
|
||||||
|
RunApiCheck(srcDirectory, projectJson.FullName, Configuration, coreMonikerPrefix, "netcore", generateApiListing, excludePublicInternalTypes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
functions @{
|
||||||
|
|
||||||
|
string GenerateApiCheckInvoker(string framework)
|
||||||
|
{
|
||||||
|
var BASE_DIR = Directory.GetCurrentDirectory();
|
||||||
|
var apicheckBasePath = Directory.EnumerateDirectories(Path.Combine(BASE_DIR, ".build", "Microsoft.AspNetCore.BuildTools.ApiCheck")).First();
|
||||||
|
var apiCheckFullFramework = new FileInfo(Path.Combine(apicheckBasePath, "tools", "net451", "Microsoft.AspNetCore.BuildTools.ApiCheck.exe"));
|
||||||
|
|
||||||
|
if (framework == "net45")
|
||||||
|
{
|
||||||
|
return apiCheckFullFramework.FullName;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "dotnet";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IList<string> GenerateApiCheckArguments(string framework, params string [] other)
|
||||||
|
{
|
||||||
|
var BASE_DIR = Directory.GetCurrentDirectory();
|
||||||
|
var apicheckBasePath = Directory.EnumerateDirectories(Path.Combine(BASE_DIR, ".build", "Microsoft.AspNetCore.BuildTools.ApiCheck")).First();
|
||||||
|
var apiCheckCore = new FileInfo(Path.Combine(apicheckBasePath, "tools", "netcoreapp1.0", "Microsoft.AspNetCore.BuildTools.ApiCheck.dll"));
|
||||||
|
|
||||||
|
if (framework == "net45")
|
||||||
|
{
|
||||||
|
return other.ToList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new List<string>{ apiCheckCore.FullName }.Concat(other).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void RunApiCheck(
|
||||||
|
DirectoryInfo directoryInfo,
|
||||||
|
string projectJson,
|
||||||
|
string configuration,
|
||||||
|
string[] monikerPrefix,
|
||||||
|
string framework,
|
||||||
|
bool generate,
|
||||||
|
bool excludePublicInternalTypes)
|
||||||
|
{
|
||||||
|
var apiListingFile = framework == "net45" ? "baseline.net45.json" : "baseline.netcore.json";
|
||||||
|
var apiListingExceptionsFile = framework == "net45" ? "exceptions.net45.json" : "exceptions.netcore.json";
|
||||||
|
|
||||||
|
var buildFolder = new DirectoryInfo(Path.Combine(directoryInfo.FullName, "bin", configuration));
|
||||||
|
if (!buildFolder.Exists)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileInfo dll = null;
|
||||||
|
foreach (var prefix in monikerPrefix)
|
||||||
|
{
|
||||||
|
var frameworkDirectory = buildFolder.EnumerateDirectories(string.Concat(prefix,"*")).FirstOrDefault();
|
||||||
|
if (frameworkDirectory != null && frameworkDirectory.EnumerateDirectories().Any())
|
||||||
|
{
|
||||||
|
frameworkDirectory = frameworkDirectory.EnumerateDirectories().FirstOrDefault(d =>
|
||||||
|
d.EnumerateFiles(string.Concat(directoryInfo.Name,".dll")).Any());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (frameworkDirectory != null)
|
||||||
|
{
|
||||||
|
dll = frameworkDirectory.EnumerateFiles(string.Concat(directoryInfo.Name,".dll")).FirstOrDefault();
|
||||||
|
if (dll != null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dll != null)
|
||||||
|
{
|
||||||
|
var apiListing = directoryInfo.EnumerateFiles(apiListingFile).FirstOrDefault();
|
||||||
|
var apiListingExceptions = directoryInfo.EnumerateFiles(apiListingExceptionsFile).FirstOrDefault();
|
||||||
|
|
||||||
|
if (generate)
|
||||||
|
{
|
||||||
|
var arguments = GenerateApiCheckArguments(framework,
|
||||||
|
"generate",
|
||||||
|
"-a " + dll.FullName,
|
||||||
|
"-p " + projectJson,
|
||||||
|
"-c " + configuration,
|
||||||
|
"-o " + Path.Combine(directoryInfo.FullName, apiListingFile));
|
||||||
|
|
||||||
|
Exec(GenerateApiCheckInvoker(framework), string.Join(" ",arguments));
|
||||||
|
}
|
||||||
|
else if (apiListing == null)
|
||||||
|
{
|
||||||
|
Log.Info("API listing not found for: " + dll.FullName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var arguments = GenerateApiCheckArguments(framework,
|
||||||
|
"compare",
|
||||||
|
"-b " + apiListing.FullName,
|
||||||
|
"-a " + dll.FullName,
|
||||||
|
"-p " + projectJson,
|
||||||
|
"-c " + configuration);
|
||||||
|
|
||||||
|
if (apiListingExceptions != null)
|
||||||
|
{
|
||||||
|
arguments.Add("-e " + apiListingExceptions.FullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (excludePublicInternalTypes)
|
||||||
|
{
|
||||||
|
// Excludes types in the internal namespace
|
||||||
|
arguments.Add("-epi");
|
||||||
|
}
|
||||||
|
|
||||||
|
Exec(GenerateApiCheckInvoker(framework), string.Join(" ", arguments));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,20 +10,4 @@ restoreDir=''
|
||||||
default currentDir = '${ Directory.GetCurrentDirectory() }'
|
default currentDir = '${ Directory.GetCurrentDirectory() }'
|
||||||
default restoreDir = '${ currentDir }'
|
default restoreDir = '${ currentDir }'
|
||||||
|
|
||||||
@{
|
dotnet command='restore ${E("KOREBUILD_DOTNET_RESTORE_OPTIONS")}' workingDir='${ restoreDir }'
|
||||||
var projectFiles = Files.Include(Path.Combine(restoreDir, "*/*/*.csproj"));
|
|
||||||
bool inferRids = false;
|
|
||||||
foreach (var projectFile in projectFiles)
|
|
||||||
{
|
|
||||||
inferRids |= File.ReadAllText(projectFile).Contains("\"netstandardapp1.5\"");
|
|
||||||
if (inferRids)
|
|
||||||
{
|
|
||||||
Log.Warn("Forcing infer-runtimes because of: " + projectFile);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
default restore_options=' ${ inferRids ? "--infer-runtimes" : "" } ${ E("KOREBUILD_DOTNET_RESTORE_OPTIONS") }'
|
|
||||||
|
|
||||||
dotnet command='restore${ restore_options }' workingDir='${ restoreDir }'
|
|
||||||
|
|
|
@ -25,10 +25,6 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"
|
||||||
{
|
{
|
||||||
E("DOTNET_BUILD_VERSION", BuildNumber);
|
E("DOTNET_BUILD_VERSION", BuildNumber);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(E("DOTNET_AUTHOR")))
|
|
||||||
{
|
|
||||||
E("DOTNET_AUTHOR", AUTHORS);
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(E("DOTNET_ASSEMBLY_FILE_VERSION")))
|
if (string.IsNullOrEmpty(E("DOTNET_ASSEMBLY_FILE_VERSION")))
|
||||||
{
|
{
|
||||||
E("DOTNET_ASSEMBLY_FILE_VERSION", CreateDayBasedVersionNumber());
|
E("DOTNET_ASSEMBLY_FILE_VERSION", CreateDayBasedVersionNumber());
|
||||||
|
@ -44,7 +40,10 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"
|
||||||
@{
|
@{
|
||||||
Configuration = "Release";
|
Configuration = "Release";
|
||||||
E("Configuration", Configuration);
|
E("Configuration", Configuration);
|
||||||
E("KOREBUILD_ADD_ASSEMBLY_INFO", "1");
|
if (string.IsNullOrEmpty(E("KOREBUILD_ADD_ASSEMBLY_INFO")))
|
||||||
|
{
|
||||||
|
E("KOREBUILD_ADD_ASSEMBLY_INFO", "1");
|
||||||
|
}
|
||||||
E("KOREBUILD_DOTNET_PACK_OPTIONS", E("KOREBUILD_DOTNET_PACK_OPTIONS") + " --serviceable");
|
E("KOREBUILD_DOTNET_PACK_OPTIONS", E("KOREBUILD_DOTNET_PACK_OPTIONS") + " --serviceable");
|
||||||
E("KOREBUILD_VERIFY_NUPKGS", "1");
|
E("KOREBUILD_VERIFY_NUPKGS", "1");
|
||||||
}
|
}
|
||||||
|
@ -54,7 +53,10 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"
|
||||||
// Find all dirs that contain a package.json file
|
// Find all dirs that contain a package.json file
|
||||||
var npmDirs = GetDirectoriesContaining(Directory.GetCurrentDirectory(), "package.json").ToArray();
|
var npmDirs = GetDirectoriesContaining(Directory.GetCurrentDirectory(), "package.json").ToArray();
|
||||||
var npmOptions = E("KOREBUILD_NPM_INSTALL_OPTIONS") ?? "--quiet --depth 0";
|
var npmOptions = E("KOREBUILD_NPM_INSTALL_OPTIONS") ?? "--quiet --depth 0";
|
||||||
Parallel.ForEach(npmDirs, npmDir => Npm("install " + npmOptions, npmDir));
|
foreach (var npmDir in npmDirs)
|
||||||
|
{
|
||||||
|
Npm("install " + npmOptions, npmDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#restore-bower-components
|
#restore-bower-components
|
||||||
|
@ -153,7 +155,7 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"
|
||||||
{
|
{
|
||||||
projectGlobs.AddRange(Files.Include(TEST_PROJECT_GLOB).ToList());
|
projectGlobs.AddRange(Files.Include(TEST_PROJECT_GLOB).ToList());
|
||||||
}
|
}
|
||||||
if (!BuildSrcOnly && Directory.Exists("samples"))
|
if (!BuildSrcOnly && Directory.Exists("samples") && Directory.EnumerateFiles("samples", "*.csproj", SearchOption.AllDirectories).Any())
|
||||||
{
|
{
|
||||||
projectGlobs.AddRange(Files.Include(SAMPLES_PROJECT_GLOB).ToList());
|
projectGlobs.AddRange(Files.Include(SAMPLES_PROJECT_GLOB).ToList());
|
||||||
}
|
}
|
||||||
|
@ -167,6 +169,9 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#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'
|
#build-pack .build-compile target='compile'
|
||||||
@{
|
@{
|
||||||
if (Directory.Exists("src"))
|
if (Directory.Exists("src"))
|
||||||
|
@ -210,6 +215,7 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"
|
||||||
|
|
||||||
foreach (var project in nativeProjects)
|
foreach (var project in nativeProjects)
|
||||||
{
|
{
|
||||||
|
Directory.CreateDirectory(Path.Combine(Path.GetDirectoryName(project), "bin"));
|
||||||
Exec(msbuildPath, project + " /p:Platform=Win32" + commonParameters);
|
Exec(msbuildPath, project + " /p:Platform=Win32" + commonParameters);
|
||||||
Exec(msbuildPath, project + " /p:Platform=x64" + commonParameters);
|
Exec(msbuildPath, project + " /p:Platform=x64" + commonParameters);
|
||||||
}
|
}
|
||||||
|
@ -242,11 +248,31 @@ default SAMPLES_PROJECT_GLOB = "samples/*/*.csproj"
|
||||||
}
|
}
|
||||||
|
|
||||||
#nuget-install target='install' description='Install NuGet packages to local repo'
|
#nuget-install target='install' description='Install NuGet packages to local repo'
|
||||||
-if (Directory.Exists("src")) {
|
-if (Directory.Exists("src") && Directory.Exists(BUILD_DIR)) {
|
||||||
nuget-packages-add sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}'
|
nuget-packages-add sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}'
|
||||||
nuget-resilient-publish sourcePackagesDir='${BUILD_DIR}' nugetFeed='${E("NUGET_PUBLISH_FEED")}' if='!string.IsNullOrEmpty(E("NUGET_PUBLISH_FEED"))'
|
nuget-resilient-publish sourcePackagesDir='${BUILD_DIR}' nugetFeed='${E("NUGET_PUBLISH_FEED")}' if='!string.IsNullOrEmpty(E("NUGET_PUBLISH_FEED"))'
|
||||||
-}
|
-}
|
||||||
|
|
||||||
|
#ci-test
|
||||||
|
@{
|
||||||
|
if (Directory.Exists("test"))
|
||||||
|
{
|
||||||
|
var globalJson = Path.Combine(BASE_DIR, "global.json");
|
||||||
|
if (File.Exists(globalJson))
|
||||||
|
{
|
||||||
|
var original = File.ReadAllText(globalJson);
|
||||||
|
var replaced = original.Replace("src,", null).Replace("src", null);
|
||||||
|
File.WriteAllText(globalJson, replaced);
|
||||||
|
}
|
||||||
|
CallTarget("initialize");
|
||||||
|
var projectFiles = Files.Include(TEST_PROJECT_GLOB);
|
||||||
|
foreach (var projectFile in projectFiles)
|
||||||
|
{
|
||||||
|
DotnetTest(projectFile, Configuration, E("KOREBUILD_DOTNET_TEST_OPTIONS"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#xunit-test target='test' if='Directory.Exists("test")'
|
#xunit-test target='test' if='Directory.Exists("test")'
|
||||||
@{
|
@{
|
||||||
var projectFiles = Files.Include(TEST_PROJECT_GLOB);
|
var projectFiles = Files.Include(TEST_PROJECT_GLOB);
|
||||||
|
@ -379,11 +405,6 @@ functions @{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShouldVerifyNupkgs
|
|
||||||
{
|
|
||||||
get { return E("KOREBUILD_VERIFY_NUPKGS") == "1"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BuildSrcOnly
|
bool BuildSrcOnly
|
||||||
{
|
{
|
||||||
get { return E("KOREBUILD_BUILD_SRC_ONLY") == "1"; }
|
get { return E("KOREBUILD_BUILD_SRC_ONLY") == "1"; }
|
||||||
|
@ -446,4 +467,4 @@ macro name="UpdateResx" resxFile='string'
|
||||||
k-generate-resx
|
k-generate-resx
|
||||||
|
|
||||||
macro name='GitCommand' gitCommand='string'
|
macro name='GitCommand' gitCommand='string'
|
||||||
git
|
git
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
|
|
||||||
var VERSION='0.1'
|
var VERSION='0.1'
|
||||||
var FULL_VERSION='0.1'
|
var FULL_VERSION='0.1'
|
||||||
var AUTHORS='Microsoft Open Technologies, Inc.'
|
|
||||||
|
|
||||||
use-standard-lifecycle
|
use-standard-lifecycle
|
||||||
k-standard-goals
|
k-standard-goals
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": { }
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"NETFrameworkReferenceAssemblies": "4.5.1"
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"projects": [ "src" ]
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
#Requires -Version 4
|
||||||
|
# Just here to isolate the build template from having to know anything about the interior structure of KoreBuild.
|
||||||
|
# You can move pretty much everything else in this repo EXCEPT this file.
|
||||||
|
$KoreBuildRoot = Convert-Path (Split-Path -Parent $PSScriptRoot)
|
||||||
|
$KoreBuild = Join-Path "$KoreBuildRoot" "src\Microsoft.AspNetCore.Build\scripts\KoreBuild.ps1"
|
||||||
|
& "$KoreBuild" @args
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Just here to isolate the build template from having to know anything about the interior structure of KoreBuild.
|
||||||
|
# You can move pretty much everything else in this repo EXCEPT this file.
|
||||||
|
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
|
||||||
|
"$ROOT/src/Microsoft.AspNetCore.Build/scripts/KoreBuild.sh" "$@"
|
|
@ -0,0 +1,122 @@
|
||||||
|
#Requires -Version 4
|
||||||
|
# Installs KoreBuild into a repo, overwriting all previous build scripts
|
||||||
|
# This script is downloaded and executed without any of the corresponding scripts in this repo, so don't assume anything in this repo is available!
|
||||||
|
|
||||||
|
param(
|
||||||
|
[switch]$Local,
|
||||||
|
[string]$KoreBuildUrl)
|
||||||
|
|
||||||
|
## Sucks that we have to have a copy of this in both this script AND the build script :(.
|
||||||
|
function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
|
||||||
|
{
|
||||||
|
while($true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Invoke-WebRequest $url -OutFile $downloadLocation
|
||||||
|
break
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
$exceptionMessage = $_.Exception.Message
|
||||||
|
Write-Host "Failed to download '$url': $exceptionMessage"
|
||||||
|
if ($retries -gt 0) {
|
||||||
|
$retries--
|
||||||
|
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
|
||||||
|
Start-Sleep -Seconds 10
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$exception = $_.Exception
|
||||||
|
throw $exception
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Prerequisites
|
||||||
|
if(!(Test-Path "$(Get-Location)\.git")) {
|
||||||
|
throw "This install script should be run from the root of a Git repo"
|
||||||
|
}
|
||||||
|
|
||||||
|
$Changes = git diff --name-only
|
||||||
|
if($Changes) {
|
||||||
|
throw "There are unstaged changes in this repo. Reset or stage them before installing KoreBuild"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ConfirmOverwrite($message) {
|
||||||
|
$title = "Overwrite previous build scripts?"
|
||||||
|
$prompt = "$message Should we continue? [Y]es or [N]o?"
|
||||||
|
$yes = New-Object System.Management.Automation.Host.ChoiceDescription '&Yes','Continues installation'
|
||||||
|
$no = New-Object System.Management.Automation.Host.ChoiceDescription '&No','Cancels installation'
|
||||||
|
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes,$no)
|
||||||
|
$choice = $host.UI.PromptForChoice($title, $prompt, $options, 1);
|
||||||
|
|
||||||
|
if($choice -ne 0) {
|
||||||
|
throw "User cancelled the operation"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$OldBuildScriptExists = @(
|
||||||
|
(Test-Path "$(Get-Location)\build.cmd"),
|
||||||
|
(Test-Path "$(Get-Location)\build.ps1"),
|
||||||
|
(Test-Path "$(Get-Location)\build.sh")
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check the existing build scripts
|
||||||
|
if($OldBuildScriptExists -contains $true) {
|
||||||
|
ConfirmOverwrite "Build scripts already exist, possibly from a previous KoreBuild installation. They will be replaced by this process."
|
||||||
|
}
|
||||||
|
|
||||||
|
# Determine KoreBuild Repo URL if not specified
|
||||||
|
if(!$KoreBuildUrl) {
|
||||||
|
$KoreBuildUrl = $env:KOREBUILD_ZIP
|
||||||
|
}
|
||||||
|
if(!$KoreBuildUrl) {
|
||||||
|
$KoreBuildUrl = "https://github.com/aspnet/KoreBuild/archive/dev.zip"
|
||||||
|
}
|
||||||
|
|
||||||
|
if($Local) {
|
||||||
|
$TemplateSource = Join-Path (Split-Path -Parent $PSScriptRoot) "template2"
|
||||||
|
Write-Host -ForegroundColor Green "Copying template files from $TemplateSource ..."
|
||||||
|
dir $TemplateSource | ForEach-Object {
|
||||||
|
$dest = Join-Path (Get-Location) $_.Name
|
||||||
|
Write-Host -ForegroundColor Cyan "* $($_.Name)"
|
||||||
|
cp $_.FullName $dest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$KoreBuildZip = Join-Path ([IO.Path]::GetTempPath()) "$([IO.Path]::GetRandomFileName()).zip"
|
||||||
|
|
||||||
|
Write-Host -ForegroundColor Green "Downloading KoreBuild files to $KoreBuildZip ..."
|
||||||
|
DownloadWithRetry -url $KoreBuildUrl -downloadLocation $KoreBuildZip -retries 6
|
||||||
|
|
||||||
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||||
|
$zip = [System.IO.Compression.ZipFile]::OpenRead($KoreBuildZip)
|
||||||
|
try {
|
||||||
|
# Copy the template files over top of existing files.
|
||||||
|
Write-Host -ForegroundColor Green "Copying template files from $KoreBuildZip ..."
|
||||||
|
$zip.Entries | ForEach-Object {
|
||||||
|
$dir = [IO.Path]::GetDirectoryName($_.FullName)
|
||||||
|
if ($dir.EndsWith("template2") -and ($_.Name)) {
|
||||||
|
Write-Host -ForegroundColor Cyan "* $($_.Name)"
|
||||||
|
$dest = Join-Path (Convert-Path (Get-Location)) $_.Name
|
||||||
|
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $dest, $true)
|
||||||
|
|
||||||
|
git add $dest
|
||||||
|
|
||||||
|
if($_.Name.EndsWith(".sh")) {
|
||||||
|
# Make sure that git records the "x" mode flag on this file (since we can't set it directly because Windows)
|
||||||
|
git update-index --chmod=+x $dest
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
$zip.Dispose()
|
||||||
|
Write-Host -ForegroundColor Green "Deleting temporary download $KoreBuildZip ..."
|
||||||
|
del -for $KoreBuildZip
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host -ForegroundColor Green "KoreBuild has been installed into this repo. The changes are ready to be committed."
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build
|
||||||
|
{
|
||||||
|
internal class MSBuildNuGetLogger : NuGet.Common.ILogger
|
||||||
|
{
|
||||||
|
private readonly TaskLoggingHelper _log;
|
||||||
|
|
||||||
|
public MSBuildNuGetLogger(TaskLoggingHelper log)
|
||||||
|
{
|
||||||
|
_log = log;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogDebug(string data)
|
||||||
|
{
|
||||||
|
_log.LogMessage(MessageImportance.Low, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogError(string data)
|
||||||
|
{
|
||||||
|
_log.LogError(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogErrorSummary(string data)
|
||||||
|
{
|
||||||
|
// MSBuild handle summaries
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogInformation(string data)
|
||||||
|
{
|
||||||
|
_log.LogMessage(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogInformationSummary(string data)
|
||||||
|
{
|
||||||
|
// MSBuild handle summaries
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogMinimal(string data)
|
||||||
|
{
|
||||||
|
_log.LogMessage(MessageImportance.High, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogVerbose(string data)
|
||||||
|
{
|
||||||
|
_log.LogMessage(MessageImportance.Low, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogWarning(string data)
|
||||||
|
{
|
||||||
|
_log.LogWarning(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- This file lists all the tasks that ship in KoreBuild -->
|
||||||
|
<UsingTask AssemblyName="Microsoft.AspNetCore.Build" TaskName="Microsoft.AspNetCore.Build.Tasks.WaitForDebugger" />
|
||||||
|
<UsingTask AssemblyName="Microsoft.AspNetCore.Build" TaskName="Microsoft.AspNetCore.Build.Tasks.GetGitCommitInfo" />
|
||||||
|
<UsingTask AssemblyName="Microsoft.AspNetCore.Build" TaskName="Microsoft.AspNetCore.Build.Tasks.DetectOSPlatform" />
|
||||||
|
<UsingTask AssemblyName="Microsoft.AspNetCore.Build" TaskName="Microsoft.AspNetCore.Build.Tasks.GatherProjectMetadata" />
|
||||||
|
<UsingTask AssemblyName="Microsoft.AspNetCore.Build" TaskName="Microsoft.AspNetCore.Build.Tasks.DumpMetadata" />
|
||||||
|
<UsingTask AssemblyName="Microsoft.AspNetCore.Build" TaskName="Microsoft.AspNetCore.Build.Tasks.ResolvePackagedTool" />
|
||||||
|
<UsingTask AssemblyName="Microsoft.AspNetCore.Build" TaskName="Microsoft.AspNetCore.Build.Tasks.NuGetInstall" />
|
||||||
|
<UsingTask AssemblyName="Microsoft.AspNetCore.Build" TaskName="Microsoft.AspNetCore.Build.Tasks.NuGetResilientPush" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>84b12f71-efb3-4c41-907a-512ebf22ca84</ProjectGuid>
|
||||||
|
<RootNamespace>Microsoft.AspNetCore.Build</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build
|
||||||
|
{
|
||||||
|
public static class Program
|
||||||
|
{
|
||||||
|
public static int Main(string[] args)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("Only needed to work around the fact that you can't publish a library :(");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("KoreBuild.Tasks")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("77ae04dc-8135-4875-9ce7-b772ea1f3cf6")]
|
|
@ -0,0 +1,62 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using NuGet.Common;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build
|
||||||
|
{
|
||||||
|
public class ReplayNuGetLogger : ILogger
|
||||||
|
{
|
||||||
|
private List<Action<ILogger>> _recordings = new List<Action<ILogger>>();
|
||||||
|
|
||||||
|
public void LogDebug(string data)
|
||||||
|
{
|
||||||
|
_recordings.Add(l => l.LogDebug(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogError(string data)
|
||||||
|
{
|
||||||
|
_recordings.Add(l => l.LogError(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogErrorSummary(string data)
|
||||||
|
{
|
||||||
|
_recordings.Add(l => l.LogErrorSummary(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogInformation(string data)
|
||||||
|
{
|
||||||
|
_recordings.Add(l => l.LogInformation(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogInformationSummary(string data)
|
||||||
|
{
|
||||||
|
_recordings.Add(l => l.LogInformationSummary(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogMinimal(string data)
|
||||||
|
{
|
||||||
|
_recordings.Add(l => l.LogMinimal(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogVerbose(string data)
|
||||||
|
{
|
||||||
|
_recordings.Add(l => l.LogVerbose(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogWarning(string data)
|
||||||
|
{
|
||||||
|
_recordings.Add(l => l.LogWarning(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Replay(ILogger logger)
|
||||||
|
{
|
||||||
|
foreach (var recording in _recordings)
|
||||||
|
{
|
||||||
|
recording(logger);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build.Tasks
|
||||||
|
{
|
||||||
|
public class DetectOSPlatform : Task
|
||||||
|
{
|
||||||
|
[Output]
|
||||||
|
public string PlatformName { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
|
{
|
||||||
|
PlatformName = "Windows";
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||||
|
{
|
||||||
|
PlatformName = "Linux";
|
||||||
|
}
|
||||||
|
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
|
||||||
|
{
|
||||||
|
PlatformName = "macOS";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.LogError("Failed to determine the platform on which the build is running");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build.Tasks
|
||||||
|
{
|
||||||
|
public class DumpMetadata : Task
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public ITaskItem[] Items { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
foreach (var item in Items)
|
||||||
|
{
|
||||||
|
Log.LogMessage(item.ItemSpec);
|
||||||
|
foreach (var metadataName in item.MetadataNames.Cast<string>())
|
||||||
|
{
|
||||||
|
Log.LogMessage($" {metadataName} = {item.GetMetadata(metadataName)}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build.Tasks
|
||||||
|
{
|
||||||
|
public class GatherProjectMetadata : Task
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public ITaskItem[] Projects { get; set; }
|
||||||
|
|
||||||
|
[Output]
|
||||||
|
public ITaskItem[] UpdatedProjects { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
UpdatedProjects = new ITaskItem[Projects.Length];
|
||||||
|
for (var i = 0; i < Projects.Length; i++)
|
||||||
|
{
|
||||||
|
var project = new TaskItem(Projects[i]);
|
||||||
|
AddProjectMetadata(project);
|
||||||
|
UpdatedProjects[i] = project;
|
||||||
|
}
|
||||||
|
Log.LogMessage($"Collected metadata for {Projects.Length} projects");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddProjectMetadata(TaskItem project)
|
||||||
|
{
|
||||||
|
var fullPath = project.GetMetadata("FullPath");
|
||||||
|
|
||||||
|
// Target Framework
|
||||||
|
var json = JObject.Parse(File.ReadAllText(fullPath));
|
||||||
|
var frameworks = json["frameworks"];
|
||||||
|
if (frameworks != null && frameworks.Type == JTokenType.Object)
|
||||||
|
{
|
||||||
|
var frameworkNames = ((JObject)frameworks).Properties().Select(p => p.Name);
|
||||||
|
project.SetMetadata("TargetFrameworks", string.Join(";", frameworkNames));
|
||||||
|
foreach (var framework in frameworkNames)
|
||||||
|
{
|
||||||
|
project.SetMetadata($"TFM_{framework.Replace('.', '_')}", "true");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Paths and stuff (directories have trailing '\' to match MSBuild conventions)
|
||||||
|
var dir = Path.GetDirectoryName(fullPath);
|
||||||
|
project.SetMetadata("ProjectDir", dir + Path.DirectorySeparatorChar);
|
||||||
|
project.SetMetadata("ProjectName", Path.GetFileName(dir));
|
||||||
|
project.SetMetadata("SharedSourcesDir", Path.Combine(dir, "shared") + Path.DirectorySeparatorChar);
|
||||||
|
project.SetMetadata("GeneratedBuildInfoFile", Path.Combine(dir, "BuildInfo.generated.cs"));
|
||||||
|
|
||||||
|
var group = Path.GetFileName(Path.GetDirectoryName(dir));
|
||||||
|
project.SetMetadata("ProjectGroup", group);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
using System.IO;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build.Tasks
|
||||||
|
{
|
||||||
|
public class GetGitCommitInfo : Task
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string RepositoryRoot { get; set; }
|
||||||
|
|
||||||
|
public bool WarnOnError { get; set; }
|
||||||
|
|
||||||
|
[Output]
|
||||||
|
public string Branch { get; set; }
|
||||||
|
|
||||||
|
[Output]
|
||||||
|
public string CommitHash { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
Branch = null;
|
||||||
|
CommitHash = null;
|
||||||
|
|
||||||
|
var headFile = Path.Combine(RepositoryRoot, ".git", "HEAD");
|
||||||
|
if(!File.Exists(headFile))
|
||||||
|
{
|
||||||
|
ReportError("Unable to determine active git branch.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var content = File.ReadAllText(headFile).Trim();
|
||||||
|
if(!content.StartsWith("ref: refs/heads/"))
|
||||||
|
{
|
||||||
|
ReportError("'.git/HEAD' file in unexpected format, unable to determine active git branch");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Branch = content.Substring(16);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(Branch))
|
||||||
|
{
|
||||||
|
ReportError("Current branch appears to be empty. Failed to retrieve current branch.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var branchFile = Path.Combine(RepositoryRoot, ".git", "refs", "heads", Branch.Replace('/', Path.DirectorySeparatorChar));
|
||||||
|
if(!File.Exists(branchFile))
|
||||||
|
{
|
||||||
|
ReportError("Unable to determine current git commit hash");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
CommitHash = File.ReadAllText(branchFile).Trim();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReportError(string message)
|
||||||
|
{
|
||||||
|
if(WarnOnError)
|
||||||
|
{
|
||||||
|
Log.LogWarning(message);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Log.LogMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
using NuGet.Packaging;
|
||||||
|
using NuGet.Packaging.Core;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build.Tasks
|
||||||
|
{
|
||||||
|
public class NuGetInstall : Task
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public ITaskItem[] Packages { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string DestinationFolder { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(DestinationFolder))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(DestinationFolder);
|
||||||
|
Log.LogMessage($"Created destination folder: {DestinationFolder}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var success = true;
|
||||||
|
var logger = new MSBuildNuGetLogger(Log);
|
||||||
|
foreach (var item in Packages)
|
||||||
|
{
|
||||||
|
// Load the package
|
||||||
|
var path = item.GetMetadata("FullPath");
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
Log.LogError($"Package file not found: {path}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
using (var stream = File.OpenRead(path))
|
||||||
|
{
|
||||||
|
PackageIdentity id;
|
||||||
|
using (var reader = new PackageArchiveReader(stream, leaveStreamOpen: true))
|
||||||
|
{
|
||||||
|
id = reader.GetIdentity();
|
||||||
|
}
|
||||||
|
stream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
|
var context = new VersionFolderPathContext(
|
||||||
|
id,
|
||||||
|
DestinationFolder,
|
||||||
|
logger,
|
||||||
|
fixNuspecIdCasing: true,
|
||||||
|
packageSaveMode: PackageSaveMode.Nupkg | PackageSaveMode.Nuspec,
|
||||||
|
normalizeFileNames: false,
|
||||||
|
xmlDocFileSaveMode: XmlDocFileSaveMode.None);
|
||||||
|
|
||||||
|
PackageExtractor.InstallFromSourceAsync(
|
||||||
|
stream.CopyToAsync,
|
||||||
|
context,
|
||||||
|
CancellationToken.None).Wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,130 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using NuGet.Commands;
|
||||||
|
using NuGet.Common;
|
||||||
|
using NuGet.Configuration;
|
||||||
|
using MSBuildTask = Microsoft.Build.Utilities.Task;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build.Tasks
|
||||||
|
{
|
||||||
|
public class NuGetResilientPush : MSBuildTask
|
||||||
|
{
|
||||||
|
private volatile bool _success = true;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public ITaskItem[] Packages { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Feed { get; set; }
|
||||||
|
|
||||||
|
public string ApiKey { get; set; }
|
||||||
|
|
||||||
|
public int MaxDegreeOfParallelism { get; set; } = Environment.ProcessorCount * 2;
|
||||||
|
|
||||||
|
public int TimeoutInSeconds { get; set; } = 0; // PushRunner uses '0' as the default
|
||||||
|
|
||||||
|
public int Retries { get; set; } = 10;
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
_success = true;
|
||||||
|
|
||||||
|
var options = new ParallelOptions()
|
||||||
|
{
|
||||||
|
MaxDegreeOfParallelism = MaxDegreeOfParallelism
|
||||||
|
};
|
||||||
|
|
||||||
|
var mainLogger = new MSBuildNuGetLogger(Log);
|
||||||
|
var padlock = new object();
|
||||||
|
|
||||||
|
var logTasks = new ConcurrentBag<Task>();
|
||||||
|
Parallel.ForEach(Packages, options, item =>
|
||||||
|
{
|
||||||
|
var logger = new ReplayNuGetLogger();
|
||||||
|
var localResult = PushPackage(item, logger).Result;
|
||||||
|
if (!localResult)
|
||||||
|
{
|
||||||
|
_success = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Asynchronously play-back the log, but on an un-awaited task so it doesn't block further work
|
||||||
|
logTasks.Add(Task.Run(() =>
|
||||||
|
{
|
||||||
|
// Lock so that each individual push gets written as a single chunk of log
|
||||||
|
lock (padlock)
|
||||||
|
{
|
||||||
|
logger.Replay(mainLogger);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Just make sure all the log messages have been written
|
||||||
|
Task.WhenAll(logTasks).Wait();
|
||||||
|
|
||||||
|
return _success;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> PushPackage(ITaskItem item, NuGet.Common.ILogger logger)
|
||||||
|
{
|
||||||
|
var path = item.GetMetadata("FullPath");
|
||||||
|
|
||||||
|
var settings = Settings.LoadDefaultSettings(
|
||||||
|
Directory.GetCurrentDirectory(),
|
||||||
|
configFileName: null,
|
||||||
|
machineWideSettings: new MachineWideSettings());
|
||||||
|
var sourceProvider = new PackageSourceProvider(settings);
|
||||||
|
|
||||||
|
var tries = 0;
|
||||||
|
var pushed = false;
|
||||||
|
while (!pushed)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await PushRunner.Run(
|
||||||
|
settings,
|
||||||
|
sourceProvider,
|
||||||
|
path,
|
||||||
|
Feed,
|
||||||
|
ApiKey,
|
||||||
|
TimeoutInSeconds,
|
||||||
|
disableBuffering: false,
|
||||||
|
noSymbols: false,
|
||||||
|
logger: logger);
|
||||||
|
pushed = true;
|
||||||
|
}
|
||||||
|
catch (Exception ex) when (tries < Retries)
|
||||||
|
{
|
||||||
|
tries++;
|
||||||
|
Log.LogMessage(MessageImportance.High, $"Failed to push {path}. Retrying ({tries}/{Retries} attempt). Error Details: {ex.ToString()}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.LogError($"Failed to push {path} on final attempt: {ex.ToString()}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class MachineWideSettings : IMachineWideSettings
|
||||||
|
{
|
||||||
|
Lazy<IEnumerable<Settings>> _settings;
|
||||||
|
|
||||||
|
public MachineWideSettings()
|
||||||
|
{
|
||||||
|
var baseDirectory = NuGetEnvironment.GetFolderPath(NuGetFolderPath.MachineWideConfigDirectory);
|
||||||
|
_settings = new Lazy<IEnumerable<Settings>>(
|
||||||
|
() => NuGet.Configuration.Settings.LoadMachineWideSettings(baseDirectory));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<Settings> Settings => _settings.Value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
using NuGet.Versioning;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build.Tasks
|
||||||
|
{
|
||||||
|
public class ResolvePackagedTool : Task
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string PackageId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string PackagesDir { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string RelativePath { get; set; }
|
||||||
|
|
||||||
|
[Output]
|
||||||
|
public string ToolPath { get; set; }
|
||||||
|
|
||||||
|
[Output]
|
||||||
|
public string ToolVersion { get; set; }
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
// Find candidates
|
||||||
|
var packageIdDir = Path.Combine(PackagesDir, PackageId);
|
||||||
|
|
||||||
|
var version = Directory.GetDirectories(packageIdDir)
|
||||||
|
.Select(d => Path.GetFileName(d))
|
||||||
|
.Select(f => ParseVersionOrDefault(f))
|
||||||
|
.Where(v => v != null)
|
||||||
|
.Max();
|
||||||
|
|
||||||
|
ToolVersion = version.ToNormalizedString();
|
||||||
|
ToolPath = Path.Combine(packageIdDir, version.ToNormalizedString(), RelativePath);
|
||||||
|
Log.LogMessage($"Resolved tool: {ToolPath}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private NuGetVersion ParseVersionOrDefault(string version)
|
||||||
|
{
|
||||||
|
NuGetVersion ver;
|
||||||
|
if (!NuGetVersion.TryParse(version, out ver))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return ver;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Build.Tasks
|
||||||
|
{
|
||||||
|
public class WaitForDebugger : Task
|
||||||
|
{
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Waiting for Debugger. Press ENTER to continue. Process ID: {Process.GetCurrentProcess().Id}");
|
||||||
|
Console.ReadLine();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
|
|
||||||
|
"buildOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"publishOptions": {
|
||||||
|
"include": [ "Microsoft.AspNetCore.Build.tasks" ]
|
||||||
|
},
|
||||||
|
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.App": {
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "platform"
|
||||||
|
},
|
||||||
|
"NuGet.Versioning": "3.5.0-beta2-1484",
|
||||||
|
"NuGet.Packaging": "3.5.0-beta2-1484",
|
||||||
|
"NuGet.Commands": "3.5.0-beta2-1484",
|
||||||
|
"Newtonsoft.Json": "9.0.1",
|
||||||
|
"Microsoft.Build": "14.3.0",
|
||||||
|
"Microsoft.Build.Framework": "14.3.0",
|
||||||
|
"Microsoft.Build.Utilities.Core": "14.3.0"
|
||||||
|
},
|
||||||
|
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": "dnxcore50"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,176 @@
|
||||||
|
#requires -version 4
|
||||||
|
|
||||||
|
Write-Host -ForegroundColor Green "Starting KoreBuild 2.0 ..."
|
||||||
|
|
||||||
|
$RepositoryRoot = Convert-Path (Get-Location)
|
||||||
|
$BuildRoot = Join-Path $RepositoryRoot ".build"
|
||||||
|
$KoreBuildRoot = (Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)))
|
||||||
|
$ArtifactsDir = Join-Path $RepositoryRoot "artifacts"
|
||||||
|
|
||||||
|
$env:REPO_FOLDER = $RepositoryRoot
|
||||||
|
$env:KOREBUILD_FOLDER = $KoreBuildRoot
|
||||||
|
|
||||||
|
$RID = "win7-x64";
|
||||||
|
if($env:PROCESSOR_ARCHITECTURE -eq "x86") {
|
||||||
|
$RID = "win7-x86";
|
||||||
|
}
|
||||||
|
|
||||||
|
$MSBuildDir = Join-Path $BuildRoot "MSBuildTools"
|
||||||
|
$ToolsDir = Join-Path $BuildRoot "Tools"
|
||||||
|
|
||||||
|
$KoreBuildLog = Join-Path $BuildRoot "korebuild.log"
|
||||||
|
if(Test-Path $KoreBuildLog) {
|
||||||
|
del $KoreBuildLog
|
||||||
|
}
|
||||||
|
|
||||||
|
$MSBuildLog = Join-Path $BuildRoot "korebuild.msbuild.log"
|
||||||
|
if(Test-Path $MSBuildLog) {
|
||||||
|
del $MSBuildLog
|
||||||
|
}
|
||||||
|
|
||||||
|
$MSBuildResponseFile = Join-Path $BuildRoot "korebuild.msbuild.rsp"
|
||||||
|
if(Test-Path $MSBuildResponseFile) {
|
||||||
|
del $MSBuildResponseFile
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function exec($cmd) {
|
||||||
|
$cmdName = [IO.Path]::GetFileName($cmd)
|
||||||
|
Write-Host -ForegroundColor DarkGray "> $cmdName $args"
|
||||||
|
"`r`n>>>>> $cmd $args <<<<<`r`n" >> $KoreBuildLog
|
||||||
|
& $cmd @args 2>&1 >> $KoreBuildLog
|
||||||
|
$exitCode = $LASTEXITCODE
|
||||||
|
if($exitCode -ne 0) {
|
||||||
|
throw "'$cmdName $args' failed with exit code: $exitCode. See '$ArtifactsDir\korebuild.log' for details"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function EnsureDotNet() {
|
||||||
|
$dotnetVersionFile = "$KoreBuildRoot\build\cli.version"
|
||||||
|
$dotnetChannel = "preview"
|
||||||
|
$dotnetVersion = Get-Content $dotnetVersionFile
|
||||||
|
$dotnetLocalInstallFolder = "$env:LOCALAPPDATA\Microsoft\dotnet\"
|
||||||
|
|
||||||
|
if ($env:KOREBUILD_DOTNET_CHANNEL)
|
||||||
|
{
|
||||||
|
$dotnetChannel = $env:KOREBUILD_DOTNET_CHANNEL
|
||||||
|
}
|
||||||
|
if ($env:KOREBUILD_DOTNET_VERSION)
|
||||||
|
{
|
||||||
|
$dotnetVersion = $env:KOREBUILD_DOTNET_VERSION
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($env:DOTNET_INSTALL_DIR)
|
||||||
|
{
|
||||||
|
$dotnetLocalInstallFolder = $env:DOTNET_INSTALL_DIR
|
||||||
|
}
|
||||||
|
|
||||||
|
$newPath = "$dotnetLocalInstallFolder;$env:PATH"
|
||||||
|
if ($env:KOREBUILD_SKIP_RUNTIME_INSTALL -eq "1")
|
||||||
|
{
|
||||||
|
Write-Host -ForegroundColor Green "Skipping runtime installation because KOREBUILD_SKIP_RUNTIME_INSTALL = 1"
|
||||||
|
# Add to the _end_ of the path in case preferred .NET CLI is not in the default location.
|
||||||
|
$newPath = "$env:PATH;$dotnetLocalInstallFolder"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Write-Host -ForegroundColor Green "Installing .NET Command-Line Tools ..."
|
||||||
|
exec "$KoreBuildRoot\build\dotnet\dotnet-install.ps1" -Channel $dotnetChannel -Version $dotnetVersion -Architecture x64
|
||||||
|
exec "$KoreBuildRoot\build\dotnet\dotnet-install.ps1" -SharedRuntime -Channel 'preview' -Version '1.0.0' -Architecture x64
|
||||||
|
}
|
||||||
|
if (!($env:Path.Split(';') -icontains $dotnetLocalInstallFolder))
|
||||||
|
{
|
||||||
|
Write-Host -ForegroundColor Green "Adding $dotnetLocalInstallFolder to PATH"
|
||||||
|
$env:Path = "$newPath"
|
||||||
|
}
|
||||||
|
|
||||||
|
# workaround for CLI issue: https://github.com/dotnet/cli/issues/2143
|
||||||
|
$sharedPath = (Join-Path (Split-Path ((get-command dotnet.exe).Path) -Parent) "shared");
|
||||||
|
(Get-ChildItem $sharedPath -Recurse *dotnet.exe) | %{ $_.FullName } | Remove-Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
function EnsureMSBuild() {
|
||||||
|
if(!(Test-Path $MSBuildDir)) {
|
||||||
|
try {
|
||||||
|
mkdir $MSBuildDir | Out-Null
|
||||||
|
$content = [IO.File]::ReadAllText((Convert-Path "$PSScriptRoot\msbuild.project.template.json"))
|
||||||
|
$content = $content.Replace("RUNTIME", $RID)
|
||||||
|
|
||||||
|
[IO.File]::WriteAllText((Join-Path $MSBuildDir "project.json"), $content);
|
||||||
|
|
||||||
|
copy "$KoreBuildRoot\NuGet.config" "$MSBuildDir"
|
||||||
|
|
||||||
|
Write-Host -ForegroundColor Green "Preparing MSBuild ..."
|
||||||
|
exec dotnet restore "$MSBuildDir\project.json" -v Detailed
|
||||||
|
exec dotnet publish "$MSBuildDir\project.json" -o "$MSBuildDir\bin\pub"
|
||||||
|
|
||||||
|
Write-Host -ForegroundColor Green "Preparing KoreBuild Tasks ..."
|
||||||
|
exec dotnet restore "$KoreBuildRoot\src\Microsoft.AspNetCore.Build" -v Detailed
|
||||||
|
exec dotnet publish "$KoreBuildRoot\src\Microsoft.AspNetCore.Build" -o "$MSBuildDir\bin\pub" -f "netcoreapp1.0"
|
||||||
|
} catch {
|
||||||
|
$ex = $error[0]
|
||||||
|
# Clean up to ensure we aren't half-initialized
|
||||||
|
if(Test-Path $MSBuildDir) {
|
||||||
|
del -rec -for $MSBuildDir
|
||||||
|
}
|
||||||
|
|
||||||
|
throw $ex
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host -ForegroundColor DarkGray "MSBuild already initialized, use -Reset to refresh it"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function EnsureTools() {
|
||||||
|
if(!(Test-Path $ToolsDir)) {
|
||||||
|
try {
|
||||||
|
Write-Host -ForegroundColor Green "Preparing other build tools ..."
|
||||||
|
exec dotnet restore "$KoreBuildRoot\tools\project.json" -v Detailed --packages "$ToolsDir"
|
||||||
|
} catch {
|
||||||
|
# Clean up to ensure we aren't half-initialized
|
||||||
|
if(Test-Path $ToolsDir) {
|
||||||
|
del -rec -for $ToolsDir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host -ForegroundColor DarkGray "Build tools already initialized, use -Reset to refresh them"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
EnsureDotNet
|
||||||
|
EnsureMSBuild
|
||||||
|
EnsureTools
|
||||||
|
|
||||||
|
$KoreBuildTargetsRoot = "$KoreBuildRoot\src\Microsoft.AspNetCore.Build\targets"
|
||||||
|
|
||||||
|
# Check for a local KoreBuild project
|
||||||
|
$Proj = Join-Path "$RepositoryRoot" "makefile.proj"
|
||||||
|
if(!(Test-Path $Proj)) {
|
||||||
|
$Proj = Join-Path "$KoreBuildTargetsRoot" "makefile.proj"
|
||||||
|
}
|
||||||
|
|
||||||
|
$MSBuildArguments = @"
|
||||||
|
/nologo
|
||||||
|
"$Proj"
|
||||||
|
/p:KoreBuildToolsPackages="$ToolsDir"
|
||||||
|
/p:KoreBuildTargetsPath="$KoreBuildTargetsRoot"
|
||||||
|
/p:KoreBuildTasksPath="$MSBuildDir\bin\pub"
|
||||||
|
/fl
|
||||||
|
/flp:LogFile="$MSBuildLog";Verbosity=diagnostic;Encoding=UTF-8
|
||||||
|
"@
|
||||||
|
|
||||||
|
$MSBuildArguments | Out-File -Encoding ASCII -FilePath $MSBuildResponseFile
|
||||||
|
$args | ForEach { $_ | Out-File -Append -Encoding ASCII -FilePath $MSBuildResponseFile } # Add local args to RSP
|
||||||
|
|
||||||
|
Write-Host -ForegroundColor Green "Starting build ..."
|
||||||
|
Write-Host -ForegroundColor DarkGray "> msbuild $Proj $args"
|
||||||
|
|
||||||
|
& "$MSBuildDir\bin\pub\CoreRun.exe" "$MSBuildDir\bin\pub\MSBuild.dll" `@"$MSBuildResponseFile"
|
||||||
|
} finally {
|
||||||
|
# Copy logs to artifacts
|
||||||
|
if(!(Test-Path $ArtifactsDir)) {
|
||||||
|
mkdir $ArtifactsDir | Out-Null
|
||||||
|
}
|
||||||
|
cp -ErrorAction SilentlyContinue $MSBuildResponseFile,$KoreBuildLog,$MSBuildLog $ArtifactsDir
|
||||||
|
}
|
|
@ -0,0 +1,178 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
CYAN="\033[0;36m"
|
||||||
|
RESET="\033[0m"
|
||||||
|
RED="\033[0;31m"
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
echo -e "${GREEN}Preparing KoreBuild 2.0...${RESET}"
|
||||||
|
|
||||||
|
if [ "$KOREBUILD_COMPATIBILITY" = "1" ]; then
|
||||||
|
MSBUILD_ARGS=()
|
||||||
|
for arg in "$@"; do
|
||||||
|
case $arg in
|
||||||
|
--quiet)
|
||||||
|
MSBUILD_ARGS=(${MSBUILD_ARGS[@]} -v:m)
|
||||||
|
;;
|
||||||
|
--*)
|
||||||
|
echo "Unknown KoreBuild 1.0 switch: $arg. If this switch took an argument, you'll have a bad problem :)"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
TARGET="-t:$(echo "${arg[@]:0:1}" | tr "[:lower:]" "[:upper:]")${arg[@]:1}"
|
||||||
|
MSBUILD_ARGS=(${MSBUILD_ARGS[@]} "$TARGET")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
echo -e "${CYAN}KoreBuild 1.0 Compatibility Mode Enabled${RESET}"
|
||||||
|
echo -e "${CYAN}KoreBuild 1.0 Command Line: ${@}${RESET}"
|
||||||
|
echo -e "${CYAN}KoreBuild 2.0 Command Line: ${MSBUILD_ARGS[@]}${RESET}"
|
||||||
|
else
|
||||||
|
MSBUILD_ARGS=("$@")
|
||||||
|
fi
|
||||||
|
|
||||||
|
export REPO_FOLDER=$PWD
|
||||||
|
export KOREBUILD_FOLDER="$(dirname $DIR)"
|
||||||
|
|
||||||
|
BUILD_ROOT="$REPO_FOLDER/.build"
|
||||||
|
KOREBUILD_ROOT="$( cd "$DIR/../../.." && pwd)"
|
||||||
|
ARTIFACTS_DIR="$REPO_FOLDER/artifacts"
|
||||||
|
[ -d $ARTIFACTS_DIR ] || mkdir $ARTIFACTS_DIR
|
||||||
|
|
||||||
|
DOTNET_INSTALL="$KOREBUILD_ROOT/build/dotnet/dotnet-install.sh"
|
||||||
|
DOTNET_VERSION_DIR="$KOREBUILD_ROOT/build"
|
||||||
|
|
||||||
|
MSBUILD_DIR="$BUILD_ROOT/MSBuildTools"
|
||||||
|
TOOLS_DIR="$BUILD_ROOT/Tools"
|
||||||
|
|
||||||
|
KOREBUILD_LOG="$BUILD_ROOT/korebuild.log"
|
||||||
|
[ ! -e "$KOREBUILD_LOG" ] || rm "$KOREBUILD_LOG"
|
||||||
|
|
||||||
|
MSBUILD_RSP="$BUILD_ROOT/korebuild.msbuild.rsp"
|
||||||
|
[ ! -e "$MSBUILD_RSP" ] || rm "$MSBUILD_RSP"
|
||||||
|
|
||||||
|
MSBUILD_LOG="$BUILD_ROOT/korebuild.msbuild.log"
|
||||||
|
[ ! -e "$MSBUILD_LOG" ] || rm "$MSBUILD_LOG"
|
||||||
|
|
||||||
|
|
||||||
|
__exec() {
|
||||||
|
local cmd=$1
|
||||||
|
shift
|
||||||
|
|
||||||
|
local cmdname=$(basename $cmd)
|
||||||
|
echo -e "${CYAN}> $cmdname $@${RESET}"
|
||||||
|
echo ">>>>> $cmd $@ <<<<<" >> $KOREBUILD_LOG
|
||||||
|
$cmd "$@" 2>&1 >> $KOREBUILD_LOG
|
||||||
|
|
||||||
|
local exitCode=$?
|
||||||
|
if [ $exitCode -ne 0 ]; then
|
||||||
|
echo -e "${RED}'$cmdname $@' failed with exit code $exitCode${RESET}" 1>&2
|
||||||
|
echo -e "${RED} check '$ARTIFACTS_DIR/korebuild.log' for more info.${RESET}" 1>&2
|
||||||
|
__end $exitCode
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_dotnet() {
|
||||||
|
versionFile="$DOTNET_VERSION_DIR/cli.version"
|
||||||
|
version=$(<$versionFile)
|
||||||
|
|
||||||
|
[ -z "$KOREBUILD_DOTNET_CHANNEL" ] && KOREBUILD_DOTNET_CHANNEL=preview
|
||||||
|
[ -z "$KOREBUILD_DOTNET_VERSION" ] && KOREBUILD_DOTNET_VERSION=$version
|
||||||
|
|
||||||
|
if [ ! -z "$KOREBUILD_SKIP_RUNTIME_INSTALL" ]; then
|
||||||
|
echo -e "${BLACK}Skipping runtime installation because KOREBUILD_SKIP_RUNTIME_INSTALL is set${RESET}"
|
||||||
|
|
||||||
|
# Add .NET installation directory to the path if it isn't yet included.
|
||||||
|
# Add to the _end_ in case preferred .NET CLI is not in the default location.
|
||||||
|
[[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$PATH:$DOTNET_INSTALL_DIR"
|
||||||
|
else
|
||||||
|
# Need to set this variable because by default the install script
|
||||||
|
# requires sudo
|
||||||
|
export DOTNET_INSTALL_DIR=~/.dotnet
|
||||||
|
chmod +x $DOTNET_INSTALL
|
||||||
|
|
||||||
|
__exec $DOTNET_INSTALL --channel $KOREBUILD_DOTNET_CHANNEL --version $KOREBUILD_DOTNET_VERSION >> $KOREBUILD_LOG
|
||||||
|
|
||||||
|
__exec $DOTNET_INSTALL --shared-runtime --channel preview --version 1.0.0 >> $KOREBUILD_LOG
|
||||||
|
|
||||||
|
# Add .NET installation directory to the path if it isn't yet included.
|
||||||
|
[[ ":$PATH:" != *":$DOTNET_INSTALL_DIR:"* ]] && export PATH="$DOTNET_INSTALL_DIR:$PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# workaround for CLI issue: https://github.com/dotnet/cli/issues/2143
|
||||||
|
DOTNET_PATH=`which dotnet | head -n 1`
|
||||||
|
ROOT_PATH=`dirname $DOTNET_PATH`
|
||||||
|
FOUND=`find $ROOT_PATH/shared -name dotnet`
|
||||||
|
if [ ! -z "$FOUND" ]; then
|
||||||
|
echo $FOUND | xargs rm
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_msbuild() {
|
||||||
|
if [ ! -d "$MSBUILD_DIR" ]; then
|
||||||
|
RID=`dotnet --info | grep "RID" | awk '{ print $2 }'`
|
||||||
|
|
||||||
|
mkdir -p $MSBUILD_DIR
|
||||||
|
cat "$KOREBUILD_ROOT/src/Microsoft.AspNetCore.Build/scripts/msbuild.project.template.json" | sed "s/RUNTIME/$RID/g" > "$MSBUILD_DIR/project.json"
|
||||||
|
cp "$KOREBUILD_ROOT/NuGet.config" "$MSBUILD_DIR"
|
||||||
|
|
||||||
|
echo -e "${GREEN}Preparing MSBuild ...${RESET}"
|
||||||
|
__exec dotnet restore "$MSBUILD_DIR/project.json" -v Minimal
|
||||||
|
__exec dotnet publish "$MSBUILD_DIR/project.json" -o "$MSBUILD_DIR/bin/pub"
|
||||||
|
|
||||||
|
echo -e "${GREEN}Preparing KoreBuild Tasks ...${RESET}"
|
||||||
|
__exec dotnet restore "$KOREBUILD_ROOT/src/Microsoft.AspNetCore.Build" -v Minimal
|
||||||
|
__exec dotnet publish "$KOREBUILD_ROOT/src/Microsoft.AspNetCore.Build" -o "$MSBUILD_DIR/bin/pub" -f "netcoreapp1.0"
|
||||||
|
else
|
||||||
|
echo -e "${CYAN}MSBuild already initialized, use --reset-korebuild to refresh it${RESET}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__join() {
|
||||||
|
local IFS="$1"
|
||||||
|
shift
|
||||||
|
echo "$*"
|
||||||
|
}
|
||||||
|
|
||||||
|
__end() {
|
||||||
|
local EXITCODE=$1
|
||||||
|
|
||||||
|
# Copy logs to artifacts
|
||||||
|
cp $MSBUILD_LOG $KOREBUILD_LOG $MSBUILD_RSP $ARTIFACTS_DIR 2>/dev/null >/dev/null
|
||||||
|
|
||||||
|
[ -e "$MSBUILD_LOG" ] && rm $MSBUILD_LOG
|
||||||
|
[ -e "$MSBUILD_RSP" ] && rm $MSBUILD_RSP
|
||||||
|
[ -e "$KOREBUILD_LOG" ] && rm $KOREBUILD_LOG
|
||||||
|
|
||||||
|
exit $EXITCODE
|
||||||
|
}
|
||||||
|
|
||||||
|
ensure_dotnet
|
||||||
|
ensure_msbuild
|
||||||
|
|
||||||
|
KOREBUILD_TARGETS_ROOT="$KOREBUILD_ROOT/src/Microsoft.AspNetCore.Build/targets"
|
||||||
|
|
||||||
|
PROJ="$REPO_FOLDER/makefile.proj"
|
||||||
|
if [ ! -e "$PROJ" ]; then
|
||||||
|
PROJ="$KOREBUILD_TARGETS_ROOT/makefile.proj"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > $MSBUILD_RSP <<ENDMSBUILDARGS
|
||||||
|
-nologo
|
||||||
|
"$PROJ"
|
||||||
|
-p:KoreBuildToolsPackages="$BUILD_DIR"
|
||||||
|
-p:KoreBuildTargetsPath="$KOREBUILD_TARGETS_ROOT"
|
||||||
|
-p:KoreBuildTasksPath="$MSBUILD_DIR/bin/pub/"
|
||||||
|
-fl
|
||||||
|
-flp:LogFile="$MSBUILD_LOG";Verbosity=diagnostic;Encoding=UTF-8
|
||||||
|
ENDMSBUILDARGS
|
||||||
|
__join $'\n' $MSBUILD_ARGS >> $MSBUILD_RSP
|
||||||
|
|
||||||
|
echo -e "${GREEN}Starting build...${RESET}"
|
||||||
|
echo -e "${CYAN}> msbuild $PROJ $@${RESET}"
|
||||||
|
|
||||||
|
# Enable "on error result next" ;P
|
||||||
|
"$MSBUILD_DIR/bin/pub/corerun" "$MSBUILD_DIR/bin/pub/MSBuild.dll" @"$MSBUILD_RSP"
|
||||||
|
__end $?
|
|
@ -0,0 +1,19 @@
|
||||||
|
{
|
||||||
|
"frameworks": {
|
||||||
|
"netcoreapp1.0": {
|
||||||
|
"imports": [ "dotnet5.5", "portable-net45+win8" ]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"NETStandard.Library": "1.6.0",
|
||||||
|
"Microsoft.NETCore.TestHost": "1.0.0",
|
||||||
|
"Microsoft.NETCore.Runtime.CoreCLR": "1.0.4",
|
||||||
|
"Microsoft.NETCore.Platforms": "1.1.0-*",
|
||||||
|
"System.Dynamic.Runtime": "4.0.11",
|
||||||
|
"NuGet.CommandLine.Xplat": "3.5.0-rc1-final",
|
||||||
|
"Microsoft.Build.Runtime": "15.1.0-preview-000370-00"
|
||||||
|
},
|
||||||
|
"runtimes": {
|
||||||
|
"RUNTIME": {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Put targets attached to the 'Clean' phase of the Standard Lifecycle here. -->
|
||||||
|
|
||||||
|
<Target Name="CleanArtifactsDirectory" BeforeTargets="Clean">
|
||||||
|
<RemoveDir Directories="$(ArtifactsDir)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CleanBinObjDirectories" BeforeTargets="Clean">
|
||||||
|
<ItemGroup>
|
||||||
|
<_ToClean Include="%(Projects.ProjectDir)bin" />
|
||||||
|
<_ToClean Include="%(Projects.ProjectDir)obj" />
|
||||||
|
</ItemGroup>
|
||||||
|
<RemoveDir Directories="@(_ToClean)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="CleanNpmModules" BeforeTargets="Clean">
|
||||||
|
<ItemGroup>
|
||||||
|
<_NpmToClean Include="%(NpmDirs.RootDir)%(NpmDirs.Directory)node_modules" />
|
||||||
|
</ItemGroup>
|
||||||
|
<RemoveDir Directories="@(_NpmToClean)" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Put targets attached to the 'Compile' phase of the Standard Lifecycle here. -->
|
||||||
|
|
||||||
|
<Target Name="DotNetBuild" BeforeTargets="Compile">
|
||||||
|
<ItemGroup>
|
||||||
|
<_ToBuild Include="@(Projects)" Condition="'$(BuildSourceOnly)' != 'true' Or '%(Projects.ProjectGroup)' == 'src'" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Delete Files="%(_ToBuild.GeneratedBuildInfoFile)" Condition="Exists(%(_ToBuild.GeneratedBuildInfoFile))" />
|
||||||
|
<WriteLinesToFile
|
||||||
|
Lines="[assembly: System.Reflection.AssemblyMetadata("CommitHash", "$(CommitHash)")]"
|
||||||
|
File="%(_ToBuild.GeneratedBuildInfoFile)"
|
||||||
|
Overwrite="true"
|
||||||
|
Condition="!Exists(%(_ToBuild.SharedSourcesDir)) And '$(CommitHash)' != ''" />
|
||||||
|
<Exec
|
||||||
|
Command="dotnet build --version-suffix "$(BuildVersionSuffix)" --configuration "$(Configuration)" $(DotNetBuild_Options) @(_ToBuild->'"%(FullPath)"', ' ')"
|
||||||
|
WorkingDirectory="$(RepositoryDir)" />
|
||||||
|
<Delete Files="%(_ToBuild.GeneratedBuildInfoFile)" Condition="Exists(%(_ToBuild.GeneratedBuildInfoFile))" />
|
||||||
|
</Target>
|
||||||
|
<Target Name="CopyBuildOutput" AfterTargets="DotNetBuild">
|
||||||
|
<ItemGroup>
|
||||||
|
<_ToCopy Include="%(Projects.ProjectDir)bin\**" Condition="'%(Projects.ProjectGroup)' == 'src'">
|
||||||
|
<ProjectName>%(Projects.ProjectName)</ProjectName>
|
||||||
|
</_ToCopy>
|
||||||
|
</ItemGroup>
|
||||||
|
<Copy SourceFiles="@(_ToCopy)" DestinationFiles="@(_ToCopy->'$(BuildDir)\%(ProjectName)\%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Put targets attached to the 'Initialize' phase of the Standard Lifecycle here. -->
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- "Private" helper properties" -->
|
||||||
|
<_StartYear>$([System.DateTime]::Parse($(ProductStartDate)).Year)</_StartYear>
|
||||||
|
<_CurrentYear>$([System.DateTime]::UtcNow.Year)</_CurrentYear>
|
||||||
|
<_YearsSinceStart>$([MSBuild]::Subtract($(_CurrentYear), $(_StartYear)))</_YearsSinceStart>
|
||||||
|
<_YearsSinceStart Condition="'$(_YearsSinceStart)' < 0">0</_YearsSinceStart>
|
||||||
|
<_DayBasedVersionNumber>$(_YearsSinceStart)$([System.DateTime]::UtcNow.ToString("MMdd"))</_DayBasedVersionNumber>
|
||||||
|
|
||||||
|
<!-- GROSS -->
|
||||||
|
<_SecondBasedTimeStamp_Str>$([System.DateTime]::UtcNow.Subtract($([System.DateTime]::Parse($(ProductStartDate)))).TotalSeconds.ToString())</_SecondBasedTimeStamp_Str>
|
||||||
|
<_SecondBasedTimeStamp>$([System.Int64]::Parse($(_SecondBasedTimeStamp_Str.Substring(0, $(_SecondBasedTimeStamp_Str.IndexOf("."))))).ToString("x9"))</_SecondBasedTimeStamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- The primary set of properties defining a Build of an ASP.NET Core repo. All overridable, in theory. -->
|
||||||
|
<Configuration Condition="'$(Configuration)' == ''">Debug</Configuration>
|
||||||
|
<RepositoryDir Condition="'$(RepositoryDir)' == ''">$(MSBuildStartupDirectory)</RepositoryDir>
|
||||||
|
<BuildQuality Condition="'$(BuildQuality)' == ''">alpha</BuildQuality>
|
||||||
|
<BuildVersion Condition="'$(BuildVersion)' == ''">1.0.0</BuildVersion>
|
||||||
|
<BuildNumber Condition="'$(BuildNumber)' == '' And '$(DOTNET_BUILD_VERSION)' != ''">$(DOTNET_BUILD_VERSION)</BuildNumber>
|
||||||
|
<BuildNumber Condition="'$(BuildNumber)' == ''">t$(_SecondBasedTimeStamp)</BuildNumber>
|
||||||
|
<Authors Condition="'$(Authors)' == '' And '$(DOTNET_AUTHOR)' != ''">$(DOTNET_AUTHOR)</Authors>
|
||||||
|
<Authors Condition="'$(Authors)' == ''">$(DefaultAuthors)</Authors>
|
||||||
|
<AssemblyFileNumber Condition="'$(AssemblyFileNumber)' == '' And '$(DOTNET_ASSEMBLY_FILE_VERSION)' != ''">$(DOTNET_ASSEMBLY_FILE_VERSION)</AssemblyFileNumber>
|
||||||
|
<AssemblyFileNumber Condition="'$(AssemblyFileNumber)' == ''">$(_DayBasedVersionNumber)</AssemblyFileNumber>
|
||||||
|
|
||||||
|
<DetectedBuildHost Condition="'$(TEAMCITY_VERSION)' != ''">TeamCity</DetectedBuildHost>
|
||||||
|
<DetectedBuildHost Condition="'$(TRAVIS)' != '' And '$(CONTINUOUS_INTEGRATION)' != ''">Travis</DetectedBuildHost>
|
||||||
|
<DetectedBuildHost Condition="'$(DetectedBuildHost)' == ''">Local Build</DetectedBuildHost>
|
||||||
|
<BuildHost Condition="'$(BuildHost)' == ''">$(DetectedBuildHost)</BuildHost>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- Properties derived from the above, not overridable -->
|
||||||
|
<AssemblyFileVersion>$(BuildVersion).$(AssemblyFileNumber)</AssemblyFileVersion>
|
||||||
|
<BuildVersionSuffix>$(BuildQuality)-$(BuildNumber)</BuildVersionSuffix>
|
||||||
|
<BuildSemanticVersion>$(BuildVersion)-$(BuildVersionSuffix)</BuildSemanticVersion>
|
||||||
|
|
||||||
|
<SourceDir>$([System.IO.Path]::Combine($(RepositoryDir), "src"))</SourceDir>
|
||||||
|
<TestDir>$([System.IO.Path]::Combine($(RepositoryDir), "test"))</TestDir>
|
||||||
|
<ToolsDir>$([System.IO.Path]::Combine($(RepositoryDir), "tools"))</ToolsDir>
|
||||||
|
<SamplesDir>$([System.IO.Path]::Combine($(RepositoryDir), "samples"))</SamplesDir>
|
||||||
|
<ArtifactsDir>$([System.IO.Path]::Combine($(RepositoryDir), "artifacts"))</ArtifactsDir>
|
||||||
|
<BuildDir>$([System.IO.Path]::Combine($(ArtifactsDir), "build"))</BuildDir>
|
||||||
|
<PackagesDir>$([System.IO.Path]::Combine($(ArtifactsDir), "packages"))</PackagesDir>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<!-- Locate things to be restored -->
|
||||||
|
<NpmDirs Include="$(RepositoryDir)/**/package.json" />
|
||||||
|
<BowerDirs Include="$(RepositoryDir)/**/bower.json" />
|
||||||
|
<GruntDirs Include="$(RepositoryDir)/**/gruntfile.js" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<UnresolvedProjects Include="$(SourceDir)/**/project.json" />
|
||||||
|
<UnresolvedProjects Include="$(TestDir)/**/project.json" />
|
||||||
|
<UnresolvedProjects Include="$(SamplesDir)/**/project.json" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="CollectCommitHash">
|
||||||
|
<GetGitCommitInfo RepositoryRoot="$(RepositoryDir)" WarnOnError="true">
|
||||||
|
<Output TaskParameter="Branch" PropertyName="GitBranch" />
|
||||||
|
<Output TaskParameter="CommitHash" PropertyName="CommitHash" />
|
||||||
|
</GetGitCommitInfo>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="DetectOSPlatform">
|
||||||
|
<DetectOSPlatform>
|
||||||
|
<Output TaskParameter="PlatformName" PropertyName="BuildPlatformName" />
|
||||||
|
</DetectOSPlatform>
|
||||||
|
<PropertyGroup>
|
||||||
|
<NuGetPath>$(MSBuildBinPath)/corerun $(MSBuildBinPath)/NuGet.CommandLine.XPlat.dll</NuGetPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="GatherProjectMetadata">
|
||||||
|
<GatherProjectMetadata Projects="@(UnresolvedProjects)">
|
||||||
|
<Output TaskParameter="UpdatedProjects" ItemName="Projects" />
|
||||||
|
</GatherProjectMetadata>
|
||||||
|
<ItemGroup>
|
||||||
|
<SourceProjects Include="@(Projects)" Condition="'%(Projects.ProjectGroup)' == 'src'" />
|
||||||
|
<TestProjects Include="@(Projects)" Condition="'%(Projects.ProjectGroup)' == 'test'" />
|
||||||
|
<SamplesProjects Include="@(Projects)" Condition="'%(Projects.ProjectGroup)' == 'samples'" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<InitializeBuildTargets>
|
||||||
|
CollectCommitHash;
|
||||||
|
DetectOSPlatform;
|
||||||
|
GatherProjectMetadata;
|
||||||
|
</InitializeBuildTargets>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Target Name="InitializeBuild" DependsOnTargets="$(InitializeBuildTargets)" BeforeTargets="Initialize">
|
||||||
|
<Message Text="Starting build $(BuildSemanticVersion) of commit $(CommitHash) (on branch '$(GitBranch)') within $(BuildHost)" Importance="high" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="Debug_DumpProperties" DependsOnTargets="Initialize">
|
||||||
|
<Message Text="BuildVersion: $(BuildVersion)" Importance="high" />
|
||||||
|
<Message Text="BuildQuality: $(BuildQuality)" Importance="high" />
|
||||||
|
<Message Text="BuildSemanticVersion: $(BuildSemanticVersion)" Importance="high" />
|
||||||
|
<Message Text="AssemblyFileVersion: $(AssemblyFileVersion)" Importance="high" />
|
||||||
|
<Message Text="RepositoryDir: $(RepositoryDir)" Importance="high" />
|
||||||
|
<Message Text="SourceDir: $(SourceDir)" Importance="high" />
|
||||||
|
<Message Text="TestDir: $(TestDir)" Importance="high" />
|
||||||
|
<Message Text="ToolsDir: $(ToolsDir)" Importance="high" />
|
||||||
|
<Message Text="SamplesDir: $(SamplesDir)" Importance="high" />
|
||||||
|
<Message Text="ArtifactsDir: $(ArtifactsDir)" Importance="high" />
|
||||||
|
<Message Text="BuildDir: $(BuildDir)" Importance="high" />
|
||||||
|
<Message Text="SourceProjects: @(SourceProjects)" Importance="high" />
|
||||||
|
<Message Text="TestProjects: @(TestProjects)" Importance="high" />
|
||||||
|
<Message Text="SamplesProjects: @(SamplesProjects)" Importance="high" />
|
||||||
|
<Message Text="Authors: $(Authors)" Importance="high" />
|
||||||
|
<Message Text="BuildPlatformName: $(BuildPlatformName)" Importance="high" />
|
||||||
|
<Message Text="NuGetPath: $(NuGetPath)" Importance="high" />
|
||||||
|
<Message Text="CommitHash: $(CommitHash)" Importance="high" />
|
||||||
|
<Message Text="GitBranch: $(GitBranch)" Importance="high" />
|
||||||
|
|
||||||
|
<DumpMetadata Items="@(Projects)" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Put targets attached to the 'Package' phase of the Standard Lifecycle here. -->
|
||||||
|
|
||||||
|
<Target Name="DotNetPack" BeforeTargets="Package">
|
||||||
|
<Exec
|
||||||
|
Command="dotnet pack --version-suffix "$(BuildVersionSuffix)" -o "$(BuildDir)" --no-build --configuration "$(Configuration)" $(DotNetPack_Options) "%(Projects.FullPath)""
|
||||||
|
Condition="'%(Projects.ProjectGroup)' == 'src'"
|
||||||
|
WorkingDirectory="$(RepositoryDir)" />
|
||||||
|
<ItemGroup>
|
||||||
|
<Packages Include="$(BuildDir)/*.nupkg" Exclude="$(BuildDir)/*.symbols.nupkg" />
|
||||||
|
<SymbolsPackages Include="$(BuildDir)/*.symbols.nupkg" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Put targets attached to the 'Prepare' phase of the Standard Lifecycle here. -->
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<RestorePackagesTargets>
|
||||||
|
DotNetRestore;
|
||||||
|
NpmRestore;
|
||||||
|
BowerRestore;
|
||||||
|
</RestorePackagesTargets>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Target Name="RestorePackages" DependsOnTargets="$(RestorePackagesTargets)" BeforeTargets="Prepare" />
|
||||||
|
|
||||||
|
<Target Name="RunGrunt" AfterTargets="RestorePackages" BeforeTargets="Prepare" Condition="'$(RunGrunt)' != 'skip' And '@(GruntDirs)' != ''">
|
||||||
|
<Exec
|
||||||
|
Command="grunt"
|
||||||
|
WorkingDirectory="%(GruntDirs.RootDir)%(GruntDirs.Directory)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="DotNetRestore" Condition="'$(DotNetRestore)' != 'skip'">
|
||||||
|
<ItemGroup>
|
||||||
|
<RestoreDirectories Include="$(SourceDir)" Condition="Exists('$(SourceDir)')" />
|
||||||
|
<RestoreDirectories Include="$(TestDir)" Condition="Exists('$(TestDir)')" />
|
||||||
|
<RestoreDirectories Include="$(SamplesDir)" Condition="Exists('$(SamplesDir)')" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Exec
|
||||||
|
Command="dotnet restore @(RestoreDirectories, ' ') $(DotNetRestore_Options)"
|
||||||
|
WorkingDirectory="$(RepositoryDir)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="NpmRestore" Condition="'$(NpmRestore)' != 'skip' And '@(NpmDirs)' != ''">
|
||||||
|
<Exec
|
||||||
|
Command="npm install $(NpmRestore_Options)"
|
||||||
|
WorkingDirectory="%(NpmDirs.RootDir)%(NpmDirs.Directory)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="BowerRestore" Condition="'$(BowerRestore)' != 'skip' And '@(BowerDirs)' != ''">
|
||||||
|
<Exec
|
||||||
|
Command="bower install $(BowerRestore_Options)"
|
||||||
|
WorkingDirectory="%(BowerDirs.RootDir)%(BowerDirs.Directory)" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Doesn't this belong in Clean? No, because Clean is about cleaning the repo, including all incremental build outputs
|
||||||
|
This is just cleaning the artifacts dir, which can be reconstituted from the incremental outputs, so we're OK with cleaning
|
||||||
|
it on every build, and it makes sure that if a project's build outputs shrink from build-to-build, we get the right outputs
|
||||||
|
-->
|
||||||
|
<Target Name="CleanPreviousBuildOutput" BeforeTargets="Prepare">
|
||||||
|
<RemoveDir Directories="$(BuildDir)" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<!-- Product-specific properties -->
|
||||||
|
<DefaultAuthors>Microsoft</DefaultAuthors>
|
||||||
|
<ProductStartDate>2015-01-01</ProductStartDate>
|
||||||
|
<BuildQuality>alpha</BuildQuality>
|
||||||
|
<BuildVersion>1.0.1</BuildVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Put targets attached to the 'Publish' phase of the Standard Lifecycle here. -->
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackageInstallDirectory Condition="'$(PackageInstallDirectory)' == ''">$([System.IO.Path]::Combine("$(ArtifactsDir)", "feed"))</PackageInstallDirectory>
|
||||||
|
<PackageInstallDirectory Condition="'$(PackageInstallDirectory)' == '' And '$(PACKAGES_PUBLISH_DIR)' != ''">$(PACKAGES_PUBLISH_DIR)</PackageInstallDirectory>
|
||||||
|
<PackagePublishFeed Condition="'$(PackagePublishFeed)' == '' And '$(NUGET_PUBLISH_FEED)' != ''">$(NUGET_PUBLISH_FEED)</PackagePublishFeed>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Target Name="InstallNuGetPackages" BeforeTargets="Publish">
|
||||||
|
<NuGetInstall Packages="@(Packages)" DestinationFolder="$(PackageInstallDirectory)" />
|
||||||
|
</Target>
|
||||||
|
<Target Name="PublishToFeed" BeforeTargets="Publish">
|
||||||
|
<Warning Text="Publishing a non-Release build to a feed can cause problems" Condition="'$(Configuration)' != 'Release'" />
|
||||||
|
<Message Text="Skipping publish to feed because PackagePublishFeed property was not specified" Importance="high" Condition="'$(PackagePublishFeed)' == ''" />
|
||||||
|
<NuGetResilientPush Packages="@(Packages)" Feed="$(PackagePublishFeed)" ApiKey="$(PackagePublishApiKey)" Condition="'$(PackagePublishFeed)' != ''" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Defines the ASP.NET Core Standard Build (a standard pattern for building the ASP.NET Core Repositories) -->
|
||||||
|
|
||||||
|
<Import Project="$(KoreBuildTasksPath)/Microsoft.AspNetCore.Build.tasks" />
|
||||||
|
|
||||||
|
<!-- The order of this technically doesn't matter but it's nice to keep them in the order they'll run :) -->
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)/Clean.targets" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)/Initialize.targets" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)/Prepare.targets" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)/Compile.targets" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)/Test.targets" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)/Package.targets" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)/Verify.targets" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)/Publish.targets" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,59 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Defines the Standard Lifecycle (a standard pattern for .NET Builds) -->
|
||||||
|
|
||||||
|
<!-- Don't do anything here! -->
|
||||||
|
<Target Name="Preinit">
|
||||||
|
<!-- Anything in or before this target can't easily be debugged for obvious reasons ;) -->
|
||||||
|
<WaitForDebugger Condition="'$(Debug)' == 'true'" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Place to do dynamic property initialiation -->
|
||||||
|
<!-- Initialize is ALWAYS run, regardless of what target the user requested (see makefile.proj's InitialTargets -->
|
||||||
|
<Target Name="Initialize" DependsOnTargets="Preinit">
|
||||||
|
<Message Text="*** Completed Initialize Phase ***" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Place to prepare the repo for the build -->
|
||||||
|
<Target Name="Prepare" DependsOnTargets="Initialize">
|
||||||
|
<Message Text="*** Completed Prepare Phase ***" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Place to compile projects -->
|
||||||
|
<Target Name="Compile" DependsOnTargets="Prepare">
|
||||||
|
<Message Text="*** Completed Compile Phase ***" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Place to run tests -->
|
||||||
|
<Target Name="Test" DependsOnTargets="Compile">
|
||||||
|
<Message Text="*** Completed Test Phase ***" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="Package" DependsOnTargets="Test">
|
||||||
|
<Message Text="*** Completed Package Phase ***" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Place to perform package verification -->
|
||||||
|
<Target Name="Verify" DependsOnTargets="Package">
|
||||||
|
<Message Text="*** Completed Verify Phase ***" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Place to publish build outputs -->
|
||||||
|
<Target Name="Publish" DependsOnTargets="Verify">
|
||||||
|
<Message Text="*** Completed Publish Phase ***" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Primary build target -->
|
||||||
|
<Target Name="Build" DependsOnTargets="Package">
|
||||||
|
<Message Text="*** Completed Build Phase ***" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Primary clean-up target -->
|
||||||
|
<Target Name="Clean" DependsOnTargets="Initialize">
|
||||||
|
<Message Text="*** Completed Clean Phase ***" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<!-- Targets used by CI/etc. Here so that they can be reconfigured via KoreBuild rather than messing with build scripts -->
|
||||||
|
<!-- The target invoked by Universe-Coherence when this repo is built -->
|
||||||
|
<Target Name="UniverseCoherenceBuild" DependsOnTargets="Verify" />
|
||||||
|
</Project>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Put targets attached to the 'Test' phase of the Standard Lifecycle here. -->
|
||||||
|
|
||||||
|
<Target Name="DotNetTest" BeforeTargets="Test">
|
||||||
|
<ItemGroup>
|
||||||
|
<_ToTest Include="@(TestProjects)" Condition="'$(BuildPlatformName)' == 'Windows' Or '%(TFM_netcoreapp1_0)' == 'true'" />
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<DotNetTestFrameworkArg Condition="'$(BuildPlatformName)' != 'Windows'">-f netcoreapp1.0</DotNetTestFrameworkArg>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Exec
|
||||||
|
Command="dotnet test --configuration "$(Configuration)" --no-build "%(_ToTest.FullPath)" $(DotNetTestFrameworkArg)"
|
||||||
|
WorkingDirectory="%(_ToTest.ProjectDir)" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- Put targets attached to the 'Verify' phase of the Standard Lifecycle here. -->
|
||||||
|
<PropertyGroup>
|
||||||
|
<PackageVerifierList>$([System.IO.Path]::Combine('$(RepositoryDir)', 'NuGetPackageVerifier.json'))</PackageVerifierList>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Target Name="VerifyNuGetPackages" BeforeTargets="Verify">
|
||||||
|
<Error Text="NuGetPackageVerifier only works on Windows right now :(" Condition="'$(BuildPlatformName)' != 'Windows'" />
|
||||||
|
|
||||||
|
<ResolvePackagedTool PackagesDir="$(KoreBuildToolsPackages)" PackageId="NuGetPackageVerifier" RelativePath="NuGetPackageVerifier.exe">
|
||||||
|
<Output TaskParameter="ToolPath" PropertyName="NuGetPackageVerifier" />
|
||||||
|
</ResolvePackagedTool>
|
||||||
|
<Exec
|
||||||
|
Command="$(NuGetPackageVerifier) "$(PackagesDir)" "$(PackageVerifierList)""
|
||||||
|
Condition="'$(Configuration)' == 'Release'" />
|
||||||
|
<Warning Text="Package verification only occurs on Release builds" Condition="'$(Configuration)' != 'Release'" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" InitialTargets="Initialize" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)\ProductInfo.props" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)\StandardLifecycle.targets" />
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)\StandardBuild.targets" />
|
||||||
|
</Project>
|
|
@ -38,7 +38,7 @@ if test ! -d $buildFolder; then
|
||||||
chmod +x $buildFile
|
chmod +x $buildFile
|
||||||
|
|
||||||
# Cleanup
|
# Cleanup
|
||||||
if test ! -d $tempFolder; then
|
if test -d $tempFolder; then
|
||||||
rm -rf $tempFolder
|
rm -rf $tempFolder
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
@ECHO OFF
|
||||||
|
|
||||||
|
REM KoreBuild 2.0
|
||||||
|
|
||||||
|
PowerShell -NoProfile -NoLogo -ExecutionPolicy unrestricted -Command "[System.Threading.Thread]::CurrentThread.CurrentCulture = ''; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '';& '%~dp0build.ps1' %*; exit $LASTEXITCODE"
|
|
@ -0,0 +1,110 @@
|
||||||
|
#Requires -Version 4
|
||||||
|
# Don't remove the next line, it's used by Universe to detect a KoreBuild 2.0-based repo.
|
||||||
|
# KoreBuild 2.0
|
||||||
|
|
||||||
|
<#
|
||||||
|
.SYNOPSIS
|
||||||
|
Builds this project.
|
||||||
|
.DESCRIPTION
|
||||||
|
Uses the ASP.NET Core Build System (KoreBuild) to build this repository. If not already present in the '.build' directory, this script downloads the latest copy of the KoreBuild tools from https://github.com/aspnet/KoreBuild (or the URL/Branch provided in the arguments). Eventually, MSBuild is invoked to perform the actual build. Additional arguments provided to this script are passed along to MSBuild. So, for example, to build a specific target, use '.\build.ps1 /t:Target'
|
||||||
|
.PARAMETER ResetKoreBuild
|
||||||
|
Deletes the '.build' directory which contains the current set of KoreBuild scripts before building. This forces the build script to re-download the latest version of the scripts.
|
||||||
|
.PARAMETER KoreBuildUrl
|
||||||
|
The URL from which to download the KoreBuild ZIP
|
||||||
|
.PARAMETER KoreBuildBranch
|
||||||
|
The branch in the default KoreBuild repository (https://github.com/aspnet/KoreBuild) to download. This overrides the -KoreBuildUrl parameter.
|
||||||
|
.PARAMETER KoreKoreBuildRoot
|
||||||
|
The local folder from which to retrieve KoreBuild files (designed for use when testing KoreBuild changes). This overrides both the -KoreBuildUrl and -KoreBuildBranch parameters.
|
||||||
|
#>
|
||||||
|
|
||||||
|
[CmdletBinding(PositionalBinding=$false,DefaultParameterSetName="DownloadDefault")]
|
||||||
|
param(
|
||||||
|
[Alias("r")][switch]$ResetKoreBuild,
|
||||||
|
[Parameter(ParameterSetName="DownloadByUrl")][Alias("u")][string]$KoreBuildUrl,
|
||||||
|
[Parameter(ParameterSetName="DownloadByBranch")][Alias("b")][string]$KoreBuildBranch,
|
||||||
|
[Parameter(ParameterSetName="DownloadFromFolder")]$KoreBuildFolder,
|
||||||
|
[Parameter(ValueFromRemainingArguments=$true)][string[]]$KoreBuildArgs)
|
||||||
|
|
||||||
|
function DownloadWithRetry([string] $url, [string] $downloadLocation, [int] $retries)
|
||||||
|
{
|
||||||
|
while($true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Invoke-WebRequest $url -OutFile $downloadLocation | Out-Null
|
||||||
|
break
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
$exceptionMessage = $_.Exception.Message
|
||||||
|
Write-Host "Failed to download '$url': $exceptionMessage"
|
||||||
|
if ($retries -gt 0) {
|
||||||
|
$retries--
|
||||||
|
Write-Host "Waiting 10 seconds before retrying. Retries left: $retries"
|
||||||
|
Start-Sleep -Seconds 10
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$exception = $_.Exception
|
||||||
|
throw $exception
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($PSCmdlet.ParameterSetName -eq "DownloadDefault") {
|
||||||
|
if(!$KoreBuildUrl) {
|
||||||
|
$KoreBuildUrl = $env:KOREBUILD_ZIP
|
||||||
|
}
|
||||||
|
if(!$KoreBuildUrl) {
|
||||||
|
$KoreBuildUrl = "https://github.com/aspnet/KoreBuild/archive/dev.zip"
|
||||||
|
}
|
||||||
|
} elseif($PSCmdlet.ParameterSetName -eq "DownloadByBranch") {
|
||||||
|
$KoreBuildUrl = "https://github.com/aspnet/KoreBuild/archive/$KoreBuildBranch.zip"
|
||||||
|
} # No need for an 'else' block, since KoreBuildUrl has been set!
|
||||||
|
|
||||||
|
$BuildFolder = Join-Path $PSScriptRoot ".build"
|
||||||
|
$KoreBuildRoot = Join-Path $BuildFolder "KoreBuild"
|
||||||
|
$BuildFile = Join-Path $KoreBuildRoot "scripts\KoreBuild.ps1"
|
||||||
|
|
||||||
|
if ($ResetKoreBuild -and (Test-Path $BuildFolder)) {
|
||||||
|
Write-Host -ForegroundColor Green "Cleaning old Build folder to force a reset ..."
|
||||||
|
del -rec -for $BuildFolder
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(Test-Path $KoreBuildRoot)) {
|
||||||
|
if($KoreBuildFolder) {
|
||||||
|
Write-Host -ForegroundColor Green "Copying local KoreBuild from $KoreBuildFolder ..."
|
||||||
|
cp -rec $KoreBuildFolder $KoreBuildRoot
|
||||||
|
} else {
|
||||||
|
Write-Host -ForegroundColor Green "Downloading KoreBuild from $KoreBuildUrl ..."
|
||||||
|
$KoreBuildDir = Join-Path ([IO.Path]::GetTempPath()) $([IO.Path]::GetRandomFileName())
|
||||||
|
mkdir $KoreBuildDir | Out-Null
|
||||||
|
$KoreBuildZip = Join-Path $KoreBuildDir "korebuild.zip"
|
||||||
|
DownloadWithRetry -url $KoreBuildUrl -downloadLocation $KoreBuildZip -retries 6
|
||||||
|
|
||||||
|
$KoreBuildExtract = Join-Path $KoreBuildDir "extract"
|
||||||
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||||
|
[System.IO.Compression.ZipFile]::ExtractToDirectory($KoreBuildZip, $KoreBuildExtract)
|
||||||
|
|
||||||
|
pushd "$KoreBuildExtract\*"
|
||||||
|
cp -rec . $KoreBuildRoot
|
||||||
|
popd
|
||||||
|
|
||||||
|
if (Test-Path $KoreBuildDir) {
|
||||||
|
del -rec -for $KoreBuildDir
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(($KoreBuildArgs -contains "-t:") -or ($KoreBuildArgs -contains "-p:")) {
|
||||||
|
throw "Due to PowerShell weirdness, you need to use '/t:' and '/p:' to pass targets and properties to MSBuild"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Launch KoreBuild
|
||||||
|
try {
|
||||||
|
pushd $PSScriptRoot
|
||||||
|
& "$BuildFile" @KoreBuildArgs
|
||||||
|
} finally {
|
||||||
|
popd
|
||||||
|
}
|
|
@ -0,0 +1,113 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# KoreBuild 2.0
|
||||||
|
|
||||||
|
# Colors
|
||||||
|
GREEN="\033[1;32m"
|
||||||
|
BLACK="\033[0;30m"
|
||||||
|
RED="\033[0;31m"
|
||||||
|
RESET="\033[0m"
|
||||||
|
|
||||||
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
cd $DIR
|
||||||
|
|
||||||
|
show_help() {
|
||||||
|
echo "Usage: $0 [-r] [--] [arguments to msbuild]"
|
||||||
|
echo " $0 [-r] [-u <URL>] [--] [arguments to msbuild]"
|
||||||
|
echo " $0 [-r] [-b <BRANCH>] [--] [arguments to msbuild]"
|
||||||
|
echo ""
|
||||||
|
echo "Arguments:"
|
||||||
|
echo " -r, --reset-korebuild Delete the current `.build` directory and re-fetch KoreBuild"
|
||||||
|
echo " -u, --korebuild-url <URL> Fetch KoreBuild from URL"
|
||||||
|
echo " -b, --korebuild-branch <BRANCH> Fetch KoreBuild from BRANCH in the default repository (https://github.com/aspnet/KoreBuild)"
|
||||||
|
echo " --korebuild-dir <DIR> Copy KoreBuild from DIR instead of downloading it"
|
||||||
|
echo " -- Consider all remaining arguments arguments to MSBuild when building the repo."
|
||||||
|
echo ""
|
||||||
|
echo "Notes:"
|
||||||
|
echo " The '--' switch is only necessary when you want to pass an argument that would otherwise be recognized by this"
|
||||||
|
echo " script to MSBuild. By default, any unrecognized argument will be forwarded to MSBuild."
|
||||||
|
echo ""
|
||||||
|
echo " If you wish to build a specific target from the MSBuild project file, use the '-t:<TARGET>' switch, which will be forwarded"
|
||||||
|
echo " to MSBuild. For example `.\build.sh -t:Verify`"
|
||||||
|
}
|
||||||
|
|
||||||
|
while [[ $# > 0 ]]; do
|
||||||
|
case $1 in
|
||||||
|
-h|-\?|--help)
|
||||||
|
show_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
-r|--reset-korebuild)
|
||||||
|
KOREBUILD_RESET=1
|
||||||
|
;;
|
||||||
|
-u|--korebuild-url)
|
||||||
|
KOREBUILD_URL=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-b|--korebuild-branch)
|
||||||
|
KOREBUILD_BRANCH=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--korebuild-dir)
|
||||||
|
KOREBUILD_LOCAL=$2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
shift
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z $KOREBUILD_URL ]; then
|
||||||
|
if [ ! -z $KOREBUILD_BRANCH ]; then
|
||||||
|
KOREBUILD_URL="https://github.com/aspnet/KoreBuild/tarball/$KOREBUILD_BRANCH"
|
||||||
|
else
|
||||||
|
KOREBUILD_URL="https://github.com/aspnet/KoreBuild/tarball/dev"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_FOLDER="$DIR/.build"
|
||||||
|
KOREBUILD_ROOT="$BUILD_FOLDER/KoreBuild"
|
||||||
|
BUILD_FILE="$KOREBUILD_ROOT/scripts/KoreBuild.sh"
|
||||||
|
|
||||||
|
if [[ -d $BUILD_FOLDER && $KOREBUILD_RESET = "1" ]]; then
|
||||||
|
echo -e "${GREEN}Cleaning old KoreBuild folder to force a reset ...${RESET}"
|
||||||
|
rm -Rf $BUILD_FOLDER
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d $BUILD_FOLDER ]; then
|
||||||
|
mkdir -p $BUILD_FOLDER
|
||||||
|
if [ ! -z $KOREBUILD_LOCAL ]; then
|
||||||
|
echo -e "${GREEN}Copying KoreBuild from $KOREBUILD_LOCAL ...${RESET}"
|
||||||
|
cp -R "$KOREBUILD_LOCAL" "$KOREBUILD_ROOT"
|
||||||
|
else
|
||||||
|
echo -e "${GREEN}Downloading KoreBuild from $KOREBUILD_URL ...${RESET}"
|
||||||
|
|
||||||
|
KOREBUILD_DIR=`mktemp -d`
|
||||||
|
KOREBUILD_TAR="$KOREBUILD_DIR/korebuild.tar.gz"
|
||||||
|
|
||||||
|
retries=6
|
||||||
|
until (wget -O $KOREBUILD_TAR $KOREBUILD_URL 2>/dev/null || curl -o $KOREBUILD_TAR --location $KOREBUILD_URL 2>/dev/null); do
|
||||||
|
echo -e "${RED}Failed to download '$KOREBUILD_TAR'${RESET}"
|
||||||
|
if [ "$retries" -le 0 ]; then
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
retries=$((retries - 1))
|
||||||
|
echo "${BLACK}Waiting 10 seconds before retrying. Retries left: $retries${RESET}"
|
||||||
|
sleep 10s
|
||||||
|
done
|
||||||
|
|
||||||
|
mkdir $KOREBUILD_ROOT
|
||||||
|
tar xf $KOREBUILD_TAR --strip-components 1 --directory $KOREBUILD_ROOT
|
||||||
|
rm -Rf $KOREBUILD_DIR
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd $DIR
|
||||||
|
chmod a+x $BUILD_FILE
|
||||||
|
$BUILD_FILE "$@"
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"frameworks": {
|
||||||
|
"net451": { }
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"NuGetPackageVerifier": "1.0.1-*"
|
||||||
|
}
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче