avoid dropping deps file when publishing
also, avoid requiring a dependency on Microsoft.NETCore.Runtime fixes #157
This commit is contained in:
parent
11b43a37d6
commit
48cd38cd92
5 changed files with 86 additions and 9 deletions
14
scripts/dev-dotnet.ps1
Normal file
14
scripts/dev-dotnet.ps1
Normal file
|
@ -0,0 +1,14 @@
|
|||
$oldPath = $env:PATH
|
||||
try {
|
||||
# Put the stage2 output on the front of the path
|
||||
$stage2 = "$PSScriptRoot\..\artifacts\win7-x64\stage2\bin"
|
||||
if (Test-Path $stage2) {
|
||||
$env:PATH="$stage2;$env:PATH"
|
||||
} else {
|
||||
Write-Host "You don't have a dev build in the 'artifacts\win7-x64\stage2' folder!"
|
||||
}
|
||||
|
||||
dotnet @args
|
||||
} finally {
|
||||
$env:PATH = $oldPath
|
||||
}
|
26
scripts/dev-dotnet.sh
Normal file
26
scripts/dev-dotnet.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE="${BASH_SOURCE[0]}"
|
||||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
SOURCE="$(readlink "$SOURCE")"
|
||||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||
done
|
||||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||
REPOROOT="$( cd -P "$DIR/.." && pwd )"
|
||||
|
||||
source "$DIR/_common.sh"
|
||||
|
||||
if [ -d "$STAGE2_DIR" ]; then
|
||||
PATH=$STAGE2_DIR/bin:$PATH
|
||||
dotnet "$@"
|
||||
else
|
||||
echo "You don't have a dev build!" 1>&2
|
||||
exit 1
|
||||
fi
|
|
@ -34,6 +34,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
var framework = app.Option("-f|--framework <FRAMEWORK>", "Compile a specific framework", CommandOptionType.MultipleValue);
|
||||
var configuration = app.Option("-c|--configuration <CONFIGURATION>", "Configuration under which to build", CommandOptionType.SingleValue);
|
||||
var noProjectDependencies = app.Option("--no-project-dependencies", "Skips building project references.", CommandOptionType.NoValue);
|
||||
var noHost = app.Option("--no-host", "Set this to skip publishing a runtime host when building for CoreCLR", CommandOptionType.NoValue);
|
||||
var project = app.Argument("<PROJECT>", "The project to compile, defaults to the current directory. Can be a path to a project.json or a project directory");
|
||||
|
||||
// Native Args
|
||||
|
@ -69,7 +70,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
ProjectContext.CreateContextForEachFramework(path);
|
||||
foreach (var context in contexts)
|
||||
{
|
||||
success &= Compile(context, configValue, outputValue, intermediateOutput.Value(), buildProjectReferences);
|
||||
success &= Compile(context, configValue, outputValue, intermediateOutput.Value(), buildProjectReferences, noHost.HasValue());
|
||||
if (isNative && success)
|
||||
{
|
||||
success &= CompileNative(context, configValue, outputValue, buildProjectReferences, intermediateValue, archValue, ilcArgsValue, ilcPathValue, isCppMode);
|
||||
|
@ -181,7 +182,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
return result.ExitCode == 0;
|
||||
}
|
||||
|
||||
private static bool Compile(ProjectContext context, string configuration, string outputOptionValue, string intermediateOutputValue, bool buildProjectReferences)
|
||||
private static bool Compile(ProjectContext context, string configuration, string outputOptionValue, string intermediateOutputValue, bool buildProjectReferences, bool noHost)
|
||||
{
|
||||
// Set up Output Paths
|
||||
string outputPath = GetOutputPath(context, configuration, outputOptionValue);
|
||||
|
@ -214,7 +215,14 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
foreach (var projectDependency in Sort(projects))
|
||||
{
|
||||
// Skip compiling project dependencies since we've already figured out the build order
|
||||
var compileResult = Command.Create("dotnet-compile", $"--framework {projectDependency.Framework} --configuration {configuration} --output \"{outputPath}\" --temp-output \"{intermediateOutputPath}\" --no-project-dependencies \"{projectDependency.Project.ProjectDirectory}\"")
|
||||
var compileResult = Command.Create("dotnet-compile",
|
||||
$"--framework {projectDependency.Framework} " +
|
||||
$"--configuration {configuration} " +
|
||||
$"--output \"{outputPath}\" " +
|
||||
$"--temp-output \"{intermediateOutputPath}\" " +
|
||||
"--no-project-dependencies " +
|
||||
(noHost ? "--no-host " : string.Empty) +
|
||||
$"\"{projectDependency.Project.ProjectDirectory}\"")
|
||||
.ForwardStdOut()
|
||||
.ForwardStdErr()
|
||||
.Execute();
|
||||
|
@ -228,10 +236,10 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
projects.Clear();
|
||||
}
|
||||
|
||||
return CompileProject(context, configuration, outputPath, intermediateOutputPath, dependencies);
|
||||
return CompileProject(context, configuration, outputPath, intermediateOutputPath, dependencies, noHost);
|
||||
}
|
||||
|
||||
private static bool CompileProject(ProjectContext context, string configuration, string outputPath, string intermediateOutputPath, List<LibraryExport> dependencies)
|
||||
private static bool CompileProject(ProjectContext context, string configuration, string outputPath, string intermediateOutputPath, List<LibraryExport> dependencies, bool noHost)
|
||||
{
|
||||
Reporter.Output.WriteLine($"Compiling {context.RootProject.Identity.Name.Yellow()} for {context.TargetFramework.DotNetFrameworkName.Yellow()}");
|
||||
var sw = Stopwatch.StartNew();
|
||||
|
@ -361,7 +369,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
|
||||
var success = result.ExitCode == 0;
|
||||
|
||||
if (success && compilationOptions.EmitEntryPoint.GetValueOrDefault())
|
||||
if (success && !noHost && compilationOptions.EmitEntryPoint.GetValueOrDefault())
|
||||
{
|
||||
var runtimeContext = ProjectContext.Create(context.ProjectDirectory, context.TargetFramework, new[] { RuntimeIdentifier.Current });
|
||||
MakeRunnable(runtimeContext,
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
"emitEntryPoint": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-23504",
|
||||
|
||||
"System.Console": "4.0.0-beta-23504",
|
||||
"System.Collections": "4.0.11-beta-23504",
|
||||
"System.Linq": "4.0.1-beta-23504",
|
||||
|
|
|
@ -118,7 +118,12 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
}
|
||||
|
||||
// Compile the project (and transitively, all it's dependencies)
|
||||
var result = Command.Create("dotnet-compile", $"--framework \"{context.TargetFramework.DotNetFrameworkName}\" --output \"{outputPath}\" --configuration \"{configuration}\" \"{context.ProjectFile.ProjectDirectory}\"")
|
||||
var result = Command.Create("dotnet-compile",
|
||||
$"--framework \"{context.TargetFramework.DotNetFrameworkName}\" " +
|
||||
$"--output \"{outputPath}\" " +
|
||||
$"--configuration \"{configuration}\" " +
|
||||
"--no-host " +
|
||||
$"\"{context.ProjectFile.ProjectDirectory}\"")
|
||||
.ForwardStdErr()
|
||||
.ForwardStdOut()
|
||||
.Execute();
|
||||
|
@ -170,8 +175,34 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
|
||||
// Copy the host
|
||||
File.Copy(hostPath, outputExe, overwrite: true);
|
||||
|
||||
// Publish the runtime
|
||||
var runtimePath = Path.GetFullPath(Path.Combine(AppContext.BaseDirectory, "..", "runtime", "coreclr"));
|
||||
if(!Directory.Exists(runtimePath))
|
||||
{
|
||||
Reporter.Error.WriteLine($"Unable to find runtime in expected location: {runtimePath}");
|
||||
return 1;
|
||||
}
|
||||
Reporter.Verbose.WriteLine($"Publishing runtime from {runtimePath.Cyan()}");
|
||||
CopyFolder(runtimePath, outputPath);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void CopyFolder(string sourceFolder, string targetFolder)
|
||||
{
|
||||
foreach (var filePath in Directory.EnumerateFiles(sourceFolder))
|
||||
{
|
||||
var fileName = Path.GetFileName(filePath);
|
||||
File.Copy(filePath, Path.Combine(targetFolder, fileName), overwrite: true);
|
||||
}
|
||||
|
||||
foreach (var folderPath in Directory.EnumerateDirectories(sourceFolder))
|
||||
{
|
||||
var folderName = new DirectoryInfo(folderPath).Name;
|
||||
CopyFolder(folderPath, Path.Combine(targetFolder, folderName));
|
||||
}
|
||||
}
|
||||
|
||||
private static void PublishFiles(IEnumerable<LibraryAsset> files, string outputPath)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue