Merge pull request #929 from livarcocc/compile_with_tfm_rid
Compile with config/tfm appended to the output path.
This commit is contained in:
commit
c055db7464
30 changed files with 276 additions and 142 deletions
|
@ -32,11 +32,11 @@ $Projects = @(
|
|||
foreach ($ProjectName in $Projects) {
|
||||
$ProjectFile = "$RepoRoot\src\$ProjectName\project.json"
|
||||
|
||||
& $toolsDir\dotnet pack "$ProjectFile" --basepath "$Stage2Dir\bin" --output "$IntermediatePackagesDir" $versionArg
|
||||
& $toolsDir\dotnet pack "$ProjectFile" --basepath "$Stage2CompilationDir\bin" --output "$IntermediatePackagesDir" --configuration "$Configuration" $versionArg
|
||||
if (!$?) {
|
||||
Write-Host "$toolsDir\dotnet pack failed for: $ProjectFile"
|
||||
Exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Get-ChildItem $IntermediatePackagesDir -Filter *.nupkg | ? {$_.Name -NotLike "*.symbols.nupkg"} | Copy-Item -Destination $PackagesDir
|
||||
Get-ChildItem $IntermediatePackagesDir\$Configuration -Filter *.nupkg | ? {$_.Name -NotLike "*.symbols.nupkg"} | Copy-Item -Destination $PackagesDir
|
||||
|
|
|
@ -12,7 +12,9 @@ $OutputDir = "$RepoRoot\artifacts\$Rid"
|
|||
$DnxDir = "$OutputDir\dnx"
|
||||
$DnxRoot = "$DnxDir\bin"
|
||||
$Stage1Dir = "$OutputDir\stage1"
|
||||
$Stage1CompilationDir = "$OutputDir\stage1compilation"
|
||||
$Stage2Dir = "$OutputDir\stage2"
|
||||
$Stage2CompilationDir = "$OutputDir\stage2compilation"
|
||||
$HostDir = "$OutputDir\corehost"
|
||||
$PackageDir = "$RepoRoot\artifacts\packages\dnvm"
|
||||
$env:ReleaseSuffix = "beta"
|
||||
|
|
|
@ -21,7 +21,9 @@ export OUTPUT_ROOT=$REPOROOT/artifacts/$RID
|
|||
export DNX_DIR=$OUTPUT_ROOT/dnx
|
||||
export DNX_ROOT=$DNX_DIR/bin
|
||||
export STAGE1_DIR=$OUTPUT_ROOT/stage1
|
||||
export STAGE1_COMPILATION_DIR=$OUTPUT_ROOT/stage1compilation
|
||||
export STAGE2_DIR=$OUTPUT_ROOT/stage2
|
||||
export STAGE2_COMPILATION_DIR=$OUTPUT_ROOT/stage2compilation
|
||||
export HOST_DIR=$OUTPUT_ROOT/corehost
|
||||
export RELEASE_SUFFIX=beta
|
||||
export CHANNEL=$RELEASE_SUFFIX
|
||||
|
|
|
@ -9,6 +9,6 @@ header "Compiling stage1 dotnet using downloaded stage0 ..."
|
|||
$StartPath = $env:PATH
|
||||
$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
|
|
@ -21,6 +21,6 @@ export PATH=$DOTNET_INSTALL_DIR/bin:$PATH
|
|||
|
||||
# Build Stage 1
|
||||
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
|
|
@ -10,6 +10,6 @@ $StartPath = $env:PATH
|
|||
$env:PATH = "$Stage1Dir\bin;$env:PATH"
|
||||
|
||||
# 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
|
|
@ -23,7 +23,7 @@ export PATH=$STAGE1_DIR/bin:$PATH
|
|||
|
||||
# Compile Stage 2
|
||||
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_TOOLS=$STAGE2_DIR
|
|
@ -9,7 +9,8 @@ param(
|
|||
[Parameter(Mandatory=$true)][string]$Configuration,
|
||||
[Parameter(Mandatory=$true)][string]$OutputDir,
|
||||
[Parameter(Mandatory=$true)][string]$RepoRoot,
|
||||
[Parameter(Mandatory=$true)][string]$HostDir)
|
||||
[Parameter(Mandatory=$true)][string]$HostDir,
|
||||
[Parameter(Mandatory=$true)][string]$CompilationOutputDir)
|
||||
|
||||
$Projects = @(
|
||||
"Microsoft.DotNet.Cli",
|
||||
|
@ -49,23 +50,47 @@ $FilesToClean = @(
|
|||
)
|
||||
|
||||
$RuntimeOutputDir = "$OutputDir\runtime\coreclr"
|
||||
$binariesOutputDir = "$CompilationOutputDir\bin\$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
|
||||
$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 (!$?) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
if (! (Test-Path $binariesOutputDir)) {
|
||||
$binariesOutputDir = "$CompilationOutputDir\bin"
|
||||
}
|
||||
|
||||
cp $binariesOutputDir\* $OutputDir\bin -force -recurse
|
||||
|
||||
# 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 (!$?) {
|
||||
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
|
||||
}
|
||||
|
||||
if (! (Test-Path $runtimeBinariesOutputDir)) {
|
||||
$runtimeBinariesOutputDir = "$CompilationOutputDir\runtime\coreclr"
|
||||
}
|
||||
|
||||
cp $runtimeBinariesOutputDir\* $RuntimeOutputDir -force -recurse
|
||||
|
||||
# Clean up bogus additional files
|
||||
$FilesToClean | ForEach-Object {
|
||||
$path = Join-Path $RuntimeOutputDir $_
|
||||
|
@ -75,7 +100,13 @@ $FilesToClean | ForEach-Object {
|
|||
}
|
||||
|
||||
# Copy the runtime app-local for the tools
|
||||
cp -rec "$RuntimeOutputDir\*" "$OutputDir\bin"
|
||||
cp -rec "$RuntimeOutputDir\*" "$OutputDir\bin" -ErrorVariable capturedErrors -ErrorAction SilentlyContinue
|
||||
$capturedErrors | foreach-object {
|
||||
if ($_ -notmatch "already exists") {
|
||||
write-error $_
|
||||
Exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Deploy the CLR host to the output
|
||||
cp "$HostDir\corehost.exe" "$OutputDir\bin"
|
||||
|
@ -96,6 +127,6 @@ if (-not (Test-Path "$OutputDir\bin\csc.ni.exe")) {
|
|||
# Copy in AppDeps
|
||||
if (-not (Test-Path "$OutputDir\bin\appdepsdk\")) {
|
||||
$env:PATH = "$OutputDir\bin;$StartPath"
|
||||
header "Acquiring Native App Dependencies"
|
||||
_cmd "$RepoRoot\scripts\build\build_appdeps.cmd ""$OutputDir"""
|
||||
header "Acquiring Native App Dependencies"
|
||||
_cmd "$RepoRoot\scripts\build\build_appdeps.cmd ""$OutputDir"""
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ source "$DIR/../common/_common.sh"
|
|||
[ ! -z "$CONFIGURATION" ] || die "Missing required environment variable CONFIGURATION"
|
||||
[ ! -z "$OUTPUT_DIR" ] || die "Missing required environment variable OUTPUT_DIR"
|
||||
[ ! -z "$HOST_DIR" ] || die "Missing required environment variable HOST_DIR"
|
||||
[ ! -z "$COMPILATION_OUTPUT_DIR" ] || die "Missing required environment variable COMPILATION_OUTPUT_DIR"
|
||||
|
||||
PROJECTS=( \
|
||||
Microsoft.DotNet.Cli \
|
||||
|
@ -56,15 +57,32 @@ FILES_TO_CLEAN=( \
|
|||
)
|
||||
|
||||
RUNTIME_OUTPUT_DIR="$OUTPUT_DIR/runtime/coreclr"
|
||||
BINARIES_OUTPUT_DIR="$COMPILATION_OUTPUT_DIR/bin/$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[@]}
|
||||
do
|
||||
echo dotnet publish --native-subdirectory --framework "$TFM" --output "$OUTPUT_DIR/bin" --configuration "$CONFIGURATION" "$REPOROOT/src/$project"
|
||||
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 "$COMPILATION_OUTPUT_DIR/bin" --configuration "$CONFIGURATION" "$REPOROOT/src/$project"
|
||||
done
|
||||
|
||||
if [ ! -d "$BINARIES_OUTPUT_DIR" ]
|
||||
then
|
||||
BINARIES_OUTPUT_DIR="$COMPILATION_OUTPUT_DIR/bin"
|
||||
fi
|
||||
cp -R -f $BINARIES_OUTPUT_DIR/* $OUTPUT_DIR/bin
|
||||
|
||||
# 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" ]
|
||||
then
|
||||
RUNTIME_BINARIES_OUTPUT_DIR="$COMPILATION_OUTPUT_DIR/runtime/coreclr"
|
||||
fi
|
||||
cp -R -f $RUNTIME_BINARIES_OUTPUT_DIR/* $RUNTIME_OUTPUT_DIR
|
||||
|
||||
# Clean up bogus additional files
|
||||
for file in ${FILES_TO_CLEAN[@]}
|
||||
|
|
|
@ -26,6 +26,10 @@ $TestProjects | ForEach-Object {
|
|||
}
|
||||
}
|
||||
|
||||
if (Test-Path $TestBinRoot\$Configuration\dnxcore50) {
|
||||
cp $TestBinRoot\$Configuration\dnxcore50\* $TestBinRoot -force -recurse
|
||||
}
|
||||
|
||||
## Temporary Workaround for Native Compilation
|
||||
## Need x64 Native Tools Dev Prompt Env Vars
|
||||
## Tracked Here: https://github.com/dotnet/cli/issues/301
|
||||
|
|
|
@ -32,6 +32,11 @@ do
|
|||
dotnet publish --framework "dnxcore50" --output "$TestBinRoot" --configuration "$CONFIGURATION" "$REPOROOT/test/$project"
|
||||
done
|
||||
|
||||
if [ -d "$TestBinRoot/$CONFIGURATION/dnxcore50" ]
|
||||
then
|
||||
cp -R -f $TestBinRoot/$CONFIGURATION/dnxcore50/* $TestBinRoot
|
||||
fi
|
||||
|
||||
# copy TestProjects folder which is used by the test cases
|
||||
mkdir -p "$TestBinRoot/TestProjects"
|
||||
cp -a $REPOROOT/test/TestProjects/* $TestBinRoot/TestProjects
|
||||
|
|
|
@ -6,8 +6,14 @@
|
|||
. "$PSScriptRoot\..\common\_common.ps1"
|
||||
|
||||
# Run Validation for Project.json dependencies
|
||||
dotnet publish $RepoRoot\tools\MultiProjectValidator -o $Stage2Dir\..\tools
|
||||
& "$Stage2Dir\..\tools\pjvalidate" "$RepoRoot\src"
|
||||
dotnet publish $RepoRoot\tools\MultiProjectValidator -o $Stage2Dir\..\tools -c "$Configuration"
|
||||
|
||||
$pjvalidatePath = "$Stage2Dir\..\tools\$Configuration\$Tfm"
|
||||
if (! (Test-Path $pjvalidatePath)) {
|
||||
$pjvalidatePath = "$Stage2Dir\..\tools"
|
||||
}
|
||||
|
||||
& "$pjvalidatePath\pjvalidate" "$RepoRoot\src"
|
||||
# TODO For release builds, this should be uncommented and fail.
|
||||
# if (!$?) {
|
||||
# Write-Host "Project Validation Failed"
|
||||
|
|
|
@ -17,8 +17,14 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
|||
source "$DIR/../common/_common.sh"
|
||||
|
||||
# Run Validation for Project.json dependencies
|
||||
dotnet publish "$REPOROOT/tools/MultiProjectValidator" -o "$STAGE2_DIR/../tools"
|
||||
dotnet publish "$REPOROOT/tools/MultiProjectValidator" -o "$STAGE2_DIR/../tools" -c "$CONFIGURATION"
|
||||
#TODO for release builds this should fail
|
||||
set +e
|
||||
"$STAGE2_DIR/../tools/pjvalidate" "$REPOROOT/src"
|
||||
PJ_VALIDATE_PATH="$STAGE2_DIR/../tools/$CONFIGURATION/$TFM"
|
||||
if [ ! -d "$PJ_VALIDATE_PATH" ]
|
||||
then
|
||||
PJ_VALIDATE_PATH="$STAGE2_DIR/../tools"
|
||||
fi
|
||||
|
||||
"$PJ_VALIDATE_PATH/pjvalidate" "$REPOROOT/src"
|
||||
set -e
|
||||
|
|
|
@ -20,58 +20,6 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
|||
{
|
||||
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)
|
||||
{
|
||||
context
|
||||
|
|
65
src/Microsoft.DotNet.ProjectModel/OutputPathCalculator.cs
Normal file
65
src/Microsoft.DotNet.ProjectModel/OutputPathCalculator.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System.IO;
|
||||
using NuGet.Frameworks;
|
||||
|
||||
namespace Microsoft.DotNet.ProjectModel
|
||||
{
|
||||
public class OutputPathCalculator
|
||||
{
|
||||
private const string ObjDirectoryName = "obj";
|
||||
|
||||
private readonly ProjectContext _project;
|
||||
|
||||
/// <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(
|
||||
ProjectContext project,
|
||||
string baseOutputPath)
|
||||
{
|
||||
_project = project;
|
||||
|
||||
BaseOutputPath = string.IsNullOrWhiteSpace(baseOutputPath) ? _project.ProjectDirectory : baseOutputPath;
|
||||
|
||||
BaseCompilationOutputPath = string.IsNullOrWhiteSpace(baseOutputPath)
|
||||
? Path.Combine(_project.ProjectDirectory, DirectoryNames.Bin)
|
||||
: baseOutputPath;
|
||||
}
|
||||
|
||||
public string GetCompilationOutputPath(string buildConfiguration)
|
||||
{
|
||||
var outDir = Path.Combine(
|
||||
BaseCompilationOutputPath,
|
||||
buildConfiguration,
|
||||
_project.TargetFramework.GetTwoDigitShortFolderName());
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -147,5 +147,10 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
}
|
||||
return outDir;
|
||||
}
|
||||
|
||||
public OutputPathCalculator GetOutputPathCalculator(string rootOutputPath)
|
||||
{
|
||||
return new OutputPathCalculator(this, rootOutputPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,10 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
_args = (BuilderCommandApp) args.ShallowCopy();
|
||||
|
||||
// Set up Output Paths. They are unique per each CompileContext
|
||||
_args.OutputValue = _rootProject.GetOutputPath(_args.ConfigValue, _args.OutputValue);
|
||||
_args.IntermediateValue = _rootProject.GetIntermediateOutputPath(_args.ConfigValue, _args.IntermediateValue, _args.OutputValue);
|
||||
var outputPathCalculator = _rootProject.GetOutputPathCalculator(_args.OutputValue);
|
||||
_args.OutputValue = outputPathCalculator.BaseCompilationOutputPath;
|
||||
_args.IntermediateValue =
|
||||
outputPathCalculator.GetIntermediateOutputPath(_args.ConfigValue, _args.IntermediateValue);
|
||||
|
||||
// Set up dependencies
|
||||
_dependencies = new ProjectDependenciesFacade(_rootProject, _args.ConfigValue);
|
||||
|
@ -338,7 +340,8 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
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 compilationOutput = CompilerUtil.GetCompilationOutput(project.ProjectFile, project.TargetFramework, config, outputPath);
|
||||
var binariesOutputPath = project.GetOutputPathCalculator(outputPath).GetCompilationOutputPath(config);
|
||||
var compilationOutput = CompilerUtil.GetCompilationOutput(project.ProjectFile, project.TargetFramework, config, binariesOutputPath);
|
||||
|
||||
// input: project.json
|
||||
compilerIO.Inputs.Add(project.ProjectFile.ProjectFilePath);
|
||||
|
@ -363,7 +366,7 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
AddCultureResources(project, intermediaryOutputPath, compilerIO);
|
||||
|
||||
// input / output: resources with culture
|
||||
AddNonCultureResources(project, outputPath, compilerIO);
|
||||
AddNonCultureResources(project, binariesOutputPath, compilerIO);
|
||||
|
||||
return compilerIO;
|
||||
}
|
||||
|
|
|
@ -61,10 +61,11 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
ProjectContext context,
|
||||
CompilerCommandApp args)
|
||||
{
|
||||
var outputPath = context.GetOutputPath(args.ConfigValue, args.OutputValue);
|
||||
var outputPathCalculator = context.GetOutputPathCalculator(args.OutputValue);
|
||||
var outputPath = outputPathCalculator.GetCompilationOutputPath(args.ConfigValue);
|
||||
var nativeOutputPath = Path.Combine(outputPath, "native");
|
||||
var intermediateOutputPath =
|
||||
context.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue, outputPath);
|
||||
var intermediateOutputPath =
|
||||
outputPathCalculator.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue);
|
||||
var nativeIntermediateOutputPath = Path.Combine(intermediateOutputPath, "native");
|
||||
Directory.CreateDirectory(nativeOutputPath);
|
||||
Directory.CreateDirectory(nativeIntermediateOutputPath);
|
||||
|
@ -160,8 +161,10 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
private static bool CompileProject(ProjectContext context, CompilerCommandApp args)
|
||||
{
|
||||
// Set up Output Paths
|
||||
string outputPath = context.GetOutputPath(args.ConfigValue, args.OutputValue);
|
||||
string intermediateOutputPath = context.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue, outputPath);
|
||||
var outputPathCalculator = context.GetOutputPathCalculator(args.OutputValue);
|
||||
var outputPath = outputPathCalculator.GetCompilationOutputPath(args.ConfigValue);
|
||||
var intermediateOutputPath =
|
||||
outputPathCalculator.GetIntermediateOutputPath(args.ConfigValue, args.IntermediateValue);
|
||||
|
||||
Directory.CreateDirectory(outputPath);
|
||||
Directory.CreateDirectory(intermediateOutputPath);
|
||||
|
|
|
@ -14,32 +14,29 @@ namespace Microsoft.DotNet.Tools.Pack
|
|||
|
||||
private readonly string _configuration;
|
||||
|
||||
private bool PackageArtifactsPathSet => !string.IsNullOrWhiteSpace(PackageArtifactsPathParameter);
|
||||
|
||||
private bool ShouldCombinePathWithFramework => !CompiledArtifactsPathSet && !PackageArtifactsPathSet;
|
||||
public bool PackageOutputPathSet => !string.IsNullOrWhiteSpace(PackageOutputPathParameter);
|
||||
|
||||
public string CompiledArtifactsPathParameter { get; }
|
||||
|
||||
public string PackageArtifactsPathParameter { get; }
|
||||
public string PackageOutputPathParameter { get; }
|
||||
|
||||
public bool CompiledArtifactsPathSet => !string.IsNullOrWhiteSpace(CompiledArtifactsPathParameter);
|
||||
|
||||
public string CompiledArtifactsPath =>
|
||||
CompiledArtifactsPathSet ? CompiledArtifactsPathParameter : PackageArtifactsPath;
|
||||
CompiledArtifactsPathSet ? CompiledArtifactsPathParameter : PackageOutputPath;
|
||||
|
||||
public string PackageArtifactsPath
|
||||
public string PackageOutputPath
|
||||
{
|
||||
get
|
||||
{
|
||||
if (PackageArtifactsPathSet)
|
||||
if (PackageOutputPathSet)
|
||||
{
|
||||
return PackageArtifactsPathParameter;
|
||||
return PackageOutputPathParameter;
|
||||
}
|
||||
|
||||
var outputPath = Path.Combine(
|
||||
_project.ProjectDirectory,
|
||||
Constants.BinDirectoryName,
|
||||
_configuration);
|
||||
Constants.BinDirectoryName);
|
||||
|
||||
return outputPath;
|
||||
}
|
||||
|
@ -48,20 +45,21 @@ namespace Microsoft.DotNet.Tools.Pack
|
|||
public ArtifactPathsCalculator(
|
||||
Project project,
|
||||
string compiledArtifactsPath,
|
||||
string packageArtifactsPath,
|
||||
string packageOutputPath,
|
||||
string configuration)
|
||||
{
|
||||
_project = project;
|
||||
CompiledArtifactsPathParameter = compiledArtifactsPath;
|
||||
PackageArtifactsPathParameter = packageArtifactsPath;
|
||||
PackageOutputPathParameter = packageOutputPath;
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public string InputPathForContext(ProjectContext context)
|
||||
{
|
||||
return ShouldCombinePathWithFramework ?
|
||||
Path.Combine(CompiledArtifactsPath, context.TargetFramework.GetTwoDigitShortFolderName()) :
|
||||
CompiledArtifactsPath;
|
||||
return Path.Combine(
|
||||
CompiledArtifactsPath,
|
||||
_configuration,
|
||||
context.TargetFramework.GetTwoDigitShortFolderName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,9 +42,9 @@ namespace Microsoft.DotNet.Tools.Pack
|
|||
var argsBuilder = new StringBuilder();
|
||||
argsBuilder.Append($"--configuration {_configuration}");
|
||||
|
||||
if (!string.IsNullOrEmpty(_artifactPathsCalculator.PackageArtifactsPathParameter))
|
||||
if (_artifactPathsCalculator.PackageOutputPathSet)
|
||||
{
|
||||
argsBuilder.Append($" --output \"{_artifactPathsCalculator.PackageArtifactsPathParameter}\"");
|
||||
argsBuilder.Append($" --output \"{_artifactPathsCalculator.PackageOutputPathParameter}\"");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(_intermediateOutputPath))
|
||||
|
|
|
@ -58,7 +58,8 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
}
|
||||
|
||||
var packageOutputPath = Path.Combine(
|
||||
ArtifactPathsCalculator.PackageArtifactsPath,
|
||||
ArtifactPathsCalculator.PackageOutputPath,
|
||||
Configuration,
|
||||
GetPackageName() + NuGet.Constants.PackageExtension);
|
||||
|
||||
if (GeneratePackage(packageOutputPath, packDiagnostics))
|
||||
|
|
|
@ -73,46 +73,38 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
/// Publish the project for given 'framework (ex - dnxcore50)' and 'runtimeID (ex - win7-x64)'
|
||||
/// </summary>
|
||||
/// <param name="context">project that is to be published</param>
|
||||
/// <param name="outputPath">Location of published files</param>
|
||||
/// <param name="baseOutputPath">Location of published files</param>
|
||||
/// <param name="configuration">Debug or Release</param>
|
||||
/// <param name="nativeSubdirectories"></param>
|
||||
/// <returns>Return 0 if successful else return non-zero</returns>
|
||||
private static bool PublishProjectContext(ProjectContext context, string outputPath, string configuration, bool nativeSubdirectories)
|
||||
private static bool PublishProjectContext(ProjectContext context, string baseOutputPath, string configuration, bool nativeSubdirectories)
|
||||
{
|
||||
Reporter.Output.WriteLine($"Publishing {context.RootProject.Identity.Name.Yellow()} for {context.TargetFramework.DotNetFrameworkName.Yellow()}/{context.RuntimeIdentifier.Yellow()}");
|
||||
|
||||
var options = context.ProjectFile.GetCompilerOptions(context.TargetFramework, configuration);
|
||||
|
||||
// Generate the output path
|
||||
if (string.IsNullOrEmpty(outputPath))
|
||||
{
|
||||
outputPath = Path.Combine(
|
||||
context.ProjectFile.ProjectDirectory,
|
||||
Constants.BinDirectoryName,
|
||||
configuration,
|
||||
context.TargetFramework.GetTwoDigitShortFolderName(),
|
||||
context.RuntimeIdentifier);
|
||||
}
|
||||
var outputPathCalculator = context.GetOutputPathCalculator(baseOutputPath);
|
||||
var outputPath = outputPathCalculator.GetCompilationOutputPath(configuration);
|
||||
|
||||
var contextVariables = new Dictionary<string, string>
|
||||
{
|
||||
{ "publish:ProjectPath", context.ProjectDirectory },
|
||||
{ "publish:Configuration", configuration },
|
||||
{ "publish:OutputPath", outputPath },
|
||||
{ "publish:OutputPath", outputPathCalculator.BaseCompilationOutputPath },
|
||||
{ "publish:Framework", context.TargetFramework.Framework },
|
||||
{ "publish:Runtime", context.RuntimeIdentifier },
|
||||
};
|
||||
|
||||
RunScripts(context, ScriptNames.PrePublish, contextVariables);
|
||||
|
||||
if (!Directory.Exists(outputPath))
|
||||
if (!Directory.Exists(outputPathCalculator.BaseCompilationOutputPath))
|
||||
{
|
||||
Directory.CreateDirectory(outputPath);
|
||||
Directory.CreateDirectory(outputPathCalculator.BaseCompilationOutputPath);
|
||||
}
|
||||
|
||||
// Compile the project (and transitively, all it's dependencies)
|
||||
var result = Command.Create("dotnet-build",
|
||||
$"--framework \"{context.TargetFramework.DotNetFrameworkName}\" " +
|
||||
$"--output \"{outputPath}\" " +
|
||||
$"--output \"{outputPathCalculator.BaseCompilationOutputPath}\" " +
|
||||
$"--configuration \"{configuration}\" " +
|
||||
"--no-host " +
|
||||
$"\"{context.ProjectFile.ProjectDirectory}\"")
|
||||
|
|
|
@ -101,7 +101,9 @@ namespace Microsoft.DotNet.Tools.Run
|
|||
}
|
||||
|
||||
// Now launch the output and give it the results
|
||||
var outputName = Path.Combine(tempDir, _context.ProjectFile.Name + Constants.ExeSuffix);
|
||||
var outputName = Path.Combine(
|
||||
_context.GetOutputPathCalculator(tempDir).GetCompilationOutputPath(Configuration),
|
||||
_context.ProjectFile.Name + Constants.ExeSuffix);
|
||||
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
{
|
||||
if (_context.TargetFramework.IsDesktop())
|
||||
|
|
|
@ -23,6 +23,15 @@
|
|||
"System.Reflection": "4.1.0-rc2-23616",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23616"
|
||||
}
|
||||
},
|
||||
"dnxcore50": {
|
||||
"dependencies": {
|
||||
"System.IO.FileSystem": "4.0.1-rc2-23616",
|
||||
"System.Linq": "4.0.1-rc2-23616",
|
||||
"System.Runtime": "4.0.21-rc2-23616",
|
||||
"System.Reflection": "4.1.0-rc2-23616",
|
||||
"System.Dynamic.Runtime": "4.0.11-rc2-23616"
|
||||
}
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
|
|
|
@ -58,13 +58,16 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
buildCommand.Execute().Should().Pass();
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
|
||||
var latestWriteTimeFirstBuild = GetLastWriteTimeOfDirectoryFiles(OutputDirectory);
|
||||
var binariesOutputDirectory = GetCompilationOutputPath(OutputDirectory, false);
|
||||
var latestWriteTimeFirstBuild = GetLastWriteTimeOfDirectoryFiles(
|
||||
binariesOutputDirectory);
|
||||
|
||||
// second build; should get skipped (incremental because no inputs changed)
|
||||
buildCommand.Execute().Should().Pass();
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
|
||||
var latestWriteTimeSecondBuild = GetLastWriteTimeOfDirectoryFiles(OutputDirectory);
|
||||
var latestWriteTimeSecondBuild = GetLastWriteTimeOfDirectoryFiles(
|
||||
binariesOutputDirectory);
|
||||
Assert.Equal(latestWriteTimeFirstBuild, latestWriteTimeSecondBuild);
|
||||
|
||||
TouchSourceFileInDirectory(TestDirectory);
|
||||
|
@ -73,7 +76,8 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
buildCommand.Execute().Should().Pass();
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
|
||||
var latestWriteTimeThirdBuild = GetLastWriteTimeOfDirectoryFiles(OutputDirectory);
|
||||
var latestWriteTimeThirdBuild = GetLastWriteTimeOfDirectoryFiles(
|
||||
binariesOutputDirectory);
|
||||
Assert.NotEqual(latestWriteTimeSecondBuild, latestWriteTimeThirdBuild);
|
||||
}
|
||||
|
||||
|
@ -91,8 +95,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
|
||||
buildCommand.Execute().Should().Pass();
|
||||
|
||||
var nativeOut = Path.Combine(OutputDirectory, "native");
|
||||
TestOutputExecutable(nativeOut, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
TestNativeOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -108,8 +111,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
|
||||
buildCommand.Execute().Should().Pass();
|
||||
|
||||
var nativeOut = Path.Combine(OutputDirectory, "native");
|
||||
TestOutputExecutable(nativeOut, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
TestNativeOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -121,20 +123,22 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
return;
|
||||
}
|
||||
|
||||
var nativeOut = Path.Combine(OutputDirectory, "native");
|
||||
|
||||
// first build
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, native: true, nativeCppMode: true);
|
||||
buildCommand.Execute().Should().Pass();
|
||||
TestOutputExecutable(nativeOut, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
var binariesOutputDirectory = GetCompilationOutputPath(OutputDirectory, false);
|
||||
|
||||
var latestWriteTimeFirstBuild = GetLastWriteTimeOfDirectoryFiles(OutputDirectory);
|
||||
buildCommand.Execute().Should().Pass();
|
||||
|
||||
TestNativeOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
|
||||
var latestWriteTimeFirstBuild = GetLastWriteTimeOfDirectoryFiles(binariesOutputDirectory);
|
||||
|
||||
// second build; should be skipped because nothing changed
|
||||
buildCommand.Execute().Should().Pass();
|
||||
TestOutputExecutable(nativeOut, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
|
||||
var latestWriteTimeSecondBuild = GetLastWriteTimeOfDirectoryFiles(OutputDirectory);
|
||||
TestNativeOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
|
||||
var latestWriteTimeSecondBuild = GetLastWriteTimeOfDirectoryFiles(binariesOutputDirectory);
|
||||
Assert.Equal(latestWriteTimeFirstBuild, latestWriteTimeSecondBuild);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
|||
|
||||
private string GetOutputFileForProject(string projectName)
|
||||
{
|
||||
return Path.Combine(GetBinDirectory(), projectName + ".dll");
|
||||
return Path.Combine(GetCompilationOutputPath(), projectName + ".dll");
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetSourceFilesForProject(string projectName)
|
||||
|
@ -109,6 +109,13 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
|||
Where(f => f.EndsWith(".cs"));
|
||||
}
|
||||
|
||||
protected string GetCompilationOutputPath()
|
||||
{
|
||||
var executablePath = Path.Combine(GetBinDirectory(), "Debug", "dnxcore50");
|
||||
|
||||
return executablePath;
|
||||
}
|
||||
|
||||
private void RunRestore(string args)
|
||||
{
|
||||
var restoreCommand = new RestoreCommand();
|
||||
|
|
|
@ -102,14 +102,14 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
|||
var buildResult = BuildProject();
|
||||
AssertProjectCompiled(_mainProject, buildResult);
|
||||
|
||||
Reporter.Verbose.WriteLine($"Files in {GetBinDirectory()}");
|
||||
foreach (var file in Directory.EnumerateFiles(GetBinDirectory()))
|
||||
Reporter.Verbose.WriteLine($"Files in {GetCompilationOutputPath()}");
|
||||
foreach (var file in Directory.EnumerateFiles(GetCompilationOutputPath()))
|
||||
{
|
||||
Reporter.Verbose.Write($"\t {file}");
|
||||
}
|
||||
|
||||
// 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);
|
||||
return fileName.StartsWith(_mainProject, StringComparison.OrdinalIgnoreCase) &&
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
|
@ -32,7 +33,8 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
|||
result.Should().Pass();
|
||||
|
||||
// verify the output xml file
|
||||
var outputXml = Path.Combine(outputDir, "TestLibrary.xml");
|
||||
var outputXml = Path.Combine(outputDir, "Debug", "dnxcore50", "TestLibrary.xml");
|
||||
Console.WriteLine("OUTPUT XML PATH: " + outputXml);
|
||||
Assert.True(File.Exists(outputXml));
|
||||
Assert.Contains("Gets the message from the helper", File.ReadAllText(outputXml));
|
||||
}
|
||||
|
|
|
@ -61,7 +61,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
string framework = string.IsNullOrEmpty(_framework) ?
|
||||
_project.GetTargetFrameworks().First().FrameworkName.GetShortFolderName() : _framework;
|
||||
string runtime = string.IsNullOrEmpty(_runtime) ? PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier() : _runtime;
|
||||
string output = Path.Combine("bin", config, framework, runtime);
|
||||
//TODO: add runtime back as soon as it gets propagated through the various commands.
|
||||
string output = Path.Combine(config, framework);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
@ -70,10 +71,10 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
if (!string.IsNullOrEmpty(_output))
|
||||
{
|
||||
return new DirectoryInfo(_output);
|
||||
return new DirectoryInfo(Path.Combine(_output, BuildRelativeOutputPath()));
|
||||
}
|
||||
|
||||
string output = Path.Combine(_project.ProjectDirectory, BuildRelativeOutputPath());
|
||||
string output = Path.Combine(_project.ProjectDirectory, "bin", BuildRelativeOutputPath());
|
||||
return new DirectoryInfo(output);
|
||||
}
|
||||
|
||||
|
|
|
@ -58,9 +58,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
string.Equals("on", val, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
protected void TestOutputExecutable(string outputDir, string executableName, string expectedOutput)
|
||||
protected void TestOutputExecutable(
|
||||
string outputDir,
|
||||
string executableName,
|
||||
string expectedOutput,
|
||||
bool native = false)
|
||||
{
|
||||
var executablePath = Path.Combine(outputDir, executableName);
|
||||
var executablePath = Path.Combine(GetCompilationOutputPath(outputDir, native), executableName);
|
||||
|
||||
var executableCommand = new TestCommand(executablePath);
|
||||
|
||||
|
@ -70,5 +74,21 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
result.Should().NotHaveStdErr();
|
||||
result.Should().Pass();
|
||||
}
|
||||
|
||||
protected void TestNativeOutputExecutable(string outputDir, string executableName, string expectedOutput)
|
||||
{
|
||||
TestOutputExecutable(outputDir, executableName, expectedOutput, true);
|
||||
}
|
||||
|
||||
protected string GetCompilationOutputPath(string outputDir, bool native)
|
||||
{
|
||||
var executablePath = Path.Combine(outputDir, "Debug", "dnxcore50");
|
||||
if (native)
|
||||
{
|
||||
executablePath = Path.Combine(outputDir, "Debug", "dnxcore50", "native");
|
||||
}
|
||||
|
||||
return executablePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue