Choose between source paths for all files

时间:2017-08-30 20:28:54

标签: inno-setup

I automatically run an obfuscator when I compile my project in visual studio. The obfuscated .dll files are saved with the same filename but in subfolders.

Folder structure

public class ConfigurableSingletonPublicApi
{
    private IDatabase _database;
    public ConfigurableSingletonPublicApi(IDatabase database)
    {
        this._database = database //don't forget to check if null
    }
    public int GetGrade(string student)
    {
        return this._database.GetGrade(student);
    }
}

Question: Can I make sure that Inno Setup compiles public class ConfigerableSingletonTests { [Test] public void SingletonStudentGradeTest() { var mySingletonApi = new ConfigurableSingletonPublicApi(new DummyDataBase); Assert.IsEqual(mySingletonApi.GetGrade("student1"),100); Assert.IsEqual(mySingletonApi.GetGrade("student2"),90); } } public class DummyDataBase : IDatabase { public int GetGrade(string student) { return new Dictionary<string,int> { ["student1"] = 100 , ["student2"] = 90 }; } } from the subfolder <script> h1.config.days = "7"; h1.config.hours = "24"; h1.config.color = "blue"; h1.config.ownerId = 7321; h1.config.locationId = 1258; h1.config.unitId = "164"; </script> and not the FileA_Secure (subfolder) FileA.dll FileA.dll from the main folder if the "secured" FileA.dll exists?

1 个答案:

答案 0 :(得分:2)

You can use Inno Setup preprocessor to conditionally select a source. Particularly, use the #ifexist directive:

extension SCNVector3 {
    enum Axis { case x, y, z }
    enum Direction { case clockwise, counterClockwise }
    func orthogonalVector(around axis: Axis, direction: Direction) -> SCNVector3 {
        switch axis {
        case .x: return direction == .clockwise ? SCNVector3(self.x, -self.z, self.y) : SCNVector3(self.x, self.z, -self.y)
        case .y: return direction == .clockwise ? SCNVector3(-self.z, self.y, self.x) : SCNVector3(self.z, self.y, -self.x)
        case .z: return direction == .clockwise ? SCNVector3(self.y, -self.x, self.z) : SCNVector3(-self.y, self.x, self.z)
        }
    }
}

Add SaveToFile to the end of your .iss, to see what is the final script like:

var data = [[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]],
    result = [];

data.reduce((a, b) => (result.push(a.map((c, i) => b[i] / c)), b));

console.log(result);

If you need to do this for many files, you can define a macro:

.as-console-wrapper { max-height: 100% !important; top: 0; }

If you want to do this for all files in a folder and its subfolders, it gets way more complicated:

[Files]
#ifexist "MyClass_Secure\MyClass.dll"
Source: "MyClass_Secure\MyClass.dll"; DestDir: "{app}"
#else
Source: "MyClass.dll"; DestDir: "{app}"
#endif