Merge pull request #91 from nventive/dev/jela/adjust-msbuild-workaround

Adjust MSBuild workaround for VS15.9
This commit is contained in:
Jérôme Laban 2019-01-29 10:56:56 -05:00 коммит произвёл GitHub
Родитель c070225100 655df72fdf
Коммит 10dc59bfe8
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 20 добавлений и 4 удалений

Просмотреть файл

@ -251,9 +251,11 @@ namespace Uno.SourceGeneratorTasks
try
{
var asm = Assembly.Load("Microsoft.Build");
var path = Path.Combine(MSBuildBasePath, "Microsoft.Build.dll");
if (Type.GetType("Microsoft.Build.Shared.FileUtilities, Microsoft.Build", false) is Type fileUtilitiesType)
var asm = Assembly.LoadFrom(path);
if (asm.GetType("Microsoft.Build.Shared.FileUtilities", false) is Type fileUtilitiesType)
{
if (fileUtilitiesType.GetField("cacheDirectory", BindingFlags.NonPublic | BindingFlags.Static) is FieldInfo field)
{
@ -264,13 +266,27 @@ namespace Uno.SourceGeneratorTasks
var cacheDirectory = Path.Combine(Path.GetTempPath(), String.Format(CultureInfo.CurrentUICulture, "MSBuild{0}-SourceGeneration", Process.GetCurrentProcess().Id));
field.SetValue(null, cacheDirectory);
System.Console.WriteLine("Applied MSBuild cache path workaround for VS15.9 and below");
}
else
{
System.Console.WriteLine($"Failed to override internal msbuild cache directory, cacheDirectory is already set to [{existingcacheDirectory}]");
}
}
else
{
System.Console.WriteLine($"Failed to override internal msbuild cache directory, could not find cacheDirectory field");
}
}
else
{
System.Console.WriteLine($"Failed to override internal msbuild cache directory, could not find Microsoft.Build.Shared.FileUtilities");
}
}
catch (Exception)
catch (Exception e)
{
System.Console.WriteLine("Failed to override internal msbuild cache directory");
System.Console.WriteLine($"Failed to override internal msbuild cache directory {e.Message}");
}
}