Minor cleanup.

This commit is contained in:
Eric Erhardt 2016-07-21 12:41:20 -05:00
parent 0eeb58f4eb
commit f0afc7eb79
3 changed files with 3 additions and 68 deletions

View file

@ -333,7 +333,7 @@ namespace Microsoft.DotNet.Cli.Compiler.Common
exporter.GetAllExports().GenerateBindingRedirects(configFiles);
}
private static int RenamePublishedHost(ProjectContext context, string outputPath, CommonCompilerOptions compilationOptions)
public static int RenamePublishedHost(ProjectContext context, string outputPath, CommonCompilerOptions compilationOptions)
{
if (context.TargetFramework.IsDesktop())
{

View file

@ -95,7 +95,6 @@
DependsOnTargets="$(PublishDependsOn)" />
<Target Name="CopyPublishArtifacts">
<Message Text="ERIC CopyPublishArtifacts" />
<!--<Copy ... ="/>" />-->
<Message Text="TODO: Implement CopyPublishArtifacts" />
</Target>
</Project>

View file

@ -12,7 +12,6 @@ using Microsoft.DotNet.InternalAbstractions;
using Microsoft.DotNet.ProjectModel;
using Microsoft.DotNet.ProjectModel.Compilation;
using Microsoft.DotNet.ProjectModel.Files;
using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.ProjectModel.Utilities;
using Microsoft.DotNet.Tools.Common;
using NuGet.Frameworks;
@ -200,7 +199,7 @@ namespace Microsoft.DotNet.Tools.Publish
if (options.EmitEntryPoint.GetValueOrDefault() && !string.IsNullOrEmpty(context.RuntimeIdentifier))
{
Reporter.Verbose.WriteLine($"publish: Renaming native host in output to create fully standalone output.");
RenamePublishedHost(context, outputPath, options);
Executable.RenamePublishedHost(context, outputPath, options);
}
RunScripts(context, ScriptNames.PostPublish, contextVariables);
@ -288,69 +287,6 @@ namespace Microsoft.DotNet.Tools.Publish
}
}
private static int RenamePublishedHost(ProjectContext context, string outputPath, CommonCompilerOptions compilationOptions)
{
if (context.TargetFramework.IsDesktop())
{
return 0;
}
var publishedHostFile = ResolvePublishedHostFile(outputPath);
if (publishedHostFile == null)
{
Reporter.Output.WriteLine($"publish: warning: host executable not available in dependencies, using host for current platform");
// TODO should this be an error?
CoreHost.CopyTo(outputPath, compilationOptions.OutputName + Constants.ExeSuffix);
return 0;
}
var publishedHostExtension = Path.GetExtension(publishedHostFile);
var renamedHostName = compilationOptions.OutputName + publishedHostExtension;
var renamedHostFile = Path.Combine(outputPath, renamedHostName);
try
{
Reporter.Verbose.WriteLine($"publish: renaming published host {publishedHostFile} to {renamedHostFile}");
File.Copy(publishedHostFile, renamedHostFile, true);
File.Delete(publishedHostFile);
}
catch (Exception e)
{
Reporter.Error.WriteLine($"publish: Failed to rename {publishedHostFile} to {renamedHostFile}: {e.Message}");
return 1;
}
return 0;
}
private static string ResolvePublishedHostFile(string outputPath)
{
var tryExtensions = new string[] { "", ".exe" };
foreach (var extension in tryExtensions)
{
var hostFile = Path.Combine(outputPath, Constants.PublishedHostExecutableName + extension);
if (File.Exists(hostFile))
{
Reporter.Verbose.WriteLine($"resolved published host: {hostFile}");
return hostFile;
}
}
Reporter.Verbose.WriteLine($"failed to resolve published host in: {outputPath}");
return null;
}
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 void PublishAssetGroups(IEnumerable<LibraryAssetGroup> groups, string outputPath, bool nativeSubdirectories, bool includeRuntimeGroups)
{
foreach (var group in groups.Where(g => includeRuntimeGroups || string.IsNullOrEmpty(g.Runtime)))