2016-02-03 18:57:25 +00:00
|
|
|
|
// 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.Linq;
|
|
|
|
|
using Microsoft.DotNet.ProjectModel.Resources;
|
|
|
|
|
using NuGet.Frameworks;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.ProjectModel
|
|
|
|
|
{
|
|
|
|
|
public class CompilationOutputFiles
|
|
|
|
|
{
|
|
|
|
|
protected readonly Project Project;
|
|
|
|
|
protected readonly string Configuration;
|
|
|
|
|
protected readonly NuGetFramework Framework;
|
|
|
|
|
|
|
|
|
|
public CompilationOutputFiles(
|
|
|
|
|
string basePath,
|
|
|
|
|
Project project,
|
|
|
|
|
string configuration,
|
|
|
|
|
NuGetFramework framework)
|
|
|
|
|
{
|
|
|
|
|
BasePath = basePath;
|
|
|
|
|
Project = project;
|
|
|
|
|
Configuration = configuration;
|
|
|
|
|
Framework = framework;
|
|
|
|
|
OutputExtension = FileNameSuffixes.DotNet.DynamicLib;
|
|
|
|
|
|
|
|
|
|
var compilationOptions = Project.GetCompilerOptions(framework, configuration);
|
|
|
|
|
if (framework.IsDesktop() && compilationOptions.EmitEntryPoint.GetValueOrDefault())
|
|
|
|
|
{
|
|
|
|
|
OutputExtension = FileNameSuffixes.DotNet.Exe;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string BasePath { get; }
|
|
|
|
|
|
|
|
|
|
public string Assembly
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2016-03-10 23:49:11 +00:00
|
|
|
|
var compilationOptions = Project.GetCompilerOptions(Framework, Configuration);
|
|
|
|
|
|
2016-03-17 23:52:50 +00:00
|
|
|
|
return Path.Combine(BasePath, compilationOptions.OutputName + OutputExtension);
|
2016-02-03 18:57:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string PdbPath
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return Path.ChangeExtension(Assembly, FileNameSuffixes.CurrentPlatform.ProgramDatabase);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string OutputExtension { get; }
|
|
|
|
|
|
2016-04-15 21:45:51 +00:00
|
|
|
|
public virtual IEnumerable<ResourceFile> Resources()
|
2016-02-03 18:57:25 +00:00
|
|
|
|
{
|
|
|
|
|
var resourceNames = Project.Files.ResourceFiles
|
|
|
|
|
.Select(f => ResourceUtility.GetResourceCultureName(f.Key))
|
|
|
|
|
.Where(f => !string.IsNullOrEmpty(f))
|
|
|
|
|
.Distinct();
|
|
|
|
|
|
|
|
|
|
foreach (var resourceName in resourceNames)
|
|
|
|
|
{
|
2016-04-15 21:45:51 +00:00
|
|
|
|
yield return new ResourceFile(Path.Combine(BasePath, resourceName, Project.Name + ".resources" + FileNameSuffixes.DotNet.DynamicLib), resourceName);
|
2016-02-03 18:57:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual IEnumerable<string> All()
|
|
|
|
|
{
|
|
|
|
|
yield return Assembly;
|
|
|
|
|
yield return PdbPath;
|
|
|
|
|
var compilationOptions = Project.GetCompilerOptions(Framework, Configuration);
|
|
|
|
|
if (compilationOptions.GenerateXmlDocumentation == true)
|
|
|
|
|
{
|
|
|
|
|
yield return Path.ChangeExtension(Assembly, "xml");
|
|
|
|
|
}
|
|
|
|
|
foreach (var resource in Resources())
|
|
|
|
|
{
|
2016-04-15 21:45:51 +00:00
|
|
|
|
yield return resource.Path;
|
2016-02-03 18:57:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|