Address PR feedback

- Use the right path separator char for unix.
- Contruct some of the args to crossgen outside the loop.
- Add the null check inside Command.Environment.
This commit is contained in:
Sridhar Periyasamy 2016-04-15 10:31:17 -07:00
parent afafe80084
commit 16dcd770f9
4 changed files with 26 additions and 24 deletions

View file

@ -36,11 +36,6 @@ namespace Microsoft.DotNet.Cli.Build.Framework
cmd.CaptureStdErr().CaptureStdOut();
}
if (env == null)
{
env = new Dictionary<string, string>();
}
var result = cmd.Environment(env).Execute();
result.EnsureSuccessful();

View file

@ -136,6 +136,11 @@ namespace Microsoft.DotNet.Cli.Build.Framework
public Command Environment(IDictionary<string, string> env)
{
if (env == null)
{
return this;
}
foreach (var item in env)
{
_process.StartInfo.Environment[item.Key] = item.Value;

View file

@ -73,6 +73,26 @@ namespace Microsoft.DotNet.Cli.Build
return;
}
string sharedFxPath = c.BuildContext.Get<string>("SharedFrameworkPath");
// HACK
// The input directory can be a portable FAT app (example the CLI itself).
// In that case there can be RID specific managed dependencies which are not right next to the app binary (example System.Diagnostics.TraceSource).
// We need those dependencies during crossgen. For now we just pass all subdirectories of the input directory as input to crossgen.
// The right fix -
// If the assembly has deps.json then parse the json file to get all the dependencies, pass these dependencies as input to crossgen.
// else pass the current directory of assembly as input to crossgen.
var addtionalPaths = Directory.GetDirectories(pathToAssemblies, "*", SearchOption.AllDirectories).ToList();
var paths = new List<string>() { sharedFxPath, pathToAssemblies };
paths.AddRange(addtionalPaths);
var platformAssembliesPaths = string.Join(Path.PathSeparator.ToString(), paths.Distinct());
var env = new Dictionary<string, string>()
{
// disable partial ngen
{ "COMPLUS_ZapDisable", "0" }
};
foreach (var file in Directory.GetFiles(pathToAssemblies))
{
string fileName = Path.GetFileName(file);
@ -83,30 +103,12 @@ namespace Microsoft.DotNet.Cli.Build
}
string tempPathName = Path.ChangeExtension(file, "readytorun");
string sharedFxPath = c.BuildContext.Get<string>("SharedFrameworkPath");
// HACK
// The input directory can be a portable FAT app (example the CLI itself).
// In that case there can be RID specific managed dependencies which are not right next to the app binary (example System.Diagnostics.TraceSource).
// We need those dependencies during crossgen. For now we just pass all subdirectories of the input directory as input to crossgen.
// The right fix -
// If the assembly has deps.json then parse the json file to get all the dependencies. Pass these dependencies as input to crossgen.
// else pass the current directory of assembly as input to crossgen.
var addtionalPaths = Directory.GetDirectories(pathToAssemblies, "*", SearchOption.AllDirectories).ToList();
var paths = new List<string>() { sharedFxPath, pathToAssemblies };
paths.AddRange(addtionalPaths);
var platformAssembliesPaths = string.Join(";", paths.Distinct());
IList<string> crossgenArgs = new List<string> {
"-readytorun", "-in", file, "-out", tempPathName,
"-platform_assemblies_paths", platformAssembliesPaths
};
var env = new Dictionary<string, string>()
{
// disable partial ngen
{ "COMPLUS_ZapDisable", "0" }
};
ExecSilent(_crossGenPath, crossgenArgs, env);
File.Delete(file);

View file

@ -5,7 +5,7 @@ using System.Reflection.PortableExecutable;
namespace Microsoft.DotNet.Cli.Build
{
public class PEUtils
public static class PEUtils
{
public static bool HasMetadata(string pathToFile)
{