summaryrefslogtreecommitdiff
path: root/src/test/wix/WixE2E/WixE2EFixture.cs
blob: 89762f726bb9c826ea54c664c0fa5a75f5d2ac82 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// 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 WixE2E
{
    using System.IO;
    using WixBuildTools.TestSupport;
    using Xunit;

    public class WixE2EFixture
    {
        [Fact]
        public void CanBuildWixlibWithNativeDll()
        {
            var projectPath = TestData.Get("TestData", "WixprojLibraryVcxprojDll", "WixprojLibraryVcxprojDll.wixproj");

            CleanEverything();

            var result = RestoreAndBuild(projectPath);
            result.AssertSuccess();
        }

        [Fact]
        public void CanBuildModuleWithWinFormsApp()
        {
            var projectPath = TestData.Get("TestData", "WixprojModuleCsprojWinFormsNetFx", "WixprojModuleCsprojWinFormsNetFx.wixproj");

            CleanEverything();

            var result = RestoreAndBuild(projectPath);
            result.AssertSuccess();
        }

        [Fact]
        public void CanBuildPackageWithWebApp()
        {
            var projectPath = TestData.Get("TestData", "WixprojPackageCsprojWebApplicationNetCore", "WixprojPackageCsprojWebApplicationNetCore.wixproj");

            CleanEverything();

            var result = RestoreAndBuild(projectPath);
            result.AssertSuccess();
        }

        [Fact]
        public void CanBuildPackageWithNativeWindowsApp()
        {
            var projectPath = TestData.Get("TestData", "WixprojPackageVcxprojWindowsApp", "WixprojPackageVcxprojWindowsApp.wixproj");

            CleanEverything();

            var result = RestoreAndBuild(projectPath);
            result.AssertSuccess();
        }

        private static void CleanEverything()
        {
            var rootFolder = TestData.Get("TestData");
            var deleteFolders = new[] { "Debug", "bin", "obj" };

            foreach (var projectFolder in Directory.GetDirectories(rootFolder))
            {
                foreach (var deleteFolder in deleteFolders)
                {
                    var folder = Path.Combine(projectFolder, deleteFolder);

                    if (Directory.Exists(folder))
                    {
                        Directory.Delete(folder, true);
                    }
                }
            }
        }

        private static MsbuildRunnerResult RestoreAndBuild(string projectPath, bool x64 = true)
        {
            return MsbuildRunner.Execute(projectPath, new[] { "-Restore", "-v:m", "-bl" }, x64);
        }
    }
}