Merge pull request #1449 from dotnet/pakrym/runtime-assets
Fix publish runtime asseets
This commit is contained in:
commit
c65a1700eb
6 changed files with 34 additions and 26 deletions
|
@ -60,7 +60,7 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common
|
|||
private void MakeCompilationOutputRunnableForFullFramework(
|
||||
string outputPath)
|
||||
{
|
||||
CopyAllDependencies(outputPath, _exporter.GetAllExports());
|
||||
CopyAllDependencies(outputPath, _exporter.GetDependencies());
|
||||
GenerateBindingRedirects(_exporter);
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,7 @@ namespace Microsoft.Dotnet.Cli.Compiler.Common
|
|||
.GetDependencies(LibraryType.Package)
|
||||
.WriteDepsTo(Path.Combine(outputPath, projectFileName + FileNameSuffixes.Deps));
|
||||
|
||||
var projectExports = exporter.GetAllExports()
|
||||
.Where(e => e.Library.Identity.Type == LibraryType.Project)
|
||||
.ToArray();
|
||||
var projectExports = exporter.GetDependencies(LibraryType.Project);
|
||||
|
||||
CopyAllDependencies(outputPath, projectExports);
|
||||
}
|
||||
|
|
|
@ -200,7 +200,18 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
else if (project.Project.Files.SourceFiles.Any())
|
||||
{
|
||||
var outputPaths = project.GetOutputPaths(_buildBasePath, _solutionRootPath, _configuration, _runtime);
|
||||
var files = outputPaths.CompilationFiles;
|
||||
CompilationOutputFiles files;
|
||||
|
||||
if (project == _rootProject &&
|
||||
!string.IsNullOrWhiteSpace(_runtime) &&
|
||||
project.Project.HasRuntimeOutput(_configuration))
|
||||
{
|
||||
files = outputPaths.RuntimeFiles;
|
||||
}
|
||||
else
|
||||
{
|
||||
files = outputPaths.CompilationFiles;
|
||||
}
|
||||
|
||||
var assemblyPath = files.Assembly;
|
||||
compileAssemblies.Add(new LibraryAsset(project.Identity.Name, null, assemblyPath));
|
||||
|
|
|
@ -393,23 +393,21 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
{
|
||||
MakeRunnable();
|
||||
}
|
||||
else
|
||||
else if (!string.IsNullOrEmpty(_args.OutputValue))
|
||||
{
|
||||
CopyCompilationOutput();
|
||||
var outputPaths = _rootProject.GetOutputPaths(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue);
|
||||
CopyCompilationOutput(outputPaths);
|
||||
}
|
||||
}
|
||||
|
||||
return succeeded;
|
||||
}
|
||||
|
||||
private void CopyCompilationOutput()
|
||||
private void CopyCompilationOutput(OutputPaths outputPaths)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_args.OutputValue))
|
||||
{
|
||||
var calculator = _rootProject.GetOutputPaths(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue);
|
||||
var dest = calculator.RuntimeOutputPath;
|
||||
var source = calculator.CompilationOutputPath;
|
||||
foreach (var file in calculator.CompilationFiles.All())
|
||||
var dest = outputPaths.RuntimeOutputPath;
|
||||
var source = outputPaths.CompilationOutputPath;
|
||||
foreach (var file in outputPaths.CompilationFiles.All())
|
||||
{
|
||||
var destFileName = file.Replace(source, dest);
|
||||
var directoryName = Path.GetDirectoryName(destFileName);
|
||||
|
@ -420,13 +418,13 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
File.Copy(file, destFileName, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void MakeRunnable()
|
||||
{
|
||||
var runtimeContext = _rootProject.CreateRuntimeContext(_args.GetRuntimes());
|
||||
var outputPaths = runtimeContext.GetOutputPaths(_args.ConfigValue, _args.BuildBasePathValue, _args.OutputValue);
|
||||
var libraryExporter = runtimeContext.CreateExporter(_args.ConfigValue, _args.BuildBasePathValue);
|
||||
CopyCompilationOutput(outputPaths);
|
||||
var executable = new Executable(runtimeContext, outputPaths, libraryExporter);
|
||||
executable.MakeCompilationOutputRunnable();
|
||||
|
||||
|
|
|
@ -25,9 +25,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
|
||||
// Create the library exporter
|
||||
var exporter = context.CreateExporter(args.ConfigValue);
|
||||
|
||||
// Gather exports for the project
|
||||
var exports = exporter.GetAllExports();
|
||||
var exports = exporter.GetDependencies();
|
||||
|
||||
// Runtime assemblies.
|
||||
// TODO: native assets/resources.
|
||||
|
|
|
@ -19,6 +19,8 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
{
|
||||
public partial class PublishCommand
|
||||
{
|
||||
private const string PublishSubfolderName = "publish";
|
||||
|
||||
public string ProjectPath { get; set; }
|
||||
public string Configuration { get; set; }
|
||||
public string BuildBasePath { get; set; }
|
||||
|
@ -88,7 +90,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
|
||||
if (string.IsNullOrEmpty(outputPath))
|
||||
{
|
||||
outputPath = context.GetOutputPaths(configuration, buildBasePath, outputPath).RuntimeOutputPath;
|
||||
outputPath = Path.Combine(context.GetOutputPaths(configuration, buildBasePath, outputPath).RuntimeOutputPath, PublishSubfolderName);
|
||||
}
|
||||
|
||||
var contextVariables = new Dictionary<string, string>
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
public sealed class PublishCommand : TestCommand
|
||||
{
|
||||
private const string PublishSubfolderName = "publish";
|
||||
|
||||
private Project _project;
|
||||
private string _path;
|
||||
private string _framework;
|
||||
|
@ -61,8 +63,7 @@ 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(config, framework, runtime);
|
||||
string output = Path.Combine(config, framework, runtime, PublishSubfolderName);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue