Added a way to get output assets
- Flow it through the project context so things end up everywhere (mostly)
This commit is contained in:
parent
543783dae4
commit
b09b00f8a5
6 changed files with 57 additions and 33 deletions
|
@ -152,21 +152,47 @@ namespace Microsoft.DotNet.ProjectModel.Compilation
|
|||
private LibraryExport ExportProject(ProjectDescription project)
|
||||
{
|
||||
var compileAssemblies = new List<LibraryAsset>();
|
||||
var runtimeAssemblies = new List<LibraryAsset>();
|
||||
var sourceReferences = new List<string>();
|
||||
|
||||
if (!string.IsNullOrEmpty(project.TargetFrameworkInfo?.AssemblyPath))
|
||||
{
|
||||
// Project specifies a pre-compiled binary. We're done!
|
||||
var assemblyPath = ResolvePath(project.Project, _configuration, project.TargetFrameworkInfo.AssemblyPath);
|
||||
compileAssemblies.Add(new LibraryAsset(
|
||||
var pdbPath = Path.ChangeExtension(assemblyPath, "pdb");
|
||||
|
||||
var compileAsset = new LibraryAsset(
|
||||
project.Project.Name,
|
||||
assemblyPath,
|
||||
Path.Combine(project.Project.ProjectDirectory, assemblyPath)));
|
||||
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);
|
||||
}
|
||||
else
|
||||
{
|
||||
var assemblyPath = project.GetOutputPathCalculator().GetAssemblyPath(_configuration);
|
||||
var outputCalculator = project.GetOutputPathCalculator();
|
||||
var assemblyPath = outputCalculator.GetAssemblyPath(_configuration);
|
||||
compileAssemblies.Add(new LibraryAsset(project.Identity.Name, null, assemblyPath));
|
||||
|
||||
foreach (var path in outputCalculator.GetBuildOutputs(_configuration))
|
||||
{
|
||||
if (Path.GetFileNameWithoutExtension(path) == project.Identity.Name)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// We're going to call this asset
|
||||
var extension = Path.GetExtension(path).Substring(1);
|
||||
runtimeAssemblies.Add(new LibraryAsset(project.Identity.Name + "/" + extension, null, path));
|
||||
}
|
||||
}
|
||||
|
||||
// Add shared sources
|
||||
|
@ -179,7 +205,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,
|
||||
compileAssemblies, Array.Empty<LibraryAsset>(), Array.Empty<AnalyzerReference>());
|
||||
runtimeAssemblies, Array.Empty<LibraryAsset>(), Array.Empty<AnalyzerReference>());
|
||||
}
|
||||
|
||||
private static string ResolvePath(Project project, string configuration, string path)
|
||||
|
|
|
@ -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.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using NuGet.Frameworks;
|
||||
|
@ -89,6 +90,21 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
_project.Name + outputExtension);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetBuildOutputs(string buildConfiguration)
|
||||
{
|
||||
var assemblyPath = GetAssemblyPath(buildConfiguration);
|
||||
|
||||
yield return assemblyPath;
|
||||
yield return Path.ChangeExtension(assemblyPath, "pdb");
|
||||
|
||||
var compilationOptions = _project.GetCompilerOptions(_framework, buildConfiguration);
|
||||
|
||||
if (compilationOptions.GenerateXmlDocumentation == true)
|
||||
{
|
||||
yield return Path.ChangeExtension(assemblyPath, "xml");
|
||||
}
|
||||
}
|
||||
|
||||
public string GetExecutablePath(string buildConfiguration)
|
||||
{
|
||||
var extension = FileNameSuffixes.CurrentPlatform.Exe;
|
||||
|
|
|
@ -510,7 +510,6 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
if (binNode != null)
|
||||
{
|
||||
targetFrameworkInformation.AssemblyPath = binNode.ValueAsString("assembly");
|
||||
targetFrameworkInformation.PdbPath = binNode.ValueAsString("pdb");
|
||||
}
|
||||
|
||||
project._targetFrameworks[frameworkName] = targetFrameworkInformation;
|
||||
|
|
|
@ -23,7 +23,5 @@ namespace Microsoft.DotNet.ProjectModel
|
|||
public string WrappedProject { get; set; }
|
||||
|
||||
public string AssemblyPath { get; set; }
|
||||
|
||||
public string PdbPath { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -407,7 +407,6 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
var compilerIO = new CompilerIO(new List<string>(), new List<string>());
|
||||
var calculator = project.GetOutputPathCalculator(outputPath);
|
||||
var binariesOutputPath = calculator.GetOutputDirectoryPath(buildConfiguration);
|
||||
var compilationOutput = calculator.GetAssemblyPath(buildConfiguration);
|
||||
|
||||
// input: project.json
|
||||
compilerIO.Inputs.Add(project.ProjectFile.ProjectFilePath);
|
||||
|
@ -422,11 +421,14 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
// input: dependencies
|
||||
AddDependencies(dependencies, compilerIO);
|
||||
|
||||
// output: compiler output
|
||||
compilerIO.Outputs.Add(compilationOutput);
|
||||
|
||||
// input / output: compilation options files
|
||||
AddFilesFromCompilationOptions(project, buildConfiguration, compilationOutput, compilerIO);
|
||||
// output: compiler outputs
|
||||
foreach (var path in calculator.GetBuildOutputs(buildConfiguration))
|
||||
{
|
||||
compilerIO.Outputs.Add(path);
|
||||
}
|
||||
|
||||
// input compilation options files
|
||||
AddCompilationOptions(project, buildConfiguration, compilerIO);
|
||||
|
||||
// input / output: resources without culture
|
||||
AddCultureResources(project, intermediaryOutputPath, compilerIO);
|
||||
|
@ -457,19 +459,10 @@ namespace Microsoft.DotNet.Tools.Build
|
|||
// non project dependencies get captured by changes in the lock file
|
||||
}
|
||||
|
||||
private static void AddFilesFromCompilationOptions(ProjectContext project, string config, string compilationOutput, CompilerIO compilerIO)
|
||||
private static void AddCompilationOptions(ProjectContext project, string config, CompilerIO compilerIO)
|
||||
{
|
||||
var compilerOptions = CompilerUtil.ResolveCompilationOptions(project, config);
|
||||
|
||||
// output: pdb file. They are always emitted (see compiler.csc)
|
||||
compilerIO.Outputs.Add(Path.ChangeExtension(compilationOutput, "pdb"));
|
||||
|
||||
// output: documentation file
|
||||
if (compilerOptions.GenerateXmlDocumentation == true)
|
||||
{
|
||||
compilerIO.Outputs.Add(Path.ChangeExtension(compilationOutput, "xml"));
|
||||
}
|
||||
|
||||
// input: key file
|
||||
if (compilerOptions.KeyFile != null)
|
||||
{
|
||||
|
|
|
@ -185,16 +185,8 @@ namespace Microsoft.DotNet.Tools.Publish
|
|||
{
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
}
|
||||
|
||||
File.Copy(file.ResolvedPath, Path.Combine(destinationDirectory, Path.GetFileName(file.ResolvedPath)), overwrite: true);
|
||||
|
||||
// Copy pdbs
|
||||
var pdbPath = Path.ChangeExtension(file.ResolvedPath, FileNameSuffixes.DotNet.ProgramDatabase);
|
||||
|
||||
if (File.Exists(pdbPath))
|
||||
{
|
||||
File.Copy(pdbPath, Path.Combine(destinationDirectory, Path.GetFileName(pdbPath)), overwrite: true);
|
||||
}
|
||||
File.Copy(file.ResolvedPath, Path.Combine(destinationDirectory, Path.GetFileName(file.ResolvedPath)), overwrite: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue