Fixed copying output assets to the publish directory

This commit is contained in:
David Fowler 2016-01-27 20:35:43 -08:00
parent d4a8fa24db
commit 6edac85dce
7 changed files with 128 additions and 101 deletions

View file

@ -24,16 +24,16 @@ namespace Microsoft.DotNet.Cli.Utils
private static CommandSpec ResolveFromPath(string commandName, IEnumerable<string> args, bool useComSpec = false) private static CommandSpec ResolveFromPath(string commandName, IEnumerable<string> args, bool useComSpec = false)
{ {
var commandPath = Env.GetCommandPath(commandName); var commandPath = Env.GetCommandPath(commandName);
return commandPath == null return commandPath == null
? null ? null
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.Path, useComSpec); : CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.Path, useComSpec);
} }
private static CommandSpec ResolveFromAppBase(string commandName, IEnumerable<string> args, bool useComSpec = false) private static CommandSpec ResolveFromAppBase(string commandName, IEnumerable<string> args, bool useComSpec = false)
{ {
var commandPath = Env.GetCommandPathFromAppBase(AppContext.BaseDirectory, commandName); var commandPath = Env.GetCommandPathFromAppBase(AppContext.BaseDirectory, commandName);
return commandPath == null return commandPath == null
? null ? null
: CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.BaseDirectory, useComSpec); : CreateCommandSpecPreferringExe(commandName, args, commandPath, CommandResolutionStrategy.BaseDirectory, useComSpec);
} }
@ -50,7 +50,7 @@ namespace Microsoft.DotNet.Cli.Utils
var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args); var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(args);
return new CommandSpec(commandName, escapedArgs, CommandResolutionStrategy.Path); return new CommandSpec(commandName, escapedArgs, CommandResolutionStrategy.Path);
} }
} }
return null; return null;
@ -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,21 +201,13 @@ 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(
string commandName, string commandName,
IEnumerable<string> args, IEnumerable<string> args,
string commandPath, string commandPath,
CommandResolutionStrategy resolutionStrategy, CommandResolutionStrategy resolutionStrategy,
bool useComSpec = false) bool useComSpec = false)
{ {
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
@ -226,7 +218,7 @@ namespace Microsoft.DotNet.Cli.Utils
// Use cmd if we can't find an exe // Use cmd if we can't find an exe
if (preferredCommandPath == null) if (preferredCommandPath == null)
{ {
useComSpec = true; useComSpec = true;
} }
else else
{ {
@ -246,8 +238,8 @@ namespace Microsoft.DotNet.Cli.Utils
} }
private static CommandSpec CreateComSpecCommandSpec( private static CommandSpec CreateComSpecCommandSpec(
string command, string command,
IEnumerable<string> args, IEnumerable<string> args,
CommandResolutionStrategy resolutionStrategy) CommandResolutionStrategy resolutionStrategy)
{ {
// To prevent Command Not Found, comspec gets passed in as // To prevent Command Not Found, comspec gets passed in as

View file

@ -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);
} }
} }

View file

@ -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>
@ -33,26 +38,28 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
/// Gets a list of fully-qualified paths to source code file references /// Gets a list of fully-qualified paths to source code file references
/// </summary> /// </summary>
public IEnumerable<string> SourceReferences { get; } public IEnumerable<string> SourceReferences { get; }
/// <summary>
/// Get a list of analyzers provided by this export.
/// </summary>
public IEnumerable<AnalyzerReference> AnalyzerReferences { get; }
public LibraryExport(LibraryDescription library, /// <summary>
IEnumerable<LibraryAsset> compileAssemblies, /// Get a list of analyzers provided by this export.
IEnumerable<string> sourceReferences, /// </summary>
IEnumerable<LibraryAsset> runtimeAssemblies, public IEnumerable<AnalyzerReference> AnalyzerReferences { get; }
IEnumerable<LibraryAsset> nativeLibraries,
IEnumerable<AnalyzerReference> analyzers) public LibraryExport(LibraryDescription library,
{ IEnumerable<LibraryAsset> compileAssemblies,
Library = library; IEnumerable<string> sourceReferences,
CompilationAssemblies = compileAssemblies; IEnumerable<LibraryAsset> runtimeAssemblies,
SourceReferences = sourceReferences; IEnumerable<string> runtimeAssets,
RuntimeAssemblies = runtimeAssemblies; IEnumerable<LibraryAsset> nativeLibraries,
NativeLibraries = nativeLibraries; IEnumerable<AnalyzerReference> analyzers)
AnalyzerReferences = analyzers; {
} Library = library;
CompilationAssemblies = compileAssemblies;
SourceReferences = sourceReferences;
RuntimeAssemblies = runtimeAssemblies;
RuntimeAssets = runtimeAssets;
NativeLibraries = nativeLibraries;
AnalyzerReferences = analyzers;
}
private string DebuggerDisplay => Library.Identity.ToString(); private string DebuggerDisplay => Library.Identity.ToString();
} }

View file

