Making some of the testbase methods protected.
Renaming variables according to code review comments. Adding the folder logic to the builder tests. Creating a separate compilation folder during the build.
This commit is contained in:
parent
b459c3665e
commit
fdea0b87e0
24 changed files with 132 additions and 131 deletions
|
@ -19,7 +19,6 @@ $IntermediatePackagesDir = "$RepoRoot\artifacts\packages\intermediate"
|
||||||
$PackagesDir = "$RepoRoot\artifacts\packages"
|
$PackagesDir = "$RepoRoot\artifacts\packages"
|
||||||
|
|
||||||
New-Item -ItemType Directory -Force -Path $IntermediatePackagesDir
|
New-Item -ItemType Directory -Force -Path $IntermediatePackagesDir
|
||||||
New-Item -ItemType Directory -Force -Path $PackagesDir\$Configuration\$Tfm
|
|
||||||
|
|
||||||
$Projects = @(
|
$Projects = @(
|
||||||
"Microsoft.DotNet.Cli.Utils",
|
"Microsoft.DotNet.Cli.Utils",
|
||||||
|
@ -30,12 +29,10 @@ $Projects = @(
|
||||||
"Microsoft.Extensions.Testing.Abstractions"
|
"Microsoft.Extensions.Testing.Abstractions"
|
||||||
)
|
)
|
||||||
|
|
||||||
cp $Stage2Dir\bin\* $PackagesDir\$Configuration\$Tfm -force -recurse
|
|
||||||
|
|
||||||
foreach ($ProjectName in $Projects) {
|
foreach ($ProjectName in $Projects) {
|
||||||
$ProjectFile = "$RepoRoot\src\$ProjectName\project.json"
|
$ProjectFile = "$RepoRoot\src\$ProjectName\project.json"
|
||||||
|
|
||||||
& $toolsDir\dotnet pack "$ProjectFile" --basepath "$PackagesDir" --output "$IntermediatePackagesDir" --configuration "$Configuration" $versionArg
|
& $toolsDir\dotnet pack "$ProjectFile" --basepath "$Stage2CompilationDir\bin" --output "$IntermediatePackagesDir" --configuration "$Configuration" $versionArg
|
||||||
if (!$?) {
|
if (!$?) {
|
||||||
Write-Host "$toolsDir\dotnet pack failed for: $ProjectFile"
|
Write-Host "$toolsDir\dotnet pack failed for: $ProjectFile"
|
||||||
Exit 1
|
Exit 1
|
||||||
|
|
|
@ -12,7 +12,9 @@ $OutputDir = "$RepoRoot\artifacts\$Rid"
|
||||||
$DnxDir = "$OutputDir\dnx"
|
$DnxDir = "$OutputDir\dnx"
|
||||||
$DnxRoot = "$DnxDir\bin"
|
$DnxRoot = "$DnxDir\bin"
|
||||||
$Stage1Dir = "$OutputDir\stage1"
|
$Stage1Dir = "$OutputDir\stage1"
|
||||||
|
$Stage1CompilationDir = "$OutputDir\stage1compilation"
|
||||||
$Stage2Dir = "$OutputDir\stage2"
|
$Stage2Dir = "$OutputDir\stage2"
|
||||||
|
$Stage2CompilationDir = "$OutputDir\stage2compilation"
|
||||||
$HostDir = "$OutputDir\corehost"
|
$HostDir = "$OutputDir\corehost"
|
||||||
$PackageDir = "$RepoRoot\artifacts\packages\dnvm"
|
$PackageDir = "$RepoRoot\artifacts\packages\dnvm"
|
||||||
$env:ReleaseSuffix = "beta"
|
$env:ReleaseSuffix = "beta"
|
||||||
|
|
|
@ -21,7 +21,9 @@ export OUTPUT_ROOT=$REPOROOT/artifacts/$RID
|
||||||
export DNX_DIR=$OUTPUT_ROOT/dnx
|
export DNX_DIR=$OUTPUT_ROOT/dnx
|
||||||
export DNX_ROOT=$DNX_DIR/bin
|
export DNX_ROOT=$DNX_DIR/bin
|
||||||
export STAGE1_DIR=$OUTPUT_ROOT/stage1
|
export STAGE1_DIR=$OUTPUT_ROOT/stage1
|
||||||
|
export STAGE1_COMPILATION_DIR=$OUTPUT_ROOT/stage1compilation
|
||||||
export STAGE2_DIR=$OUTPUT_ROOT/stage2
|
export STAGE2_DIR=$OUTPUT_ROOT/stage2
|
||||||
|
export STAGE2_COMPILATION_DIR=$OUTPUT_ROOT/stage2compilation
|
||||||
export HOST_DIR=$OUTPUT_ROOT/corehost
|
export HOST_DIR=$OUTPUT_ROOT/corehost
|
||||||
export RELEASE_SUFFIX=beta
|
export RELEASE_SUFFIX=beta
|
||||||
export CHANNEL=$RELEASE_SUFFIX
|
export CHANNEL=$RELEASE_SUFFIX
|
||||||
|
|
|
@ -9,6 +9,6 @@ header "Compiling stage1 dotnet using downloaded stage0 ..."
|
||||||
$StartPath = $env:PATH
|
$StartPath = $env:PATH
|
||||||
$env:PATH = "$env:DOTNET_INSTALL_DIR\cli\bin;$StartPath"
|
$env:PATH = "$env:DOTNET_INSTALL_DIR\cli\bin;$StartPath"
|
||||||
|
|
||||||
_ "$RepoRoot\scripts\compile\compile-stage.ps1" @("$Tfm","$Rid","$Configuration","$Stage1Dir","$RepoRoot","$HostDir")
|
_ "$RepoRoot\scripts\compile\compile-stage.ps1" @("$Tfm","$Rid","$Configuration","$Stage1Dir","$RepoRoot","$HostDir", "$Stage1CompilationDir")
|
||||||
|
|
||||||
$env:PATH=$StartPath
|
$env:PATH=$StartPath
|
|
@ -21,6 +21,6 @@ export PATH=$DOTNET_INSTALL_DIR/bin:$PATH
|
||||||
|
|
||||||
# Build Stage 1
|
# Build Stage 1
|
||||||
header "Building stage1 dotnet using downloaded stage0 ..."
|
header "Building stage1 dotnet using downloaded stage0 ..."
|
||||||
OUTPUT_DIR=$STAGE1_DIR $REPOROOT/scripts/compile/compile-stage.sh
|
COMPILATION_OUTPUT_DIR=$STAGE1_COMPILATION_DIR OUTPUT_DIR=$STAGE1_DIR $REPOROOT/scripts/compile/compile-stage.sh
|
||||||
|
|
||||||
export PATH=$StartPath
|
export PATH=$StartPath
|
|
@ -10,6 +10,6 @@ $StartPath = $env:PATH
|
||||||
$env:PATH = "$Stage1Dir\bin;$env:PATH"
|
$env:PATH = "$Stage1Dir\bin;$env:PATH"
|
||||||
|
|
||||||
# Compile
|
# Compile
|
||||||
_ "$RepoRoot\scripts\compile\compile-stage.ps1" @("$Tfm","$Rid","$Configuration","$Stage2Dir","$RepoRoot","$HostDir")
|
_ "$RepoRoot\scripts\compile\compile-stage.ps1" @("$Tfm","$Rid","$Configuration","$Stage2Dir","$RepoRoot","$HostDir", "$Stage2CompilationDir")
|
||||||
|
|
||||||
$env:PATH=$StartPath
|
$env:PATH=$StartPath
|
|
@ -23,7 +23,7 @@ export PATH=$STAGE1_DIR/bin:$PATH
|
||||||
|
|
||||||
# Compile Stage 2
|
# Compile Stage 2
|
||||||
header "Compiling stage2 dotnet using just-built stage1 ..."
|
header "Compiling stage2 dotnet using just-built stage1 ..."
|
||||||
OUTPUT_DIR=$STAGE2_DIR $REPOROOT/scripts/compile/compile-stage.sh
|
COMPILATION_OUTPUT_DIR=$STAGE2_COMPILATION_DIR OUTPUT_DIR=$STAGE2_DIR $REPOROOT/scripts/compile/compile-stage.sh
|
||||||
|
|
||||||
export DOTNET_HOME=$STAGE2_DIR
|
export DOTNET_HOME=$STAGE2_DIR
|
||||||
export DOTNET_TOOLS=$STAGE2_DIR
|
export DOTNET_TOOLS=$STAGE2_DIR
|
|
@ -9,7 +9,8 @@ param(
|
||||||
[Parameter(Mandatory=$true)][string]$Configuration,
|
[Parameter(Mandatory=$true)][string]$Configuration,
|
||||||
[Parameter(Mandatory=$true)][string]$OutputDir,
|
[Parameter(Mandatory=$true)][string]$OutputDir,
|
||||||
[Parameter(Mandatory=$true)][string]$RepoRoot,
|
[Parameter(Mandatory=$true)][string]$RepoRoot,
|
||||||
[Parameter(Mandatory=$true)][string]$HostDir)
|
[Parameter(Mandatory=$true)][string]$HostDir,
|
||||||
|
[Parameter(Mandatory=$true)][string]$CompilationOutputDir)
|
||||||
|
|
||||||
$Projects = @(
|
$Projects = @(
|
||||||
"Microsoft.DotNet.Cli",
|
"Microsoft.DotNet.Cli",
|
||||||
|
@ -49,35 +50,47 @@ $FilesToClean = @(
|
||||||
)
|
)
|
||||||
|
|
||||||
$RuntimeOutputDir = "$OutputDir\runtime\coreclr"
|
$RuntimeOutputDir = "$OutputDir\runtime\coreclr"
|
||||||
$binariesOutputDir = "$OutputDir\bin\$Configuration\$Tfm"
|
$binariesOutputDir = "$CompilationOutputDir\bin\$Configuration\$Tfm"
|
||||||
$runtimeBinariesOutputDir = "$RuntimeOutputDir\$Configuration\$Tfm"
|
$runtimeBinariesOutputDir = "$CompilationOutputDir\runtime\coreclr\$Configuration\$Tfm"
|
||||||
|
|
||||||
|
if(!(Test-Path $OutputDir\bin))
|
||||||
|
{
|
||||||
|
mkdir $OutputDir\bin | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(Test-Path $RuntimeOutputDir))
|
||||||
|
{
|
||||||
|
mkdir $RuntimeOutputDir | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
# Publish each project
|
# Publish each project
|
||||||
$Projects | ForEach-Object {
|
$Projects | ForEach-Object {
|
||||||
dotnet publish --native-subdirectory --framework "$Tfm" --runtime "$Rid" --output "$OutputDir\bin" --configuration "$Configuration" "$RepoRoot\src\$_"
|
dotnet publish --native-subdirectory --framework "$Tfm" --runtime "$Rid" --output "$CompilationOutputDir\bin" --configuration "$Configuration" "$RepoRoot\src\$_"
|
||||||
if (!$?) {
|
if (!$?) {
|
||||||
Write-Host Command failed: dotnet publish --native-subdirectory --framework "$Tfm" --runtime "$Rid" --output "$OutputDir\bin" --configuration "$Configuration" "$RepoRoot\src\$_"
|
Write-Host Command failed: dotnet publish --native-subdirectory --framework "$Tfm" --runtime "$Rid" --output "$CompilationOutputDir\bin" --configuration "$Configuration" "$RepoRoot\src\$_"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Path $binariesOutputDir) {
|
if (! (Test-Path $binariesOutputDir)) {
|
||||||
cp $binariesOutputDir\* $OutputDir\bin -force -recurse
|
$binariesOutputDir = "$CompilationOutputDir\bin"
|
||||||
Remove-Item $binariesOutputDir -recurse
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cp $binariesOutputDir\* $OutputDir\bin -force -recurse
|
||||||
|
|
||||||
# Publish the runtime
|
# Publish the runtime
|
||||||
dotnet publish --framework "$Tfm" --runtime "$Rid" --output "$RuntimeOutputDir" --configuration "$Configuration" "$RepoRoot\src\Microsoft.DotNet.Runtime"
|
dotnet publish --framework "$Tfm" --runtime "$Rid" --output "$CompilationOutputDir\runtime\coreclr" --configuration "$Configuration" "$RepoRoot\src\Microsoft.DotNet.Runtime"
|
||||||
if (!$?) {
|
if (!$?) {
|
||||||
Write-Host Command failed: dotnet publish --framework "$Tfm" --runtime "$Rid" --output "$RuntimeOutputDir" --configuration "$Configuration" "$RepoRoot\src\Microsoft.DotNet.Runtime"
|
Write-Host Command failed: dotnet publish --framework "$Tfm" --runtime "$Rid" --output "$CompilationOutputDir\runtime\coreclr" --configuration "$Configuration" "$RepoRoot\src\Microsoft.DotNet.Runtime"
|
||||||
Exit 1
|
Exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Test-Path $runtimeBinariesOutputDir) {
|
if (! (Test-Path $runtimeBinariesOutputDir)) {
|
||||||
cp $runtimeBinariesOutputDir\* $RuntimeOutputDir -force -recurse
|
$runtimeBinariesOutputDir = "$CompilationOutputDir\runtime\coreclr"
|
||||||
Remove-Item $runtimeBinariesOutputDir -recurse
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cp $runtimeBinariesOutputDir\* $RuntimeOutputDir -force -recurse
|
||||||
|
|
||||||
# Clean up bogus additional files
|
# Clean up bogus additional files
|
||||||
$FilesToClean | ForEach-Object {
|
$FilesToClean | ForEach-Object {
|
||||||
$path = Join-Path $RuntimeOutputDir $_
|
$path = Join-Path $RuntimeOutputDir $_
|
||||||
|
|
|
@ -21,6 +21,7 @@ source "$DIR/../common/_common.sh"
|
||||||
[ ! -z "$CONFIGURATION" ] || die "Missing required environment variable CONFIGURATION"
|
[ ! -z "$CONFIGURATION" ] || die "Missing required environment variable CONFIGURATION"
|
||||||
[ ! -z "$OUTPUT_DIR" ] || die "Missing required environment variable OUTPUT_DIR"
|
[ ! -z "$OUTPUT_DIR" ] || die "Missing required environment variable OUTPUT_DIR"
|
||||||
[ ! -z "$HOST_DIR" ] || die "Missing required environment variable HOST_DIR"
|
[ ! -z "$HOST_DIR" ] || die "Missing required environment variable HOST_DIR"
|
||||||
|
[ ! -z "$COMPILATION_OUTPUT_DIR" ] || die "Missing required environment variable COMPILATION_OUTPUT_DIR"
|
||||||
|
|
||||||
PROJECTS=( \
|
PROJECTS=( \
|
||||||
Microsoft.DotNet.Cli \
|
Microsoft.DotNet.Cli \
|
||||||
|
@ -56,29 +57,32 @@ FILES_TO_CLEAN=( \
|
||||||
)
|
)
|
||||||
|
|
||||||
RUNTIME_OUTPUT_DIR="$OUTPUT_DIR/runtime/coreclr"
|
RUNTIME_OUTPUT_DIR="$OUTPUT_DIR/runtime/coreclr"
|
||||||
BINARIES_OUTPUT_DIR="$OUTPUT_DIR/bin/$CONFIGURATION/$TFM"
|
BINARIES_OUTPUT_DIR="$COMPILATION_OUTPUT_DIR/bin/$CONFIGURATION/$TFM"
|
||||||
RUNTIME_BINARIES_OUTPUT_DIR="$RUNTIME_OUTPUT_DIR/$CONFIGURATION/$TFM"
|
RUNTIME_BINARIES_OUTPUT_DIR="$COMPILATION_OUTPUT_DIR/runtime/coreclr/$CONFIGURATION/$TFM"
|
||||||
|
|
||||||
|
mkdir -p "$OUTPUT_DIR/bin"
|
||||||
|
mkdir -p "$RUNTIME_OUTPUT_DIR"
|
||||||
|
|
||||||
for project in ${PROJECTS[@]}
|
for project in ${PROJECTS[@]}
|
||||||
do
|
do
|
||||||
echo dotnet publish --native-subdirectory --framework "$TFM" --output "$OUTPUT_DIR/bin" --configuration "$CONFIGURATION" "$REPOROOT/src/$project"
|
echo dotnet publish --native-subdirectory --framework "$TFM" --output "$COMPILATION_OUTPUT_DIR/bin" --configuration "$CONFIGURATION" "$REPOROOT/src/$project"
|
||||||
dotnet publish --native-subdirectory --framework "$TFM" --output "$OUTPUT_DIR/bin" --configuration "$CONFIGURATION" "$REPOROOT/src/$project"
|
dotnet publish --native-subdirectory --framework "$TFM" --output "$COMPILATION_OUTPUT_DIR/bin" --configuration "$CONFIGURATION" "$REPOROOT/src/$project"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -d "$BINARIES_OUTPUT_DIR" ]
|
if [ ! -d "$BINARIES_OUTPUT_DIR" ]
|
||||||
then
|
then
|
||||||
cp -R -f $BINARIES_OUTPUT_DIR/* $OUTPUT_DIR/bin
|
BINARIES_OUTPUT_DIR="$COMPILATION_OUTPUT_DIR/bin"
|
||||||
fi
|
fi
|
||||||
rm -rf $OUTPUT_DIR/bin/$CONFIGURATION
|
cp -R -f $BINARIES_OUTPUT_DIR/* $OUTPUT_DIR/bin
|
||||||
|
|
||||||
# Bring in the runtime
|
# Bring in the runtime
|
||||||
dotnet publish --output "$RUNTIME_OUTPUT_DIR" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Runtime"
|
dotnet publish --output "$COMPILATION_OUTPUT_DIR/runtime/coreclr" --configuration "$CONFIGURATION" "$REPOROOT/src/Microsoft.DotNet.Runtime"
|
||||||
|
|
||||||
if [ -d "$RUNTIME_BINARIES_OUTPUT_DIR" ]
|
if [ ! -d "$RUNTIME_BINARIES_OUTPUT_DIR" ]
|
||||||
then
|
then
|
||||||
cp -R -f $RUNTIME_BINARIES_OUTPUT_DIR/* $RUNTIME_OUTPUT_DIR
|
RUNTIME_BINARIES_OUTPUT_DIR="$COMPILATION_OUTPUT_DIR/runtime/coreclr"
|
||||||
fi
|
fi
|
||||||
rm -rf "$RUNTIME_OUTPUT_DIR/$CONFIGURATION"
|
cp -R -f $RUNTIME_BINARIES_OUTPUT_DIR/* $RUNTIME_OUTPUT_DIR
|
||||||
|
|
||||||
# Clean up bogus additional files
|
# Clean up bogus additional files
|
||||||
for file in ${FILES_TO_CLEAN[@]}
|
for file in ${FILES_TO_CLEAN[@]}
|
||||||
|
|
|
@ -28,7 +28,6 @@ $TestProjects | ForEach-Object {
|
||||||
|
|
||||||
if (Test-Path $TestBinRoot\$Configuration\dnxcore50) {
|
if (Test-Path $TestBinRoot\$Configuration\dnxcore50) {
|
||||||
cp $TestBinRoot\$Configuration\dnxcore50\* $TestBinRoot -force -recurse
|
cp $TestBinRoot\$Configuration\dnxcore50\* $TestBinRoot -force -recurse
|
||||||
Remove-Item $TestBinRoot\$Configuration\dnxcore50 -recurse
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## Temporary Workaround for Native Compilation
|
## Temporary Workaround for Native Compilation
|
||||||
|
|
|
@ -36,7 +36,6 @@ if [ -d "$TestBinRoot/$CONFIGURATION/dnxcore50" ]
|
||||||
then
|
then
|
||||||
cp -R -f $TestBinRoot/$CONFIGURATION/dnxcore50/* $TestBinRoot
|
cp -R -f $TestBinRoot/$CONFIGURATION/dnxcore50/* $TestBinRoot
|
||||||
fi
|
fi
|
||||||
rm -rf $TestBinRoot/$CONFIGURATION/dnxcore50
|
|
||||||
|
|
||||||
# copy TestProjects folder which is used by the test cases
|
# copy TestProjects folder which is used by the test cases
|
||||||
mkdir -p "$TestBinRoot/TestProjects"
|
mkdir -p "$TestBinRoot/TestProjects"
|
||||||
|
|
|
@ -20,58 +20,6 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
{
|
{
|
||||||
public static string ProjectName(this ProjectContext context) => context.RootProject.Identity.Name;
|
public static string ProjectName(this ProjectContext context) => context.RootProject.Identity.Name;
|
||||||
|
|
||||||
public static string GetOutputPath(this ProjectContext context, string configuration, string currentOutputPath)
|
|
||||||
{
|
|
||||||
var outputPath = string.Empty;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(currentOutputPath))
|
|
||||||
{
|
|
||||||
outputPath = Path.Combine(
|
|
||||||
GetDefaultRootOutputPath(context, currentOutputPath),
|
|
||||||
Constants.BinDirectoryName,
|
|
||||||
configuration,
|
|
||||||
context.TargetFramework.GetTwoDigitShortFolderName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
outputPath = currentOutputPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
return outputPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetIntermediateOutputPath(this ProjectContext context, string configuration, string intermediateOutputValue, string currentOutputPath)
|
|
||||||
{
|
|
||||||
var intermediateOutputPath = string.Empty;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(intermediateOutputValue))
|
|
||||||
{
|
|
||||||
intermediateOutputPath = Path.Combine(
|
|
||||||
GetDefaultRootOutputPath(context, currentOutputPath),
|
|
||||||
Constants.ObjDirectoryName,
|
|
||||||
configuration,
|
|
||||||
context.TargetFramework.GetTwoDigitShortFolderName());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
intermediateOutputPath = intermediateOutputValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return intermediateOutputPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static string GetDefaultRootOutputPath(ProjectContext context, string currentOutputPath)
|
|
||||||
{
|
|
||||||
var rootOutputPath = string.Empty;
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(currentOutputPath))
|
|
||||||
{
|
|
||||||
rootOutputPath = context.ProjectFile.ProjectDirectory;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rootOutputPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void MakeCompilationOutputRunnable(this ProjectContext context, string outputPath, string configuration)
|
public static void MakeCompilationOutputRunnable(this ProjectContext context, string outputPath, string configuration)
|
||||||
{
|
{
|
||||||
context
|
context
|
||||||
|
|
|
@ -8,33 +8,58 @@ namespace Microsoft.DotNet.ProjectModel
|
||||||
{
|
{
|
||||||
public class OutputPathCalculator
|
public class OutputPathCalculator
|
||||||
{
|
{
|
||||||
|
private const string ObjDirectoryName = "obj";
|
||||||
|
|
||||||
private readonly ProjectContext _project;
|
private readonly ProjectContext _project;
|
||||||
|
|
||||||
public string BaseRootOutputPath { get; }
|
/// <summary>
|
||||||
|
/// Unaltered output path. Either what is passed in in the constructor, or the project directory.
|
||||||
|
/// </summary>
|
||||||
|
private string BaseOutputPath { get; }
|
||||||
|
|
||||||
|
public string BaseCompilationOutputPath { get; }
|
||||||
|
|
||||||
public OutputPathCalculator(
|
public OutputPathCalculator(
|
||||||
ProjectContext project,
|
ProjectContext project,
|
||||||
string rootOutputPath)
|
string baseOutputPath)
|
||||||
{
|
{
|
||||||
_project = project;
|
_project = project;
|
||||||
BaseRootOutputPath = string.IsNullOrWhiteSpace(rootOutputPath)
|
|
||||||
|
BaseOutputPath = string.IsNullOrWhiteSpace(baseOutputPath) ? _project.ProjectDirectory : baseOutputPath;
|
||||||
|
|
||||||
|
BaseCompilationOutputPath = string.IsNullOrWhiteSpace(baseOutputPath)
|
||||||
? Path.Combine(_project.ProjectDirectory, DirectoryNames.Bin)
|
? Path.Combine(_project.ProjectDirectory, DirectoryNames.Bin)
|
||||||
: rootOutputPath;
|
: baseOutputPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetOutputDirectoryPath(string buildConfiguration)
|
public string GetCompilationOutputPath(string buildConfiguration)
|
||||||
{
|
{
|
||||||
var outDir = Path.Combine(
|
var outDir = Path.Combine(
|
||||||
BaseRootOutputPath,
|
BaseCompilationOutputPath,
|
||||||
buildConfiguration,
|
buildConfiguration,
|
||||||
_project.TargetFramework.GetTwoDigitShortFolderName());
|
_project.TargetFramework.GetTwoDigitShortFolderName());
|
||||||
|
|
||||||
// if (!string.IsNullOrEmpty(_project.RuntimeIdentifier))
|
|
||||||
// {
|
|
||||||
// outDir = Path.Combine(outDir, _project.RuntimeIdentifier);
|
|
||||||
// }
|
|
||||||
|
|
||||||
return outDir;
|
return outDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string GetIntermediateOutputPath(string buildConfiguration, string intermediateOutputValue)
|
||||||
|
{
|
||||||
|
string intermediateOutputPath;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(intermediateOutputValue))
|
||||||
|
{
|
||||||
|
intermediateOutputPath = Path.Combine(
|
||||||
|
BaseOutputPath,
|
||||||
|
ObjDirectoryName,
|
||||||
|
buildConfiguration,
|
||||||
|
_project.TargetFramework.GetTwoDigitShortFolderName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
intermediateOutputPath = intermediateOutputValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return intermediateOutputPath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,8 +39,10 @@ namespace Microsoft.DotNet.Tools.Build
|
||||||
_args = (BuilderCommandApp) args.ShallowCopy();
|
_args = (BuilderCommandApp) args.ShallowCopy();
|
||||||
|
|
||||||
// Set up Output Paths. They are unique per each CompileContext
|
// Set up Output Paths. They are unique per each CompileContext
|
||||||
_args.OutputValue = _rootProject.GetOutputPathCalculator(_args.OutputValue).BaseRootOutputPath;
|
var outputPathCalculator = _rootProject.GetOutputPathCalculator(_args.OutputValue);
|
||||||
_args.IntermediateValue = _rootProject.GetIntermediateOutputPath(_args.ConfigValue, _args.IntermediateValue, _args.OutputValue);
|
_args.OutputValue = outputPathCalculator.BaseCompilationOutputPath;
|
||||||
|
_args.IntermediateValue =
|
||||||
|
outputPathCalculator.GetIntermediateOutputPath(_args.ConfigValue, _args.IntermediateValue);
|
||||||
|
|
||||||
// Set up dependencies
|
// Set up dependencies
|
||||||
_dependencies = new ProjectDependenciesFacade(_rootProject, _args.ConfigValue);
|
_dependencies = new ProjectDependenciesFacade(_rootProject, _args.ConfigValue);
|
||||||
|
@ -338,7 +340,7 @@ namespace Microsoft.DotNet.Tools.Build
|
||||||
public static CompilerIO GetCompileIO(ProjectContext project, string config, string outputPath, string intermediaryOutputPath, ProjectDependenciesFacade dependencies)
|
public static CompilerIO GetCompileIO(ProjectContext project, string config, string outputPath, string intermediaryOutputPath, ProjectDependenciesFacade dependencies)
|
||||||
{
|
{
|
||||||
var compilerIO = new CompilerIO(new List<string>(), new List<string>());
|
var compilerIO = new CompilerIO(new List<string>(), new List<string>());
|
||||||
var binariesOutputPath = project.GetOutputPathCalculator(outputPath).GetOutputDirectoryPath(config);
|
var binariesOutputPath = project.GetOutputPathCalculator(outputPath).GetCompilationOutputPath(config);
|
||||||
var compilationOutput = CompilerUtil.GetCompilationOutput(project.ProjectFile, project.TargetFramework, config, binariesOutputPath);
|
var compilationOutput = CompilerUtil.GetCompilationOutput(project.ProjectFile, project.TargetFramework, config, binariesOutputPath);
|
||||||
|
|
||||||
// input: project.json
|
// input: project.json
|
||||||
|
|
|
@ -61,10 +61,11 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
ProjectContext context,
|
ProjectContext context,
|
||||||
CompilerCommandApp args)
|
CompilerCommandApp args)
|
||||||
{
|
{
|
||||||
var outputPath = context.GetOutputPathCalculator(args.OutputValue).GetOutputDirectoryPath(args.ConfigValue);
|
var outputPathCalculator = context.GetOutputPathCalculator(args.OutputValue);
|
||||||
|
var outputPath = outputPathCalculator.GetCompilationOutputPath(args.ConfigValue);
|
||||||
var nativeOutputPath = Path.Combine(outputPath, "native");
|
var nativeOutputPath = Path.Combine(outputPath, "native");
|
||||||
var intermediateOutputPath =
|
var intermediateOutputPath =
|
||||||
context.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue, outputPath);
|
outputPathCalculator.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue);
|
||||||
var nativeIntermediateOutputPath = Path.Combine(intermediateOutputPath, "native");
|
var nativeIntermediateOutputPath = Path.Combine(intermediateOutputPath, "native");
|
||||||
Directory.CreateDirectory(nativeOutputPath);
|
Directory.CreateDirectory(nativeOutputPath);
|
||||||
Directory.CreateDirectory(nativeIntermediateOutputPath);
|
Directory.CreateDirectory(nativeIntermediateOutputPath);
|
||||||
|
@ -160,8 +161,10 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
private static bool CompileProject(ProjectContext context, CompilerCommandApp args)
|
private static bool CompileProject(ProjectContext context, CompilerCommandApp args)
|
||||||
{
|
{
|
||||||
// Set up Output Paths
|
// Set up Output Paths
|
||||||
var outputPath = context.GetOutputPathCalculator(args.OutputValue).GetOutputDirectoryPath(args.ConfigValue);
|
var outputPathCalculator = context.GetOutputPathCalculator(args.OutputValue);
|
||||||
string intermediateOutputPath = context.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue, outputPath);
|
var outputPath = outputPathCalculator.GetCompilationOutputPath(args.ConfigValue);
|
||||||
|
var intermediateOutputPath =
|
||||||
|
outputPathCalculator.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue);
|
||||||
|
|
||||||
Directory.CreateDirectory(outputPath);
|
Directory.CreateDirectory(outputPath);
|
||||||
Directory.CreateDirectory(intermediateOutputPath);
|
Directory.CreateDirectory(intermediateOutputPath);
|
||||||
|
|
|
@ -14,24 +14,24 @@ namespace Microsoft.DotNet.Tools.Pack
|
||||||
|
|
||||||
private readonly string _configuration;
|
private readonly string _configuration;
|
||||||
|
|
||||||
public bool PackageArtifactsPathSet => !string.IsNullOrWhiteSpace(PackageArtifactsPathParameter);
|
public bool PackageOutputPathSet => !string.IsNullOrWhiteSpace(PackageOutputPathParameter);
|
||||||
|
|
||||||
public string CompiledArtifactsPathParameter { get; }
|
public string CompiledArtifactsPathParameter { get; }
|
||||||
|
|
||||||
public string PackageArtifactsPathParameter { get; }
|
public string PackageOutputPathParameter { get; }
|
||||||
|
|
||||||
public bool CompiledArtifactsPathSet => !string.IsNullOrWhiteSpace(CompiledArtifactsPathParameter);
|
public bool CompiledArtifactsPathSet => !string.IsNullOrWhiteSpace(CompiledArtifactsPathParameter);
|
||||||
|
|
||||||
public string CompiledArtifactsPath =>
|
public string CompiledArtifactsPath =>
|
||||||
CompiledArtifactsPathSet ? CompiledArtifactsPathParameter : PackageArtifactsPath;
|
CompiledArtifactsPathSet ? CompiledArtifactsPathParameter : PackageOutputPath;
|
||||||
|
|
||||||
public string PackageArtifactsPath
|
public string PackageOutputPath
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (PackageArtifactsPathSet)
|
if (PackageOutputPathSet)
|
||||||
{
|
{
|
||||||
return PackageArtifactsPathParameter;
|
return PackageOutputPathParameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
var outputPath = Path.Combine(
|
var outputPath = Path.Combine(
|
||||||
|
@ -45,12 +45,12 @@ namespace Microsoft.DotNet.Tools.Pack
|
||||||
public ArtifactPathsCalculator(
|
public ArtifactPathsCalculator(
|
||||||
Project project,
|
Project project,
|
||||||
string compiledArtifactsPath,
|
string compiledArtifactsPath,
|
||||||
string packageArtifactsPath,
|
string packageOutputPath,
|
||||||
string configuration)
|
string configuration)
|
||||||
{
|
{
|
||||||
_project = project;
|
_project = project;
|
||||||
CompiledArtifactsPathParameter = compiledArtifactsPath;
|
CompiledArtifactsPathParameter = compiledArtifactsPath;
|
||||||
PackageArtifactsPathParameter = packageArtifactsPath;
|
PackageOutputPathParameter = packageOutputPath;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@ namespace Microsoft.DotNet.Tools.Pack
|
||||||
var argsBuilder = new StringBuilder();
|
var argsBuilder = new StringBuilder();
|
||||||
argsBuilder.Append($"--configuration {_configuration}");
|
argsBuilder.Append($"--configuration {_configuration}");
|
||||||
|
|
||||||
if (_artifactPathsCalculator.PackageArtifactsPathSet)
|
if (_artifactPathsCalculator.PackageOutputPathSet)
|
||||||
{
|
{
|
||||||
argsBuilder.Append($" --output \"{_artifactPathsCalculator.PackageArtifactsPathParameter}\"");
|
argsBuilder.Append($" --output \"{_artifactPathsCalculator.PackageOutputPathParameter}\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(_intermediateOutputPath))
|
if (!string.IsNullOrEmpty(_intermediateOutputPath))
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
var packageOutputPath = Path.Combine(
|
var packageOutputPath = Path.Combine(
|
||||||
ArtifactPathsCalculator.PackageArtifactsPath,
|
ArtifactPathsCalculator.PackageOutputPath,
|
||||||
Configuration,
|
Configuration,
|
||||||
GetPackageName() + NuGet.Constants.PackageExtension);
|
GetPackageName() + NuGet.Constants.PackageExtension);
|
||||||
|
|
||||||
|
|
|
@ -83,28 +83,28 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
|
|
||||||
var options = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration);
|
var options = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration);
|
||||||
var outputPathCalculator = context.GetOutputPathCalculator(baseOutputPath);
|
var outputPathCalculator = context.GetOutputPathCalculator(baseOutputPath);
|
||||||
var outputPath = outputPathCalculator.GetOutputDirectoryPath(configuration);
|
var outputPath = outputPathCalculator.GetCompilationOutputPath(configuration);
|
||||||
|
|
||||||
var contextVariables = new Dictionary<string, string>
|
var contextVariables = new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "publish:ProjectPath", context.ProjectDirectory },
|
{ "publish:ProjectPath", context.ProjectDirectory },
|
||||||
{ "publish:Configuration", configuration },
|
{ "publish:Configuration", configuration },
|
||||||
{ "publish:OutputPath", outputPathCalculator.BaseRootOutputPath },
|
{ "publish:OutputPath", outputPathCalculator.BaseCompilationOutputPath },
|
||||||
{ "publish:Framework", context.TargetFramework.Framework },
|
{ "publish:Framework", context.TargetFramework.Framework },
|
||||||
{ "publish:Runtime", context.RuntimeIdentifier },
|
{ "publish:Runtime", context.RuntimeIdentifier },
|
||||||
};
|
};
|
||||||
|
|
||||||
RunScripts(context, ScriptNames.PrePublish, contextVariables);
|
RunScripts(context, ScriptNames.PrePublish, contextVariables);
|
||||||
|
|
||||||
if (!Directory.Exists(outputPathCalculator.BaseRootOutputPath))
|
if (!Directory.Exists(outputPathCalculator.BaseCompilationOutputPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(outputPathCalculator.BaseRootOutputPath);
|
Directory.CreateDirectory(outputPathCalculator.BaseCompilationOutputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the project (and transitively, all it's dependencies)
|
// Compile the project (and transitively, all it's dependencies)
|
||||||
var result = Command.Create("dotnet-build",
|
var result = Command.Create("dotnet-build",
|
||||||
$"--framework \"{context.TargetFramework.DotNetFrameworkName}\" " +
|
$"--framework \"{context.TargetFramework.DotNetFrameworkName}\" " +
|
||||||
$"--output \"{outputPathCalculator.BaseRootOutputPath}\" " +
|
$"--output \"{outputPathCalculator.BaseCompilationOutputPath}\" " +
|
||||||
$"--configuration \"{configuration}\" " +
|
$"--configuration \"{configuration}\" " +
|
||||||
"--no-host " +
|
"--no-host " +
|
||||||
$"\"{context.ProjectFile.ProjectDirectory}\"")
|
$"\"{context.ProjectFile.ProjectDirectory}\"")
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace Microsoft.DotNet.Tools.Run
|
||||||
|
|
||||||
// Now launch the output and give it the results
|
// Now launch the output and give it the results
|
||||||
var outputName = Path.Combine(
|
var outputName = Path.Combine(
|
||||||
_context.GetOutputPathCalculator(tempDir).GetOutputDirectoryPath(Configuration),
|
_context.GetOutputPathCalculator(tempDir).GetCompilationOutputPath(Configuration),
|
||||||
_context.ProjectFile.Name + Constants.ExeSuffix);
|
_context.ProjectFile.Name + Constants.ExeSuffix);
|
||||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
||||||
buildCommand.Execute().Should().Pass();
|
buildCommand.Execute().Should().Pass();
|
||||||
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||||
|
|
||||||
var binariesOutputDirectory = GetBinariesOutputDirectory(OutputDirectory, false);
|
var binariesOutputDirectory = GetCompilationOutputPath(OutputDirectory, false);
|
||||||
var latestWriteTimeFirstBuild = GetLastWriteTimeOfDirectoryFiles(
|
var latestWriteTimeFirstBuild = GetLastWriteTimeOfDirectoryFiles(
|
||||||
binariesOutputDirectory);
|
binariesOutputDirectory);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
||||||
|
|
||||||
// first build
|
// first build
|
||||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, native: true, nativeCppMode: true);
|
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, native: true, nativeCppMode: true);
|
||||||
var binariesOutputDirectory = GetBinariesOutputDirectory(OutputDirectory, false);
|
var binariesOutputDirectory = GetCompilationOutputPath(OutputDirectory, false);
|
||||||
|
|
||||||
buildCommand.Execute().Should().Pass();
|
buildCommand.Execute().Should().Pass();
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||||
|
|
||||||
private string GetOutputFileForProject(string projectName)
|
private string GetOutputFileForProject(string projectName)
|
||||||
{
|
{
|
||||||
return Path.Combine(GetBinDirectory(), projectName + ".dll");
|
return Path.Combine(GetCompilationOutputPath(), projectName + ".dll");
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<string> GetSourceFilesForProject(string projectName)
|
private IEnumerable<string> GetSourceFilesForProject(string projectName)
|
||||||
|
@ -109,6 +109,13 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||||
Where(f => f.EndsWith(".cs"));
|
Where(f => f.EndsWith(".cs"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected string GetCompilationOutputPath()
|
||||||
|
{
|
||||||
|
var executablePath = Path.Combine(GetBinDirectory(), "Debug", "dnxcore50");
|
||||||
|
|
||||||
|
return executablePath;
|
||||||
|
}
|
||||||
|
|
||||||
private void RunRestore(string args)
|
private void RunRestore(string args)
|
||||||
{
|
{
|
||||||
var restoreCommand = new RestoreCommand();
|
var restoreCommand = new RestoreCommand();
|
||||||
|
|
|
@ -102,14 +102,14 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||||
var buildResult = BuildProject();
|
var buildResult = BuildProject();
|
||||||
AssertProjectCompiled(_mainProject, buildResult);
|
AssertProjectCompiled(_mainProject, buildResult);
|
||||||
|
|
||||||
Reporter.Verbose.WriteLine($"Files in {GetBinDirectory()}");
|
Reporter.Verbose.WriteLine($"Files in {GetCompilationOutputPath()}");
|
||||||
foreach (var file in Directory.EnumerateFiles(GetBinDirectory()))
|
foreach (var file in Directory.EnumerateFiles(GetCompilationOutputPath()))
|
||||||
{
|
{
|
||||||
Reporter.Verbose.Write($"\t {file}");
|
Reporter.Verbose.Write($"\t {file}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete output files with extensions
|
// delete output files with extensions
|
||||||
foreach (var outputFile in Directory.EnumerateFiles(GetBinDirectory()).Where(f =>
|
foreach (var outputFile in Directory.EnumerateFiles(GetCompilationOutputPath()).Where(f =>
|
||||||
{
|
{
|
||||||
var fileName = Path.GetFileName(f);
|
var fileName = Path.GetFileName(f);
|
||||||
return fileName.StartsWith(_mainProject, StringComparison.OrdinalIgnoreCase) &&
|
return fileName.StartsWith(_mainProject, StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
string expectedOutput,
|
string expectedOutput,
|
||||||
bool native = false)
|
bool native = false)
|
||||||
{
|
{
|
||||||
var executablePath = Path.Combine(GetBinariesOutputDirectory(outputDir, native), executableName);
|
var executablePath = Path.Combine(GetCompilationOutputPath(outputDir, native), executableName);
|
||||||
|
|
||||||
var executableCommand = new TestCommand(executablePath);
|
var executableCommand = new TestCommand(executablePath);
|
||||||
|
|
||||||
|
@ -75,12 +75,12 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
||||||
result.Should().Pass();
|
result.Should().Pass();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TestNativeOutputExecutable(string outputDir, string executableName, string expectedOutput)
|
protected void TestNativeOutputExecutable(string outputDir, string executableName, string expectedOutput)
|
||||||
{
|
{
|
||||||
TestOutputExecutable(outputDir, executableName, expectedOutput, true);
|
TestOutputExecutable(outputDir, executableName, expectedOutput, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetBinariesOutputDirectory(string outputDir, bool native)
|
protected string GetCompilationOutputPath(string outputDir, bool native)
|
||||||
{
|
{
|
||||||
var executablePath = Path.Combine(outputDir, "Debug", "dnxcore50");
|
var executablePath = Path.Combine(outputDir, "Debug", "dnxcore50");
|
||||||
if (native)
|
if (native)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue