aboutsummaryrefslogtreecommitdiffstats
path: root/Tests/Test_QtMsBuild.Build/Test_IntDir.cs
blob: 357383f9f583d1b624d0b1bc88c2b3574e76bf4f (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
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

using System;
using System.IO;
using Microsoft.Build.Construction;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace QtVsTools.Test.QtMsBuild.Build
{
    [TestClass]
    public class Test_IntDir
    {
        [TestMethod]
        public void IntDir()
        {
            using var temp = new TempProject();
            temp.Clone($@"{Properties.SolutionDir}Tests\ProjectFormats\304\QtProjectV304.vcxproj");
            var xml = ProjectRootElement.Open(temp.ProjectPath);
            var props = xml.AddPropertyGroup();
            props.AddProperty("OldIntDir", "$(IntDir)");
            props.AddProperty("IntDir", @"$(ProjectDir)build\$(Configuration)\");
            xml.Save();

            var project = MsBuild.Evaluate(temp.ProjectPath,
                ("Platform", "x64"), ("Configuration", "Debug"));
            Assert.IsTrue(project.Build("Rebuild"));
            Assert.IsTrue(
                File.Exists(project.ExpandString($@"$(IntDir)qt\qmake\props.txt")));
            Assert.IsFalse(
                File.Exists(project.ExpandString($@"$(OldIntDir)qt\qmake\props.txt")));
        }
    }
}