@ -81,7 +81,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
var sourceReferences = new List<string>(); var sourceReferences = new List<string>();
var analyzerReferences = new List<AnalyzerReference>(); var analyzerReferences = new List<AnalyzerReference>();
var libraryExport = GetExport(library); var libraryExport = GetExport(library);
// We need to filter out source references from non-root libraries, // We need to filter out source references from non-root libraries,
// so we rebuild the library export // so we rebuild the library export
@ -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);
} }
} }
@ -142,17 +147,17 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
{ {
sourceReferences.Add(sharedSource); sourceReferences.Add(sharedSource);
} }
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))
@ -160,38 +165,29 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
// Project specifies a pre-compiled binary. We're done! // Project specifies a pre-compiled binary. We're done!
var assemblyPath = ResolvePath(project.Project, _configuration, project.TargetFrameworkInfo.AssemblyPath); var assemblyPath = ResolvePath(project.Project, _configuration, project.TargetFrameworkInfo.AssemblyPath);
var pdbPath = Path.ChangeExtension(assemblyPath, "pdb"); var pdbPath = Path.ChangeExtension(assemblyPath, "pdb");
var compileAsset = new LibraryAsset( var compileAsset = new LibraryAsset(
project.Project.Name, project.Project.Name,
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
{ {
var outputCalculator = project.GetOutputPathCalculator(); var outputCalculator = project.GetOutputPathCalculator();
var assemblyPath = outputCalculator.GetAssemblyPath(_configuration); var assemblyPath = outputCalculator.GetAssemblyPath(_configuration);
compileAssemblies.Add(new LibraryAsset(project.Identity.Name, null, assemblyPath)); compileAssemblies.Add(new LibraryAsset(project.Identity.Name, null, assemblyPath));
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>());
} }
@ -245,7 +242,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
.Where(path => path.StartsWith("shared" + Path.DirectorySeparatorChar)) .Where(path => path.StartsWith("shared" + Path.DirectorySeparatorChar))
.Select(path => Path.Combine(package.Path, path)); .Select(path => Path.Combine(package.Path, path));
} }
private IEnumerable<AnalyzerReference> GetAnalyzerReferences(PackageDescription package) private IEnumerable<AnalyzerReference> GetAnalyzerReferences(PackageDescription package)
{ {
var analyzers = package var analyzers = package
@ -253,16 +250,16 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
.Files .Files
.Where(path => path.StartsWith("analyzers" + Path.DirectorySeparatorChar) && .Where(path => path.StartsWith("analyzers" + Path.DirectorySeparatorChar) &&
path.EndsWith(".dll")); path.EndsWith(".dll"));
var analyzerRefs = new List<AnalyzerReference>(); var analyzerRefs = new List<AnalyzerReference>();
// See https://docs.nuget.org/create/analyzers-conventions for the analyzer // See https://docs.nuget.org/create/analyzers-conventions for the analyzer
// NuGet specification // NuGet specification
foreach (var analyzer in analyzers) foreach (var analyzer in analyzers)
{ {
var specifiers = analyzer.Split(Path.DirectorySeparatorChar); var specifiers = analyzer.Split(Path.DirectorySeparatorChar);
var assemblyPath = Path.Combine(package.Path, analyzer); var assemblyPath = Path.Combine(package.Path, analyzer);
// $/analyzers/{Framework Name}{Version}/{Supported Architecture}/{Supported Programming Language}/{Analyzer}.dll // $/analyzers/{Framework Name}{Version}/{Supported Architecture}/{Supported Programming Language}/{Analyzer}.dll
switch (specifiers.Length) switch (specifiers.Length)
{ {
@ -275,7 +272,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
runtimeIdentifier: null runtimeIdentifier: null
)); ));
break; break;
// $/analyzers/{framework}/{analyzer}.dll // $/analyzers/{framework}/{analyzer}.dll
case 3: case 3:
analyzerRefs.Add(new AnalyzerReference( analyzerRefs.Add(new AnalyzerReference(
@ -285,7 +282,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
runtimeIdentifier: null runtimeIdentifier: null
)); ));
break; break;
// $/analyzers/{framework}/{language}/{analyzer}.dll // $/analyzers/{framework}/{language}/{analyzer}.dll
case 4: case 4:
analyzerRefs.Add(new AnalyzerReference( analyzerRefs.Add(new AnalyzerReference(
@ -295,7 +292,7 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
runtimeIdentifier: null runtimeIdentifier: null
)); ));
break; break;
// $/analyzers/{framework}/{runtime}/{language}/{analyzer}.dll // $/analyzers/{framework}/{runtime}/{language}/{analyzer}.dll
case 5: case 5:
analyzerRefs.Add(new AnalyzerReference( analyzerRefs.Add(new AnalyzerReference(
@ -305,10 +302,10 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
runtimeIdentifier: specifiers[2] runtimeIdentifier: specifiers[2]
)); ));
break; break;
// Anything less than 2 specifiers or more than 4 is // Anything less than 2 specifiers or more than 4 is
// illegal according to the specification and will be // illegal according to the specification and will be
// ignored // ignored
} }
} }
return analyzerRefs; return analyzerRefs;

View file

