aboutsummaryrefslogtreecommitdiff
path: root/src/test/WixToolsetTest.MSBuild/MsbuildUtilities.cs
blob: d4815bde04d046248c695f44adcae4094ca52822 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright(c) .NET Foundation and contributors.All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.

namespace WixToolsetTest.MSBuild
{
    using System;
    using System.Collections.Generic;
    using System.IO;
    using WixBuildTools.TestSupport;

    public enum BuildSystem
    {
        MSBuild,
        MSBuild64,
    }

    public static class MsbuildUtilities
    {
        public static readonly string WixPropsPath = Path.Combine(new Uri(typeof(MsbuildUtilities).Assembly.CodeBase).AbsolutePath, "..", "..", "publish", "WixToolset.MSBuild", "build", "WixToolset.MSBuild.props");

        public static MsbuildRunnerResult BuildProject(BuildSystem buildSystem, string projectPath, params string[] arguments)
        {
            var allArgs = new List<string>
            {
                $"-p:WixMSBuildProps={MsbuildUtilities.WixPropsPath}",
            };

            if (arguments != null)
            {
                allArgs.AddRange(arguments);
            }

            switch (buildSystem)
            {
                case BuildSystem.MSBuild:
                case BuildSystem.MSBuild64:
                    {
                        return MsbuildRunner.Execute(projectPath, allArgs.ToArray(), buildSystem == BuildSystem.MSBuild64);
                    }
                default:
                    {
                        throw new NotImplementedException();
                    }
            }
        }
    }
}