Fixed copying output assets to the publish directory
This commit is contained in:
parent
d4a8fa24db
commit
6edac85dce
7 changed files with 128 additions and 101 deletions
|
@ -69,7 +69,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
|
|
||||||
if (commandPackage == null) return null;
|
if (commandPackage == null) return null;
|
||||||
|
|
||||||
var depsPath = GetDepsPath(projectContext, Constants.DefaultConfiguration);
|
var depsPath = projectContext.GetOutputPathCalculator().GetDepsPath(Constants.DefaultConfiguration);
|
||||||
|
|
||||||
return ConfigureCommandFromPackage(commandName, args, commandPackage, projectContext, depsPath, useComSpec);
|
return ConfigureCommandFromPackage(commandName, args, commandPackage, projectContext, depsPath, useComSpec);
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
private static PackageDescription GetCommandPackage(ProjectContext projectContext, string commandName)
|
private static PackageDescription GetCommandPackage(ProjectContext projectContext, string commandName)
|
||||||
{
|
{
|
||||||
return projectContext.LibraryManager.GetLibraries()
|
return projectContext.LibraryManager.GetLibraries()
|
||||||
.Where(l => l.GetType() == typeof (PackageDescription))
|
.Where(l => l.GetType() == typeof(PackageDescription))
|
||||||
.Select(l => l as PackageDescription)
|
.Select(l => l as PackageDescription)
|
||||||
.FirstOrDefault(p => p.Library.Files
|
.FirstOrDefault(p => p.Library.Files
|
||||||
.Select(Path.GetFileName)
|
.Select(Path.GetFileName)
|
||||||
|
@ -201,14 +201,6 @@ namespace Microsoft.DotNet.Cli.Utils
|
||||||
var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args);
|
var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args);
|
||||||
return new CommandSpec(fileName, escapedArgs, CommandResolutionStrategy.NugetPackage);
|
return new CommandSpec(fileName, escapedArgs, CommandResolutionStrategy.NugetPackage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string GetDepsPath(ProjectContext context, string buildConfiguration)
|
|
||||||
{
|
|
||||||
return Path.Combine(context.GetOutputPathCalculator().GetOutputDirectoryPath(buildConfiguration),
|
|
||||||
context.ProjectFile.Name + FileNameSuffixes.Deps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CommandSpec CreateCommandSpecPreferringExe(
|
private static CommandSpec CreateCommandSpecPreferringExe(
|
||||||
|
|
|
@ -32,16 +32,18 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static IEnumerable<LibraryAsset> RuntimeAssets(this LibraryExport export)
|
internal static IEnumerable<string> RuntimeAssets(this LibraryExport export)
|
||||||
{
|
{
|
||||||
return export.RuntimeAssemblies.Union(export.NativeLibraries);
|
return export.RuntimeAssemblies.Union(export.NativeLibraries)
|
||||||
|
.Select(e => e.ResolvedPath)
|
||||||
|
.Union(export.RuntimeAssets);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void CopyTo(this IEnumerable<LibraryAsset> assets, string destinationPath)
|
internal static void CopyTo(this IEnumerable<string> assets, string destinationPath)
|
||||||
{
|
{
|
||||||
foreach (var asset in assets)
|
foreach (var asset in assets)
|
||||||
{
|
{
|
||||||
File.Copy(asset.ResolvedPath, Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)),
|
File.Copy(asset, Path.Combine(destinationPath, Path.GetFileName(asset)),
|
||||||
overwrite: true);
|
overwrite: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,11 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IEnumerable<LibraryAsset> RuntimeAssemblies { get; }
|
public IEnumerable<LibraryAsset> RuntimeAssemblies { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Non assembly runtime assets.
|
||||||
|
/// </summary>
|
||||||
|
public IEnumerable<string> RuntimeAssets { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a list of fully-qualified paths to native binaries required to run
|
/// Gets a list of fully-qualified paths to native binaries required to run
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -43,6 +48,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
IEnumerable<LibraryAsset> compileAssemblies,
|
IEnumerable<LibraryAsset> compileAssemblies,
|
||||||
IEnumerable<string> sourceReferences,
|
IEnumerable<string> sourceReferences,
|
||||||
IEnumerable<LibraryAsset> runtimeAssemblies,
|
IEnumerable<LibraryAsset> runtimeAssemblies,
|
||||||
|
IEnumerable<string> runtimeAssets,
|
||||||
IEnumerable<LibraryAsset> nativeLibraries,
|
IEnumerable<LibraryAsset> nativeLibraries,
|
||||||
IEnumerable<AnalyzerReference> analyzers)
|
IEnumerable<AnalyzerReference> analyzers)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +56,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
CompilationAssemblies = compileAssemblies;
|
CompilationAssemblies = compileAssemblies;
|
||||||
SourceReferences = sourceReferences;
|
SourceReferences = sourceReferences;
|
||||||
RuntimeAssemblies = runtimeAssemblies;
|
RuntimeAssemblies = runtimeAssemblies;
|
||||||
|
RuntimeAssets = runtimeAssets;
|
||||||
NativeLibraries = nativeLibraries;
|
NativeLibraries = nativeLibraries;
|
||||||
AnalyzerReferences = analyzers;
|
AnalyzerReferences = analyzers;
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,8 +100,13 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
analyzerReferences.AddRange(libraryExport.AnalyzerReferences);
|
analyzerReferences.AddRange(libraryExport.AnalyzerReferences);
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return new LibraryExport(library, compilationAssemblies, sourceReferences,
|
yield return new LibraryExport(library,
|
||||||
libraryExport.RuntimeAssemblies, libraryExport.NativeLibraries, analyzerReferences);
|
compilationAssemblies,
|
||||||
|
sourceReferences,
|
||||||
|
libraryExport.RuntimeAssemblies,
|
||||||
|
libraryExport.RuntimeAssets,
|
||||||
|
libraryExport.NativeLibraries,
|
||||||
|
analyzerReferences);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,13 +151,13 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
var analyzers = GetAnalyzerReferences(package);
|
var analyzers = GetAnalyzerReferences(package);
|
||||||
|
|
||||||
return new LibraryExport(package, compileAssemblies,
|
return new LibraryExport(package, compileAssemblies,
|
||||||
sourceReferences, runtimeAssemblies, nativeLibraries, analyzers);
|
sourceReferences, runtimeAssemblies, Array.Empty<string>(), nativeLibraries, analyzers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private LibraryExport ExportProject(ProjectDescription project)
|
private LibraryExport ExportProject(ProjectDescription project)
|
||||||
{
|
{
|
||||||
var compileAssemblies = new List<LibraryAsset>();
|
var compileAssemblies = new List<LibraryAsset>();
|
||||||
var runtimeAssemblies = new List<LibraryAsset>();
|
var runtimeAssets = new List<string>();
|
||||||
var sourceReferences = new List<string>();
|
var sourceReferences = new List<string>();
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(project.TargetFrameworkInfo?.AssemblyPath))
|
if (!string.IsNullOrEmpty(project.TargetFrameworkInfo?.AssemblyPath))
|
||||||
|
@ -166,15 +171,8 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
null,
|
null,
|
||||||
Path.GetFullPath(Path.Combine(project.Project.ProjectDirectory, assemblyPath)));
|
Path.GetFullPath(Path.Combine(project.Project.ProjectDirectory, assemblyPath)));
|
||||||
|
|
||||||
var pdbAsset = new LibraryAsset(
|
|
||||||
project.Project.Name + "/pdb",
|
|
||||||
null,
|
|
||||||
Path.GetFullPath(Path.Combine(project.Project.ProjectDirectory, pdbPath)));
|
|
||||||
|
|
||||||
compileAssemblies.Add(compileAsset);
|
compileAssemblies.Add(compileAsset);
|
||||||
|
runtimeAssets.Add(pdbPath);
|
||||||
runtimeAssemblies.Add(compileAsset);
|
|
||||||
runtimeAssemblies.Add(pdbAsset);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -184,14 +182,12 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
|
|
||||||
foreach (var path in outputCalculator.GetBuildOutputs(_configuration))
|
foreach (var path in outputCalculator.GetBuildOutputs(_configuration))
|
||||||
{
|
{
|
||||||
var assetName = project.Identity.Name;
|
if (string.Equals(assemblyPath, path))
|
||||||
if (Path.GetFileNameWithoutExtension(path) != project.Identity.Name)
|
|
||||||
{
|
{
|
||||||
assetName += "/" + Path.GetExtension(path).Substring(1);
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We're going to call this asset
|
runtimeAssets.Add(path);
|
||||||
runtimeAssemblies.Add(new LibraryAsset(assetName, null, path));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +201,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
// just the same as compileAssemblies and nativeLibraries are empty
|
// just the same as compileAssemblies and nativeLibraries are empty
|
||||||
// Also no support for analyzer projects
|
// Also no support for analyzer projects
|
||||||
return new LibraryExport(project, compileAssemblies, sourceReferences,
|
return new LibraryExport(project, compileAssemblies, sourceReferences,
|
||||||
runtimeAssemblies, Array.Empty<LibraryAsset>(), Array.Empty<AnalyzerReference>());
|
compileAssemblies, runtimeAssets, Array.Empty<LibraryAsset>(), Array.Empty<AnalyzerReference>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string ResolvePath(Project project, string configuration, string path)
|
private static string ResolvePath(Project project, string configuration, string path)
|
||||||
|
@ -233,6 +229,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
||||||
new[] { new LibraryAsset(library.Identity.Name, library.Path, library.Path) },
|
new[] { new LibraryAsset(library.Identity.Name, library.Path, library.Path) },
|
||||||
Array.Empty<string>(),
|
Array.Empty<string>(),
|
||||||
Array.Empty<LibraryAsset>(),
|
Array.Empty<LibraryAsset>(),
|
||||||
|
Array.Empty<string>(),
|
||||||
Array.Empty<LibraryAsset>(),
|
Array.Empty<LibraryAsset>(),
|
||||||
Array.Empty<AnalyzerReference>());
|
Array.Empty<AnalyzerReference>());
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
// 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.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
@ -103,6 +104,27 @@ namespace Microsoft.DotNet.ProjectModel
|
||||||
{
|
{
|
||||||
yield return Path.ChangeExtension(assemblyPath, "xml");
|
yield return Path.ChangeExtension(assemblyPath, "xml");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This should only exist in desktop framework
|
||||||
|
var configFile = assemblyPath + ".config";
|
||||||
|
|
||||||
|
if (File.Exists(configFile))
|
||||||
|
{
|
||||||
|
yield return configFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deps file
|
||||||
|
var depsFile = GetDepsPath(buildConfiguration);
|
||||||
|
|
||||||
|
if (File.Exists(depsFile))
|
||||||
|
{
|
||||||
|
yield return depsFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetDepsPath(string buildConfiguration)
|
||||||
|
{
|
||||||
|
return Path.Combine(GetOutputDirectoryPath(buildConfiguration), _project.Name + FileNameSuffixes.Deps);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetExecutablePath(string buildConfiguration)
|
public string GetExecutablePath(string buildConfiguration)
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
}
|
}
|
||||||
|
|
||||||
// CodeGen Mode
|
// CodeGen Mode
|
||||||
if(args.IsCppModeValue)
|
if (args.IsCppModeValue)
|
||||||
{
|
{
|
||||||
nativeArgs.Add("--mode");
|
nativeArgs.Add("--mode");
|
||||||
nativeArgs.Add("cpp");
|
nativeArgs.Add("cpp");
|
||||||
|
@ -288,7 +288,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
};
|
};
|
||||||
RunScripts(context, ScriptNames.PreCompile, contextVariables);
|
RunScripts(context, ScriptNames.PreCompile, contextVariables);
|
||||||
|
|
||||||
var result = Command.Create($"dotnet-compile-{compilerName}", new [] {"@" + $"{rsp}" })
|
var result = Command.Create($"dotnet-compile-{compilerName}", new[] { "@" + $"{rsp}" })
|
||||||
.OnErrorLine(line =>
|
.OnErrorLine(line =>
|
||||||
{
|
{
|
||||||
var diagnostic = ParseDiagnostic(context.ProjectDirectory, line);
|
var diagnostic = ParseDiagnostic(context.ProjectDirectory, line);
|
||||||
|
@ -344,13 +344,17 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
generateBindingRedirects = true;
|
generateBindingRedirects = true;
|
||||||
var projectContext =
|
var projectContext =
|
||||||
ProjectContext.Create(context.ProjectDirectory, context.TargetFramework,
|
ProjectContext.Create(context.ProjectDirectory, context.TargetFramework,
|
||||||
new[] { PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier()});
|
new[] { PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier() });
|
||||||
|
|
||||||
|
// Don't generate a deps file if we're on desktop
|
||||||
|
if (!context.TargetFramework.IsDesktop())
|
||||||
|
{
|
||||||
projectContext
|
projectContext
|
||||||
.CreateExporter(args.ConfigValue)
|
.CreateExporter(args.ConfigValue)
|
||||||
.GetDependencies(LibraryType.Package)
|
.GetDependencies(LibraryType.Package)
|
||||||
.WriteDepsTo(Path.Combine(outputPath, projectContext.ProjectFile.Name + FileNameSuffixes.Deps));
|
.WriteDepsTo(Path.Combine(outputPath, projectContext.ProjectFile.Name + FileNameSuffixes.Deps));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (generateBindingRedirects && context.TargetFramework.IsDesktop())
|
if (generateBindingRedirects && context.TargetFramework.IsDesktop())
|
||||||
{
|
{
|
||||||
|
@ -373,12 +377,6 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CopyExport(string outputPath, LibraryExport export)
|
|
||||||
{
|
|
||||||
CopyFiles(export.RuntimeAssemblies, outputPath);
|
|
||||||
CopyFiles(export.NativeLibraries, outputPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool PrintSummary(List<DiagnosticMessage> diagnostics, Stopwatch sw, bool success = true)
|
private static bool PrintSummary(List<DiagnosticMessage> diagnostics, Stopwatch sw, bool success = true)
|
||||||
{
|
{
|
||||||
PrintDiagnostics(diagnostics);
|
PrintDiagnostics(diagnostics);
|
||||||
|
|
|
@ -132,6 +132,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
|
|
||||||
PublishFiles(export.RuntimeAssemblies, outputPath, nativeSubdirectories: false);
|
PublishFiles(export.RuntimeAssemblies, outputPath, nativeSubdirectories: false);
|
||||||
PublishFiles(export.NativeLibraries, outputPath, nativeSubdirectories);
|
PublishFiles(export.NativeLibraries, outputPath, nativeSubdirectories);
|
||||||
|
PublishFiles(export.RuntimeAssets, outputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyContents(context, outputPath);
|
CopyContents(context, outputPath);
|
||||||
|
@ -174,6 +175,14 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
private static void PublishFiles(IEnumerable<string> files, string outputPath)
|
||||||
|
{
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
var targetPath = Path.Combine(outputPath, Path.GetFileName(file));
|
||||||
|
File.Copy(file, targetPath, overwrite: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void PublishFiles(IEnumerable<LibraryAsset> files, string outputPath, bool nativeSubdirectories)
|
private static void PublishFiles(IEnumerable<LibraryAsset> files, string outputPath, bool nativeSubdirectories)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue