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;
|
||||
|
||||
var depsPath = GetDepsPath(projectContext, Constants.DefaultConfiguration);
|
||||
var depsPath = projectContext.GetOutputPathCalculator().GetDepsPath(Constants.DefaultConfiguration);
|
||||
|
||||
return ConfigureCommandFromPackage(commandName, args, commandPackage, projectContext, depsPath, useComSpec);
|
||||
}
|
||||
|
@ -201,14 +201,6 @@ namespace Microsoft.DotNet.Cli.Utils
|
|||
var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args);
|
||||
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(
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
File.Copy(asset.ResolvedPath, Path.Combine(destinationPath, Path.GetFileName(asset.ResolvedPath)),
|
||||
File.Copy(asset, Path.Combine(destinationPath, Path.GetFileName(asset)),
|
||||
overwrite: true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,11 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
/// </summary>
|
||||
public IEnumerable<LibraryAsset> RuntimeAssemblies { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Non assembly runtime assets.
|
||||
/// </summary>
|
||||
public IEnumerable<string> RuntimeAssets { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a list of fully-qualified paths to native binaries required to run
|
||||
/// </summary>
|
||||
|
@ -43,6 +48,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
IEnumerable<LibraryAsset> compileAssemblies,
|
||||
IEnumerable<string> sourceReferences,
|
||||
IEnumerable<LibraryAsset> runtimeAssemblies,
|
||||
IEnumerable<string> runtimeAssets,
|
||||
IEnumerable<LibraryAsset> nativeLibraries,
|
||||
IEnumerable<AnalyzerReference> analyzers)
|
||||
{
|
||||
|
@ -50,6 +56,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
CompilationAssemblies = compileAssemblies;
|
||||
SourceReferences = sourceReferences;
|
||||
RuntimeAssemblies = runtimeAssemblies;
|
||||
RuntimeAssets = runtimeAssets;
|
||||
NativeLibraries = nativeLibraries;
|
||||
AnalyzerReferences = analyzers;
|
||||
}
|
||||
|
|
|
@ -100,8 +100,13 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
analyzerReferences.AddRange(libraryExport.AnalyzerReferences);
|
||||
}
|
||||
|
||||
yield return new LibraryExport(library, compilationAssemblies, sourceReferences,
|
||||
libraryExport.RuntimeAssemblies, libraryExport.NativeLibraries, analyzerReferences);
|
||||
yield return new LibraryExport(library,
|
||||
compilationAssemblies,
|
||||
sourceReferences,
|
||||
libraryExport.RuntimeAssemblies,
|
||||
libraryExport.RuntimeAssets,
|
||||
libraryExport.NativeLibraries,
|
||||
analyzerReferences);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,13 +151,13 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
var analyzers = GetAnalyzerReferences(package);
|
||||
|
||||
return new LibraryExport(package, compileAssemblies,
|
||||
sourceReferences, runtimeAssemblies, nativeLibraries, analyzers);
|
||||
sourceReferences, runtimeAssemblies, Array.Empty<string>(), nativeLibraries, analyzers);
|
||||
}
|
||||
|
||||
private LibraryExport ExportProject(ProjectDescription project)
|
||||
{
|
||||
var compileAssemblies = new List<LibraryAsset>();
|
||||
var runtimeAssemblies = new List<LibraryAsset>();
|
||||
var runtimeAssets = new List<string>();
|
||||
var sourceReferences = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(project.TargetFrameworkInfo?.AssemblyPath))
|
||||
|
@ -166,15 +171,8 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
null,
|
||||
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);
|
||||
|
||||
runtimeAssemblies.Add(compileAsset);
|
||||
runtimeAssemblies.Add(pdbAsset);
|
||||
runtimeAssets.Add(pdbPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -184,14 +182,12 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
|
||||
foreach (var path in outputCalculator.GetBuildOutputs(_configuration))
|
||||
{
|
||||
var assetName = project.Identity.Name;
|
||||
if (Path.GetFileNameWithoutExtension(path) != project.Identity.Name)
|
||||
if (string.Equals(assemblyPath, path))
|
||||
{
|
||||
assetName += "/" + Path.GetExtension(path).Substring(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
// We're going to call this asset
|
||||
runtimeAssemblies.Add(new LibraryAsset(assetName, null, path));
|
||||
runtimeAssets.Add(path);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -205,7 +201,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
// just the same as compileAssemblies and nativeLibraries are empty
|
||||
// Also no support for analyzer projects
|
||||
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)
|
||||
|
@ -233,6 +229,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
new[] { new LibraryAsset(library.Identity.Name, library.Path, library.Path) },
|
||||
Array.Empty<string>(),
|
||||
Array.Empty<LibraryAsset>(),
|
||||
Array.Empty<string>(),
|
||||
Array.Empty<LibraryAsset>(),
|
||||
Array.Empty<AnalyzerReference>());
|
||||
}
|
||||
|
|
|
@ -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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -103,6 +104,27 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
{
|
||||
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)
|
||||
|
|
|
@ -346,11 +346,15 @@ namespace Microsoft.DotNet.Tools.Compiler
|
|||
ProjectContext.Create(context.ProjectDirectory, context.TargetFramework,
|
||||
new[] { PlatformServices.Default.Runtime.GetLegacyRestoreRuntimeIdentifier() });
|
||||
|
||||
// Don't generate a deps file if we're on desktop
|
||||
if (!context.TargetFramework.IsDesktop())
|
||||
{
|
||||
projectContext
|
||||
.CreateExporter(args.ConfigValue)
|
||||
.GetDependencies(LibraryType.Package)
|
||||
.WriteDepsTo(Path.Combine(outputPath, projectContext.ProjectFile.Name + FileNameSuffixes.Deps));
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
PrintDiagnostics(diagnostics);
|
||||
|
|
|
@ -132,6 +132,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
|
||||
PublishFiles(export.RuntimeAssemblies, outputPath, nativeSubdirectories: false);
|
||||
PublishFiles(export.NativeLibraries, outputPath, nativeSubdirectories);
|
||||
PublishFiles(export.RuntimeAssets, outputPath);
|
||||
}
|
||||
|
||||
CopyContents(context, outputPath);
|
||||
|
@ -174,6 +175,14 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue