Browse Source

Use MSBuild locator API to find MSBuild. Fixes VS 2019 issue.

pull/1522/head
Oren Novotny 6 years ago
parent
commit
d0d0e9953a
Failed to extract signature
  1. 1
      ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj
  2. 18
      ICSharpCode.Decompiler.Tests/RoundtripAssembly.cs

1
ICSharpCode.Decompiler.Tests/ICSharpCode.Decompiler.Tests.csproj

@ -41,6 +41,7 @@ @@ -41,6 +41,7 @@
<ItemGroup>
<PackageReference Include="DiffLib" Version="2017.7.26.1241" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.2.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.0.0-beta4-final" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" Version="3.0.0-beta4-final" />
<PackageReference Include="Microsoft.DiaSymReader.Converter.Xml" Version="1.1.0-beta1-63314-01" />

18
ICSharpCode.Decompiler.Tests/RoundtripAssembly.cs

@ -26,6 +26,7 @@ using System.Threading; @@ -26,6 +26,7 @@ using System.Threading;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.Tests.Helpers;
using Microsoft.Build.Locator;
using Microsoft.Win32;
using NUnit.Framework;
@ -188,22 +189,15 @@ namespace ICSharpCode.Decompiler.Tests @@ -188,22 +189,15 @@ namespace ICSharpCode.Decompiler.Tests
File.Delete(file);
}
}
static string FindVS2017()
{
using (var key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)) {
using (var subkey = key.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio\SxS\VS7")) {
return subkey?.GetValue("15.0") as string;
}
}
}
static string FindMSBuild()
{
string vsPath = FindVS2017();
string vsPath = MSBuildLocator.QueryVisualStudioInstances(new VisualStudioInstanceQueryOptions { DiscoveryTypes = DiscoveryType.VisualStudioSetup })
.FirstOrDefault()
?.MSBuildPath;
if (vsPath == null)
throw new InvalidOperationException("Could not find VS2017");
return Path.Combine(vsPath, @"MSBuild\15.0\bin\MSBuild.exe");
throw new InvalidOperationException("Could not find MSBuild");
return Path.Combine(vsPath, "msbuild.exe");
}
static void Compile(string projectFile, string outputDir)

Loading…
Cancel
Save