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