Browse Source

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

pull/1522/head
Oren Novotny 7 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 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="DiffLib" Version="2017.7.26.1241" /> <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.CSharp" Version="3.0.0-beta4-final" />
<PackageReference Include="Microsoft.CodeAnalysis.VisualBasic" 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" /> <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;
using ICSharpCode.Decompiler.CSharp; using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.Metadata; using ICSharpCode.Decompiler.Metadata;
using ICSharpCode.Decompiler.Tests.Helpers; using ICSharpCode.Decompiler.Tests.Helpers;
using Microsoft.Build.Locator;
using Microsoft.Win32; using Microsoft.Win32;
using NUnit.Framework; using NUnit.Framework;
@ -189,21 +190,14 @@ namespace ICSharpCode.Decompiler.Tests
} }
} }
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() static string FindMSBuild()
{ {
string vsPath = FindVS2017(); string vsPath = MSBuildLocator.QueryVisualStudioInstances(new VisualStudioInstanceQueryOptions { DiscoveryTypes = DiscoveryType.VisualStudioSetup })
.FirstOrDefault()
?.MSBuildPath;
if (vsPath == null) if (vsPath == null)
throw new InvalidOperationException("Could not find VS2017"); throw new InvalidOperationException("Could not find MSBuild");
return Path.Combine(vsPath, @"MSBuild\15.0\bin\MSBuild.exe"); return Path.Combine(vsPath, "msbuild.exe");
} }
static void Compile(string projectFile, string outputDir) static void Compile(string projectFile, string outputDir)

Loading…
Cancel
Save