Changes to publish
- Added ability to rename a project using the name entry in project.json. Renaming files doesn't work well when debugging the pdb can't be loaded. - Removed the logic that looks at commands on publish. The only thing that matters is the assembly name.
This commit is contained in:
parent
6bb95c4857
commit
ee0d2519e6
5 changed files with 101 additions and 107 deletions
|
@ -1,24 +1,25 @@
|
||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"name": "dotnet",
|
||||||
"compilationOptions": {
|
"version": "1.0.0-*",
|
||||||
"emitEntryPoint": true
|
"compilationOptions": {
|
||||||
},
|
"emitEntryPoint": true
|
||||||
"commands": {
|
},
|
||||||
"dotnet": "Microsoft.DotNet.Cli"
|
"commands": {
|
||||||
},
|
"dotnet": "Microsoft.DotNet.Cli"
|
||||||
"dependencies": {
|
},
|
||||||
"Microsoft.NETCore.Runtime": "1.0.1-*",
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.Runtime": "1.0.1-*",
|
||||||
|
|
||||||
"System.Console": "4.0.0-*",
|
"System.Console": "4.0.0-*",
|
||||||
"System.Collections": "4.0.11-*",
|
"System.Collections": "4.0.11-*",
|
||||||
"System.Linq": "4.0.1-*",
|
"System.Linq": "4.0.1-*",
|
||||||
"System.Diagnostics.Process": "4.1.0-*",
|
"System.Diagnostics.Process": "4.1.0-*",
|
||||||
"Microsoft.DotNet.Cli.Utils": {
|
"Microsoft.DotNet.Cli.Utils": {
|
||||||
"type": "build",
|
"type": "build",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
}
|
|
||||||
},
|
|
||||||
"frameworks": {
|
|
||||||
"dnxcore50": { }
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"dnxcore50": { }
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,32 +1,33 @@
|
||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"name": "dotnet-compile",
|
||||||
"compilationOptions": {
|
"version": "1.0.0-*",
|
||||||
"emitEntryPoint": true
|
"compilationOptions": {
|
||||||
},
|
"emitEntryPoint": true
|
||||||
"commands": {
|
},
|
||||||
"dotnet-compile": "Microsoft.DotNet.Tools.Compiler"
|
"commands": {
|
||||||
},
|
"dotnet-compile": "Microsoft.DotNet.Tools.Compiler"
|
||||||
"dependencies": {
|
},
|
||||||
"Microsoft.NETCore.TestHost": "1.0.0-*",
|
"dependencies": {
|
||||||
"Microsoft.NETCore.Runtime": "1.0.1-*",
|
"Microsoft.NETCore.TestHost": "1.0.0-*",
|
||||||
|
"Microsoft.NETCore.Runtime": "1.0.1-*",
|
||||||
|
|
||||||
"System.Console": "4.0.0-*",
|
"System.Console": "4.0.0-*",
|
||||||
"System.Collections": "4.0.11-*",
|
"System.Collections": "4.0.11-*",
|
||||||
"System.Linq": "4.0.1-*",
|
"System.Linq": "4.0.1-*",
|
||||||
"System.Diagnostics.Process": "4.1.0-*",
|
"System.Diagnostics.Process": "4.1.0-*",
|
||||||
"System.IO.FileSystem": "4.0.1-*",
|
"System.IO.FileSystem": "4.0.1-*",
|
||||||
"Microsoft.Extensions.ProjectModel": "1.0.0-*",
|
"Microsoft.Extensions.ProjectModel": "1.0.0-*",
|
||||||
"Microsoft.DotNet.Cli.Utils": {
|
"Microsoft.DotNet.Cli.Utils": {
|
||||||
"type": "build",
|
"type": "build",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
},
|
|
||||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
|
||||||
"type": "build",
|
|
||||||
"version": "1.0.0-*"
|
|
||||||
},
|
|
||||||
"Microsoft.Net.Compilers.netcore": "1.1.0-*"
|
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||||
"dnxcore50": { }
|
"type": "build",
|
||||||
}
|
"version": "1.0.0-*"
|
||||||
|
},
|
||||||
|
"Microsoft.Net.Compilers.netcore": "1.1.0-*"
|
||||||
|
},
|
||||||
|
"frameworks": {
|
||||||
|
"dnxcore50": { }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
{
|
{
|
||||||
Reporter.Output.WriteLine($"Publishing {context.RootProject.Identity.Name.Yellow()} for {context.TargetFramework.DotNetFrameworkName.Yellow()}/{context.RuntimeIdentifier}");
|
Reporter.Output.WriteLine($"Publishing {context.RootProject.Identity.Name.Yellow()} for {context.TargetFramework.DotNetFrameworkName.Yellow()}/{context.RuntimeIdentifier}");
|
||||||
|
|
||||||
// Hackily generate the output path
|
// Generate the output path
|
||||||
if (string.IsNullOrEmpty(outputPath))
|
if (string.IsNullOrEmpty(outputPath))
|
||||||
{
|
{
|
||||||
outputPath = Path.Combine(
|
outputPath = Path.Combine(
|
||||||
|
@ -87,6 +87,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
context.TargetFramework.GetTwoDigitShortFolderName(),
|
context.TargetFramework.GetTwoDigitShortFolderName(),
|
||||||
"publish");
|
"publish");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Directory.Exists(outputPath))
|
if (!Directory.Exists(outputPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(outputPath);
|
Directory.CreateDirectory(outputPath);
|
||||||
|
@ -98,6 +99,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
.ForwardStdOut()
|
.ForwardStdOut()
|
||||||
.RunAsync()
|
.RunAsync()
|
||||||
.Result;
|
.Result;
|
||||||
|
|
||||||
if (result.ExitCode != 0)
|
if (result.ExitCode != 0)
|
||||||
{
|
{
|
||||||
Reporter.Error.WriteLine("Compilation failed!".Red().Bold());
|
Reporter.Error.WriteLine("Compilation failed!".Red().Bold());
|
||||||
|
@ -106,6 +108,7 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
|
|
||||||
// Use a library exporter to collect publish assets
|
// Use a library exporter to collect publish assets
|
||||||
var exporter = context.CreateExporter(configuration);
|
var exporter = context.CreateExporter(configuration);
|
||||||
|
|
||||||
foreach (var export in exporter.GetAllExports())
|
foreach (var export in exporter.GetAllExports())
|
||||||
{
|
{
|
||||||
Reporter.Output.WriteLine($"Publishing {export.Library.Identity.ToString().Green().Bold()} ...");
|
Reporter.Output.WriteLine($"Publishing {export.Library.Identity.ToString().Green().Bold()} ...");
|
||||||
|
@ -137,12 +140,14 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
{
|
{
|
||||||
hostsPath = AppContext.BaseDirectory;
|
hostsPath = AppContext.BaseDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
var coreConsole = Path.Combine(hostsPath, Constants.CoreConsoleName);
|
var coreConsole = Path.Combine(hostsPath, Constants.CoreConsoleName);
|
||||||
if (!File.Exists(coreConsole))
|
if (!File.Exists(coreConsole))
|
||||||
{
|
{
|
||||||
Reporter.Error.WriteLine($"Unable to locate {Constants.CoreConsoleName} in {coreConsole}, use {Constants.HostsPathEnvironmentVariable} to set the path to it.".Red().Bold());
|
Reporter.Error.WriteLine($"Unable to locate {Constants.CoreConsoleName} in {coreConsole}, use {Constants.HostsPathEnvironmentVariable} to set the path to it.".Red().Bold());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var coreRun = Path.Combine(hostsPath, Constants.CoreRunName);
|
var coreRun = Path.Combine(hostsPath, Constants.CoreRunName);
|
||||||
if (!File.Exists(coreRun))
|
if (!File.Exists(coreRun))
|
||||||
{
|
{
|
||||||
|
@ -158,11 +163,8 @@ namespace Microsoft.DotNet.Tools.Publish
|
||||||
var outputExe = Path.Combine(outputPath, context.ProjectFile.Name);
|
var outputExe = Path.Combine(outputPath, context.ProjectFile.Name);
|
||||||
var outputDll = Path.Combine(outputPath, context.ProjectFile.Name + ".dll");
|
var outputDll = Path.Combine(outputPath, context.ProjectFile.Name + ".dll");
|
||||||
|
|
||||||
// Check if the a command name is specified, and rename the necessary files
|
// Write a script that can be used to launch with CoreRun
|
||||||
if (context.ProjectFile.Commands.Count == 1)
|
var script = $@"#!/usr/bin/env bash
|
||||||
{
|
|
||||||
// Write a script that can be used to launch with CoreRun
|
|
||||||
var script = $@"#!/usr/bin/env bash
|
|
||||||
SOURCE=""${{BASH_SOURCE[0]}}""
|
SOURCE=""${{BASH_SOURCE[0]}}""
|
||||||
while [ -h ""$SOURCE"" ]; do # resolve $SOURCE until the file is no longer a symlink
|
while [ -h ""$SOURCE"" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||||
DIR=""$( cd -P ""$( dirname ""$SOURCE"" )"" && pwd )""
|
DIR=""$( cd -P ""$( dirname ""$SOURCE"" )"" && pwd )""
|
||||||
|
@ -171,16 +173,19 @@ while [ -h ""$SOURCE"" ]; do # resolve $SOURCE until the file is no longer a sym
|
||||||
done
|
done
|
||||||
DIR=""$( cd -P ""$( dirname ""$SOURCE"" )"" && pwd )""
|
DIR=""$( cd -P ""$( dirname ""$SOURCE"" )"" && pwd )""
|
||||||
exec ""$DIR/corerun"" ""$DIR/{context.ProjectFile.Name}.exe"" $*";
|
exec ""$DIR/corerun"" ""$DIR/{context.ProjectFile.Name}.exe"" $*";
|
||||||
outputExe = Path.Combine(outputPath, context.ProjectFile.Commands.Single().Key);
|
|
||||||
File.WriteAllText(outputExe, script);
|
File.WriteAllText(outputExe, script);
|
||||||
Command.Create("chmod", $"a+x {outputExe}")
|
|
||||||
.ForwardStdOut()
|
Command.Create("chmod", $"a+x {outputExe}")
|
||||||
.ForwardStdErr()
|
.ForwardStdOut()
|
||||||
.RunAsync()
|
.ForwardStdErr()
|
||||||
.Wait();
|
.RunAsync()
|
||||||
File.Copy(outputDll, Path.ChangeExtension(outputDll, ".exe"));
|
.GetAwaiter()
|
||||||
File.Delete(outputDll);
|
.GetResult();
|
||||||
}
|
|
||||||
|
File.Copy(outputDll, Path.ChangeExtension(outputDll, ".exe"));
|
||||||
|
File.Delete(outputDll);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,12 +197,14 @@ exec ""$DIR/corerun"" ""$DIR/{context.ProjectFile.Name}.exe"" $*";
|
||||||
{
|
{
|
||||||
hostsPath = AppContext.BaseDirectory;
|
hostsPath = AppContext.BaseDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
var coreConsole = Path.Combine(hostsPath, Constants.CoreConsoleName);
|
var coreConsole = Path.Combine(hostsPath, Constants.CoreConsoleName);
|
||||||
if (!File.Exists(coreConsole))
|
if (!File.Exists(coreConsole))
|
||||||
{
|
{
|
||||||
Reporter.Error.WriteLine($"Unable to locate {Constants.CoreConsoleName} in {coreConsole}, use {Constants.HostsPathEnvironmentVariable} to set the path to it.".Red().Bold());
|
Reporter.Error.WriteLine($"Unable to locate {Constants.CoreConsoleName} in {coreConsole}, use {Constants.HostsPathEnvironmentVariable} to set the path to it.".Red().Bold());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var coreRun = Path.Combine(hostsPath, Constants.CoreRunName);
|
var coreRun = Path.Combine(hostsPath, Constants.CoreRunName);
|
||||||
if (!File.Exists(coreRun))
|
if (!File.Exists(coreRun))
|
||||||
{
|
{
|
||||||
|
@ -214,22 +221,6 @@ exec ""$DIR/corerun"" ""$DIR/{context.ProjectFile.Name}.exe"" $*";
|
||||||
var outputDll = Path.Combine(outputPath, context.ProjectFile.Name + ".dll");
|
var outputDll = Path.Combine(outputPath, context.ProjectFile.Name + ".dll");
|
||||||
File.Copy(coreConsole, outputExe, overwrite: true);
|
File.Copy(coreConsole, outputExe, overwrite: true);
|
||||||
|
|
||||||
// Check if the a command name is specified, and rename the necessary files
|
|
||||||
if (context.ProjectFile.Commands.Count == 1)
|
|
||||||
{
|
|
||||||
var commandName = context.ProjectFile.Commands.Single().Key;
|
|
||||||
|
|
||||||
// Move coreconsole and the matching dll
|
|
||||||
var renamedExe = Path.Combine(outputPath, commandName + ".exe");
|
|
||||||
var renamedDll = Path.ChangeExtension(renamedExe, ".dll");
|
|
||||||
if (File.Exists(renamedExe))
|
|
||||||
{
|
|
||||||
File.Delete(renamedExe);
|
|
||||||
}
|
|
||||||
File.Move(outputExe, renamedExe);
|
|
||||||
File.Move(outputDll, renamedDll);
|
|
||||||
outputExe = Path.Combine(outputPath, commandName + ".exe");
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,31 @@
|
||||||
{
|
{
|
||||||
"version": "1.0.0-*",
|
"name": "dotnet-publish",
|
||||||
"compilationOptions": {
|
"version": "1.0.0-*",
|
||||||
"emitEntryPoint": true
|
"compilationOptions": {
|
||||||
|
"emitEntryPoint": true
|
||||||
|
},
|
||||||
|
"commands": {
|
||||||
|
"dotnet-publish": "Microsoft.DotNet.Tools.Publish"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"Microsoft.NETCore.Runtime": "1.0.1-*",
|
||||||
|
"System.Console": "4.0.0-*",
|
||||||
|
"System.Collections": "4.0.11-*",
|
||||||
|
"System.Linq": "4.0.1-*",
|
||||||
|
"System.Diagnostics.Process": "4.1.0-*",
|
||||||
|
"System.IO.FileSystem": "4.0.1-*",
|
||||||
|
"Microsoft.Extensions.ProjectModel": "1.0.0-*",
|
||||||
|
"Microsoft.DotNet.Cli.Utils": {
|
||||||
|
"type": "build",
|
||||||
|
"version": "1.0.0-*"
|
||||||
},
|
},
|
||||||
"commands": {
|
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
||||||
"dotnet-publish": "Microsoft.DotNet.Tools.Publish"
|
"type": "build",
|
||||||
|
"version": "1.0.0-*"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"System.AppContext": "4.0.1-*"
|
||||||
"Microsoft.NETCore.Runtime": "1.0.1-*",
|
},
|
||||||
"System.Console": "4.0.0-*",
|
"frameworks": {
|
||||||
"System.Collections": "4.0.11-*",
|
"dnxcore50": { }
|
||||||
"System.Linq": "4.0.1-*",
|
}
|
||||||
"System.Diagnostics.Process": "4.1.0-*",
|
|
||||||
"System.IO.FileSystem": "4.0.1-*",
|
|
||||||
"Microsoft.Extensions.ProjectModel": "1.0.0-*",
|
|
||||||
"Microsoft.DotNet.Cli.Utils": {
|
|
||||||
"type": "build",
|
|
||||||
"version": "1.0.0-*"
|
|
||||||
},
|
|
||||||
"Microsoft.Extensions.CommandLineUtils.Sources": {
|
|
||||||
"type": "build",
|
|
||||||
"version": "1.0.0-*"
|
|
||||||
},
|
|
||||||
"System.AppContext": "4.0.1-*"
|
|
||||||
},
|
|
||||||
"frameworks": {
|
|
||||||
"dnxcore50": { }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ namespace Microsoft.Extensions.ProjectModel
|
||||||
}
|
}
|
||||||
|
|
||||||
// Meta-data properties
|
// Meta-data properties
|
||||||
project.Name = projectName;
|
project.Name = rawProject.ValueAsString("name") ?? projectName;
|
||||||
project.ProjectFilePath = Path.GetFullPath(projectPath);
|
project.ProjectFilePath = Path.GetFullPath(projectPath);
|
||||||
|
|
||||||
var version = rawProject.Value("version") as JsonString;
|
var version = rawProject.Value("version") as JsonString;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue