DSC 包资源具有相同的关键属性

DSC Package resource have identical key properties

我正在尝试先卸载一个包,然后再安装该包的最新版本。您会认为很简单,但是当我在我的 DSC 配置中包含以下代码时:

    ### remove old product setup
    Package removeOldProduct {
        Ensure = 'Absent'
        Name = 'My Product Name'
        Path = ""
        ProductId = ""
    }
    ### now install the latest product setup
    Package productSetup {
        Ensure = 'Present'
        Name = 'My Product Name'
        Path = "$productShare\Repository\product.msi"
        ProductId = ""
        Arguments = "ACCEPT_EULA=1 /q"
        DependsOn = '[Package]MsSql'
    }

创建 .mof 文件时,我收到以下错误:

Test-ConflictingResources : A conflict was detected between resources '[Package]productSetup and '[Package]removeOldProduct in node 'myNodeServer'. Resources have identical key properties but there are differences in the following non-key properties: 'Path;Ensure;Arguments'.

我不想使用脚本资源来处理我的卸载。我在这里做错了什么?

一般来说,您的配置应该是幂等的,所以这没有多大意义。每次应用配置时(每 30 分钟或设置的任何值),您都将卸载并重新安装软件包。

MSI 安装程序应该支持自动升级,这意味着您只需确保安装(更新的)MSI。