diff options
| author | Rob Mensching <rob@firegiant.com> | 2019-05-07 23:01:53 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2019-05-07 23:05:11 -0700 |
| commit | 8f288810a4bdeb7a397073ac9682f0478583be44 (patch) | |
| tree | 7bc5c5711f3768f25c2ae62f3515558449fb6c69 /src | |
| parent | 0c688dbd8a32342f117179ec3432b4237334dbcd (diff) | |
| download | wix-8f288810a4bdeb7a397073ac9682f0478583be44.tar.gz wix-8f288810a4bdeb7a397073ac9682f0478583be44.tar.bz2 wix-8f288810a4bdeb7a397073ac9682f0478583be44.zip | |
Support MSBuild16 in runner
Diffstat (limited to 'src')
4 files changed, 71 insertions, 24 deletions
diff --git a/src/WixBuildTools.MsgGen/WixBuildTools.MsgGen.csproj b/src/WixBuildTools.MsgGen/WixBuildTools.MsgGen.csproj index b0954998..80d6b0d6 100644 --- a/src/WixBuildTools.MsgGen/WixBuildTools.MsgGen.csproj +++ b/src/WixBuildTools.MsgGen/WixBuildTools.MsgGen.csproj | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | </ItemGroup> | 18 | </ItemGroup> |
| 19 | 19 | ||
| 20 | <ItemGroup> | 20 | <ItemGroup> |
| 21 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63102-01" PrivateAssets="All" /> | 21 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" /> |
| 22 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> | 22 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> |
| 23 | </ItemGroup> | 23 | </ItemGroup> |
| 24 | 24 | ||
diff --git a/src/WixBuildTools.TestSupport/MsbuildRunner.cs b/src/WixBuildTools.TestSupport/MsbuildRunner.cs index dbfc02f1..953ed654 100644 --- a/src/WixBuildTools.TestSupport/MsbuildRunner.cs +++ b/src/WixBuildTools.TestSupport/MsbuildRunner.cs | |||
| @@ -8,37 +8,84 @@ namespace WixBuildTools.TestSupport | |||
| 8 | using System.IO; | 8 | using System.IO; |
| 9 | using System.Text; | 9 | using System.Text; |
| 10 | 10 | ||
| 11 | public class MsbuildRunner | 11 | public static class MsbuildRunner |
| 12 | { | 12 | { |
| 13 | private static readonly string VswhereRelativePath = @"Microsoft Visual Studio\Installer\vswhere.exe"; | 13 | private static readonly string VswhereRelativePath = @"Microsoft Visual Studio\Installer\vswhere.exe"; |
| 14 | private static readonly string[] VswhereFindArguments = new[] { "-property", "installationPath", "-latest" }; | 14 | private static readonly string[] VswhereFindArguments = new[] { "-property", "installationPath" }; |
| 15 | private static readonly string Msbuild15RelativePath = @"MSBuild\15.0\bin\MSBuild.exe"; | 15 | private static readonly string Msbuild15RelativePath = @"MSBuild\15.0\Bin\MSBuild.exe"; |
| 16 | private static readonly string Msbuild16RelativePath = @"MSBuild\Current\Bin\MSBuild.exe"; | ||
| 16 | 17 | ||
| 17 | public MsbuildRunner() | 18 | private static string Msbuild15Path; |
| 19 | private static string Msbuild16Path; | ||
| 20 | |||
| 21 | public static MsbuildRunnerResult Execute(string projectPath, string[] arguments = null) => InitAndExecute(String.Empty, projectPath, arguments); | ||
| 22 | |||
| 23 | public static MsbuildRunnerResult ExecuteWithMsbuild15(string projectPath, string[] arguments = null) => InitAndExecute("15", projectPath, arguments); | ||
| 24 | |||
| 25 | public static MsbuildRunnerResult ExecuteWithMsbuild16(string projectPath, string[] arguments = null) => InitAndExecute("16", projectPath, arguments); | ||
| 26 | |||
| 27 | private static MsbuildRunnerResult InitAndExecute(string msbuildVersion, string projectPath, string[] arguments) | ||
| 18 | { | 28 | { |
| 19 | var vswherePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), VswhereRelativePath); | 29 | if (Msbuild15Path == null && Msbuild16Path == null) |
| 20 | if (!File.Exists(vswherePath)) | ||
| 21 | { | 30 | { |
| 22 | throw new InvalidOperationException($"Failed to find vswhere at: {vswherePath}"); | 31 | var vswherePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), VswhereRelativePath); |
| 32 | if (!File.Exists(vswherePath)) | ||
| 33 | { | ||
| 34 | throw new InvalidOperationException($"Failed to find vswhere at: {vswherePath}"); | ||
| 35 | } | ||
| 36 | |||
| 37 | var result = RunProcessCaptureOutput(vswherePath, VswhereFindArguments); | ||
| 38 | if (result.ExitCode != 0) | ||
| 39 | { | ||
| 40 | throw new InvalidOperationException($"Failed to execute vswhere.exe, exit code: {result.ExitCode}"); | ||
| 41 | } | ||
| 42 | |||
| 43 | Msbuild15Path = String.Empty; | ||
| 44 | Msbuild16Path = String.Empty; | ||
| 45 | |||
| 46 | foreach (var installPath in result.Output) | ||
| 47 | { | ||
| 48 | if (String.IsNullOrEmpty(Msbuild16Path)) | ||
| 49 | { | ||
| 50 | var path = Path.Combine(installPath, Msbuild16RelativePath); | ||
| 51 | if (File.Exists(path)) | ||
| 52 | { | ||
| 53 | Msbuild16Path = path; | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
| 57 | if (String.IsNullOrEmpty(Msbuild15Path)) | ||
| 58 | { | ||
| 59 | var path = Path.Combine(installPath, Msbuild15RelativePath); | ||
| 60 | if (File.Exists(path)) | ||
| 61 | { | ||
| 62 | Msbuild15Path = path; | ||
| 63 | } | ||
| 64 | } | ||
| 65 | } | ||
| 23 | } | 66 | } |
| 24 | 67 | ||
| 25 | var result = RunProcessCaptureOutput(vswherePath, VswhereFindArguments); | 68 | var msbuildPath = Msbuild15Path ?? Msbuild16Path; |
| 26 | if (result.ExitCode != 0) | 69 | |
| 70 | if (msbuildVersion == "15") | ||
| 27 | { | 71 | { |
| 28 | throw new InvalidOperationException($"Failed to execute vswhere.exe, exit code: {result.ExitCode}"); | 72 | msbuildPath = Msbuild15Path; |
| 29 | } | 73 | } |
| 30 | 74 | else if (msbuildVersion == "16") | |
| 31 | this.Msbuild15Path = Path.Combine(result.Output[0], Msbuild15RelativePath); | ||
| 32 | if (!File.Exists(this.Msbuild15Path)) | ||
| 33 | { | 75 | { |
| 34 | throw new InvalidOperationException($"Failed to find MSBuild v15 at: {this.Msbuild15Path}"); | 76 | msbuildPath = Msbuild16Path; |
| 35 | } | 77 | } |
| 36 | } | ||
| 37 | 78 | ||
| 38 | private string Msbuild15Path { get; } | 79 | return ExecuteCore(msbuildVersion, msbuildPath, projectPath, arguments); |
| 80 | } | ||
| 39 | 81 | ||
| 40 | public MsbuildRunnerResult Execute(string projectPath, string[] arguments = null) | 82 | private static MsbuildRunnerResult ExecuteCore(string msbuildVersion, string msbuildPath, string projectPath, string[] arguments) |
| 41 | { | 83 | { |
| 84 | if (String.IsNullOrEmpty(msbuildPath)) | ||
| 85 | { | ||
| 86 | throw new InvalidOperationException($"Failed to find an installed MSBuild{msbuildVersion}"); | ||
| 87 | } | ||
| 88 | |||
| 42 | var total = new List<string> | 89 | var total = new List<string> |
| 43 | { | 90 | { |
| 44 | projectPath | 91 | projectPath |
| @@ -50,7 +97,7 @@ namespace WixBuildTools.TestSupport | |||
| 50 | } | 97 | } |
| 51 | 98 | ||
| 52 | var workingFolder = Path.GetDirectoryName(projectPath); | 99 | var workingFolder = Path.GetDirectoryName(projectPath); |
| 53 | return RunProcessCaptureOutput(this.Msbuild15Path, total.ToArray(), workingFolder); | 100 | return RunProcessCaptureOutput(msbuildPath, total.ToArray(), workingFolder); |
| 54 | } | 101 | } |
| 55 | 102 | ||
| 56 | private static MsbuildRunnerResult RunProcessCaptureOutput(string executablePath, string[] arguments = null, string workingFolder = null) | 103 | private static MsbuildRunnerResult RunProcessCaptureOutput(string executablePath, string[] arguments = null, string workingFolder = null) |
| @@ -70,8 +117,8 @@ namespace WixBuildTools.TestSupport | |||
| 70 | 117 | ||
| 71 | using (var process = Process.Start(startInfo)) | 118 | using (var process = Process.Start(startInfo)) |
| 72 | { | 119 | { |
| 73 | process.OutputDataReceived += (s, e) => { if (e.Data != null) output.Add(e.Data); }; | 120 | process.OutputDataReceived += (s, e) => { if (e.Data != null) { output.Add(e.Data); } }; |
| 74 | process.ErrorDataReceived += (s, e) => { if (e.Data != null) output.Add(e.Data); }; | 121 | process.ErrorDataReceived += (s, e) => { if (e.Data != null) { output.Add(e.Data); } }; |
| 75 | 122 | ||
| 76 | process.BeginErrorReadLine(); | 123 | process.BeginErrorReadLine(); |
| 77 | process.BeginOutputReadLine(); | 124 | process.BeginOutputReadLine(); |
diff --git a/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj b/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj index bfee2da9..782a0217 100644 --- a/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj +++ b/src/WixBuildTools.TestSupport/WixBuildTools.TestSupport.csproj | |||
| @@ -16,12 +16,12 @@ | |||
| 16 | </ItemGroup> | 16 | </ItemGroup> |
| 17 | 17 | ||
| 18 | <ItemGroup> | 18 | <ItemGroup> |
| 19 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63102-01" PrivateAssets="All" /> | 19 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05 " PrivateAssets="All" /> |
| 20 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> | 20 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> |
| 21 | </ItemGroup> | 21 | </ItemGroup> |
| 22 | 22 | ||
| 23 | <ItemGroup> | 23 | <ItemGroup> |
| 24 | <PackageReference Include="xunit" Version="2.4.0" /> | 24 | <PackageReference Include="xunit.assert" Version="2.4.1" /> |
| 25 | </ItemGroup> | 25 | </ItemGroup> |
| 26 | 26 | ||
| 27 | </Project> | 27 | </Project> |
diff --git a/src/WixBuildTools.XsdGen/WixBuildTools.XsdGen.csproj b/src/WixBuildTools.XsdGen/WixBuildTools.XsdGen.csproj index d4c26dee..ef24420e 100644 --- a/src/WixBuildTools.XsdGen/WixBuildTools.XsdGen.csproj +++ b/src/WixBuildTools.XsdGen/WixBuildTools.XsdGen.csproj | |||
| @@ -19,7 +19,7 @@ | |||
| 19 | </ItemGroup> | 19 | </ItemGroup> |
| 20 | 20 | ||
| 21 | <ItemGroup> | 21 | <ItemGroup> |
| 22 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-63102-01" PrivateAssets="All" /> | 22 | <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-18618-05" PrivateAssets="All" /> |
| 23 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> | 23 | <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.65" PrivateAssets="All" /> |
| 24 | </ItemGroup> | 24 | </ItemGroup> |
| 25 | 25 | ||