@ -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;
@ -74,7 +75,7 @@ namespace Microsoft.DotNet.ProjectModel
return intermediateOutputPath; return intermediateOutputPath;
} }
public string GetAssemblyPath(string buildConfiguration) public string GetAssemblyPath(string buildConfiguration)
{ {
var compilationOptions = _project.GetCompilerOptions(_framework, buildConfiguration); var compilationOptions = _project.GetCompilerOptions(_framework, buildConfiguration);
@ -89,22 +90,43 @@ namespace Microsoft.DotNet.ProjectModel
GetOutputDirectoryPath(buildConfiguration), GetOutputDirectoryPath(buildConfiguration),
_project.Name + outputExtension); _project.Name + outputExtension);
} }
public IEnumerable<string> GetBuildOutputs(string buildConfiguration) public IEnumerable<string> GetBuildOutputs(string buildConfiguration)
{ {
var assemblyPath = GetAssemblyPath(buildConfiguration); var assemblyPath = GetAssemblyPath(buildConfiguration);
yield return assemblyPath; yield return assemblyPath;
yield return Path.ChangeExtension(assemblyPath, "pdb"); yield return Path.ChangeExtension(assemblyPath, "pdb");
var compilationOptions = _project.GetCompilerOptions(_framework, buildConfiguration); var compilationOptions = _project.GetCompilerOptions(_framework, buildConfiguration);
if (compilationOptions.GenerateXmlDocumentation == true) if (compilationOptions.GenerateXmlDocumentation == true)
{ {
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)
{ {
var extension = FileNameSuffixes.CurrentPlatform.Exe; var extension = FileNameSuffixes.CurrentPlatform.Exe;
@ -115,7 +137,7 @@ namespace Microsoft.DotNet.ProjectModel
{ {
extension = FileNameSuffixes.DotNet.Exe; extension = FileNameSuffixes.DotNet.Exe;
} }
return Path.Combine( return Path.Combine(
GetOutputDirectoryPath(buildConfiguration), GetOutputDirectoryPath(buildConfiguration),
_project.Name + extension); _project.Name + extension);

View file

@ -57,7 +57,7 @@ namespace Microsoft.DotNet.Tools.Compiler
} }
private static bool CompileNative( private static bool CompileNative(
ProjectContext context, ProjectContext context,
CompilerCommandApp args) CompilerCommandApp args)
{ {
var outputPathCalculator = context.GetOutputPathCalculator(args.OutputValue); var outputPathCalculator = context.GetOutputPathCalculator(args.OutputValue);
@ -71,7 +71,7 @@ namespace Microsoft.DotNet.Tools.Compiler
var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, args.ConfigValue); var compilationOptions = context.ProjectFile.GetCompilerOptions(context.TargetFramework, args.ConfigValue);
var managedOutput = outputPathCalculator.GetAssemblyPath(args.ConfigValue); var managedOutput = outputPathCalculator.GetAssemblyPath(args.ConfigValue);
var nativeArgs = new List<string>(); var nativeArgs = new List<string>();
// Input Assembly // Input Assembly
@ -82,8 +82,8 @@ namespace Microsoft.DotNet.Tools.Compiler
{ {
nativeArgs.Add("--ilcargs"); nativeArgs.Add("--ilcargs");
nativeArgs.Add($"{args.IlcArgsValue}"); nativeArgs.Add($"{args.IlcArgsValue}");
} }
// ILC Path // ILC Path
if (!string.IsNullOrWhiteSpace(args.IlcPathValue)) if (!string.IsNullOrWhiteSpace(args.IlcPathValue))
{ {
@ -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");
@ -138,7 +138,7 @@ namespace Microsoft.DotNet.Tools.Compiler
// Output Path // Output Path
nativeArgs.Add("--output"); nativeArgs.Add("--output");
nativeArgs.Add($"{nativeOutputPath}"); nativeArgs.Add($"{nativeOutputPath}");
// Write Response File // Write Response File
var rsp = Path.Combine(nativeIntermediateOutputPath, $"dotnet-compile-native.{context.ProjectFile.Name}.rsp"); var rsp = Path.Combine(nativeIntermediateOutputPath, $"dotnet-compile-native.{context.ProjectFile.Name}.rsp");
@ -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,12 +344,16 @@ 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() });
projectContext // Don't generate a deps file if we're on desktop
.CreateExporter(args.ConfigValue) if (!context.TargetFramework.IsDesktop())
.GetDependencies(LibraryType.Package) {
.WriteDepsTo(Path.Combine(outputPath, projectContext.ProjectFile.Name + FileNameSuffixes.Deps)); projectContext
.CreateExporter(args.ConfigValue)
.GetDependencies(LibraryType.Package)
.WriteDepsTo(Path.Combine(outputPath, projectContext.ProjectFile.Name + FileNameSuffixes.Deps));
}
} }
if (generateBindingRedirects && context.TargetFramework.IsDesktop()) if (generateBindingRedirects && context.TargetFramework.IsDesktop())
@ -372,12 +376,6 @@ namespace Microsoft.DotNet.Tools.Compiler
.Execute(); .Execute();
} }
} }
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)
{ {

View file

@ -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)
{ {