Make project dependencies work for dotnet run
- Copy project references to the output folder
This commit is contained in:
parent
da2925e920
commit
96dfcfa563
1 changed files with 22 additions and 9 deletions
|
@ -248,8 +248,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
{
|
{
|
||||||
var runtimeContext = ProjectContext.Create(context.ProjectDirectory, context.TargetFramework, new[] { RuntimeIdentifier.Current });
|
var runtimeContext = ProjectContext.Create(context.ProjectDirectory, context.TargetFramework, new[] { RuntimeIdentifier.Current });
|
||||||
MakeRunnable(runtimeContext,
|
MakeRunnable(runtimeContext,
|
||||||
outputPath,
|
outputPath,
|
||||||
context.ProjectFile.Name,
|
|
||||||
runtimeContext.CreateExporter(configuration));
|
runtimeContext.CreateExporter(configuration));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +327,7 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
Directory.CreateDirectory(path);
|
Directory.CreateDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void MakeRunnable(ProjectContext runtimeContext, string outputPath, string projectName, LibraryExporter exporter)
|
private static void MakeRunnable(ProjectContext runtimeContext, string outputPath, LibraryExporter exporter)
|
||||||
{
|
{
|
||||||
if (runtimeContext.TargetFramework.IsDesktop())
|
if (runtimeContext.TargetFramework.IsDesktop())
|
||||||
{
|
{
|
||||||
|
@ -346,24 +345,38 @@ namespace Microsoft.DotNet.Tools.Compiler
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
EmitHost(outputPath, projectName, exporter);
|
EmitHost(runtimeContext, outputPath, exporter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EmitHost(string outputPath, string projectName, LibraryExporter exporter)
|
private static void EmitHost(ProjectContext runtimeContext, string outputPath, LibraryExporter exporter)
|
||||||
{
|
{
|
||||||
// Write the Host information file (basically a simplified form of the lock file)
|
// Write the Host information file (basically a simplified form of the lock file)
|
||||||
var lines = new List<string>();
|
var lines = new List<string>();
|
||||||
foreach(var export in exporter.GetAllExports())
|
foreach(var export in exporter.GetAllExports())
|
||||||
{
|
{
|
||||||
lines.AddRange(GenerateLines(export, export.RuntimeAssemblies, "runtime"));
|
if (export.Library == runtimeContext.RootProject)
|
||||||
lines.AddRange(GenerateLines(export, export.NativeLibraries, "native"));
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (export.Library is ProjectDescription)
|
||||||
|
{
|
||||||
|
// Copy project dependencies to the output folder
|
||||||
|
CopyFiles(export.RuntimeAssemblies, outputPath);
|
||||||
|
CopyFiles(export.NativeLibraries, outputPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lines.AddRange(GenerateLines(export, export.RuntimeAssemblies, "runtime"));
|
||||||
|
lines.AddRange(GenerateLines(export, export.NativeLibraries, "native"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File.WriteAllLines(Path.Combine(outputPath, projectName + ".deps"), lines);
|
File.WriteAllLines(Path.Combine(outputPath, runtimeContext.ProjectFile.Name + ".deps"), lines);
|
||||||
|
|
||||||
// Copy the host in
|
// Copy the host in
|
||||||
CopyHost(Path.Combine(outputPath, projectName + Constants.ExeSuffix));
|
CopyHost(Path.Combine(outputPath, runtimeContext.ProjectFile.Name + Constants.ExeSuffix));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void CopyHost(string target)
|
private static void CopyHost(string target)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue