简体   繁体   English

适用于InstallShield项目的Stylecop

[英]Stylecop for InstallShield project

I need to make sure that InstallShield has only allowed settings. 我需要确保InstallShield仅允许设置。 I would like to run this check on CI server. 我想在CI服务器上运行此检查。

In other words in Component table I would like to check Attributes fields has only allowed values( <td>8</td> , <td>1</td> ) 换句话说,在“ Component表”中,我想检查“ Attributes字段仅具有允许的值( <td>8</td><td>1</td>

<table name="Component">
    <col key="yes" def="s72">Component</col>
    <col def="S38">ComponentId</col>
    <col def="s72">Directory_</col>
    <col def="i2">Attributes</col>
    <col def="S255">Condition</col>
    <col def="S72">KeyPath</col>
    <col def="I4">ISAttributes</col>
    <col def="S255">ISComments</col>
    <col def="S255">ISScanAtBuildFile</col>
    <col def="S255">ISRegFileToMergeAtBuild</col>
    <col def="S0">ISDotNetInstallerArgsInstall</col>
    <col def="S0">ISDotNetInstallerArgsCommit</col>
    <col def="S0">ISDotNetInstallerArgsUninstall</col>
    <col def="S0">ISDotNetInstallerArgsRollback</col>
        <row>
            <td>Adapter</td>
            <td>{05A86BD3-38F8-40CC-8A16-AB643A555787}</td>
            <td>ADAPTER</td>
            <td>8</td>
            <td/>
            <td>adapter.dll</td>
            <td>1</td>
            <td/>
            <td/>
            <td/>
            <td>/LogFile=</td>
            <td>/LogFile=</td>
            <td>/LogFile=</td>
            <td>/LogFile=</td>
        </row>

The straightforward approach would be create PowerShell script to parse the project file as XML, find corresponding values, and make sure they are in allowed range. 直接的方法是创建PowerShell脚本,以将项目文件解析为XML,找到相应的值,并确保它们在允许的范围内。

Is there more elegant way to do so like tool similar to StyleCop? 有没有像StyleCop这样的工具更优雅的方式做到这一点? As custom PowerShell script would be expensive to support by its own. 作为自定义的PowerShell脚本,要单独支持它会很昂贵。

Thanks to comment from Steve I got working PowerShell version without need to manually parse InstallShield project file. 感谢Steve的评论,我可以使用PowerShell版本,而无需手动解析InstallShield项目文件。

Using Automation Interface It is quite easy to check a component for errorneous configuration. 使用自动化接口检查组件的错误配置非常容易。

$projectFile = "project.ism"

$project = new-object -comobject IswiAuto16.ISWiProject

$project.OpenProject($projectFile)

Foreach ($feature in $project.ISWiFeatures)
{
    Foreach ($component in $feature.ISWiComponents)
    {
        if(<check $component  for an errorneous config>)
        {
            <report an issue here>
        }
    }
}

$project.CloseProject()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM