Skip to content

MonoAOTCompiler.cs: Correctly handle relative path for assembly to #49178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/tasks/AotCompilerTask/MonoAOTCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public override bool Execute()
private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths)
{
string assembly = assemblyItem.ItemSpec;
string directory = Path.GetDirectoryName(assembly)!;
string assemblyDir = Path.GetDirectoryName(assembly)!;
var aotAssembly = new TaskItem(assembly);
var aotArgs = new List<string>();
var processArgs = new List<string>();
Expand Down Expand Up @@ -350,18 +350,18 @@ private bool PrecompileLibrary(ITaskItem assemblyItem, string? monoPaths)
// values, which wont work.
processArgs.Add($"\"--aot={string.Join(",", aotArgs)}\"");

processArgs.Add(assembly);
processArgs.Add(assemblyFilename);

var envVariables = new Dictionary<string, string>
{
{"MONO_PATH", $"{directory}{Path.PathSeparator}{monoPaths}"},
{"MONO_PATH", $"{assemblyDir}{Path.PathSeparator}{monoPaths}"},
{"MONO_ENV_OPTIONS", string.Empty} // we do not want options to be provided out of band to the cross compilers
};

try
{
// run the AOT compiler
Utils.RunProcess(CompilerBinaryPath, string.Join(" ", processArgs), envVariables, directory, silent: false, outputMessageImportance: MessageImportance.Low);
Utils.RunProcess(CompilerBinaryPath, string.Join(" ", processArgs), envVariables, assemblyDir, silent: false, outputMessageImportance: MessageImportance.Low);
}
catch (Exception ex)
{
Expand Down
2 changes: 2 additions & 0 deletions src/tasks/Common/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public static string RunProcess(
if (workingDir != null)
processStartInfo.WorkingDirectory = workingDir;

LogInfo($"Using working directory: {workingDir ?? Environment.CurrentDirectory}", MessageImportance.Low);

if (envVars != null)
{
if (envVars.Count > 0)
Expand Down