3

I'm trying to first uninstall a package, then install the latest version of that same package. Simple you would think, but when I include the following code in my DSC configuration:

    ### 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'
    }

While creating the .mof file, I receive the following error:

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'.

I don't want to use a Script resource to process my uninstall. What am I doing wrong here?

Samer
  • 3,848
  • 4
  • 25
  • 24

1 Answers1

1

Your configuration is supposed to be idempotent, generally, so this doesn't make a lot of sense. You would be uninstalling and reinstalling the package every time the configuration is applied (every 30 minutes or whatever it's set to).

An MSI installer should support upgrading automatically, which means you would just ensure the installation of the (newer) MSI.

briantist
  • 45,546
  • 6
  • 82
  • 127
  • My intention is to uninstall the older version of the package, then install the newer latest version of a product (which is continuously being updated under development). Here is a better question: Will the Package resource check if the .msi file include the same exact installation? I doubt it. My understanding is that the Package resource will only install the Package if it does not exist, not when it's out of date. – Samer Mar 24 '16 at 16:56
  • To clarify, I'm setting up a configuration of a QA VM which will fetch the latest Dev .msi files and install them on the QA vm automatically. – Samer Mar 24 '16 at 16:58
  • @SamersSalib if you enter a product id, and the product ID changes when the package is updated, then it may work. You might also look at the `xPackage` resource in the [`xPSDesiredStateConfiguration`](https://github.com/PowerShell/xPSDesiredStateConfiguration) module, which has additional parameters (like `Version`) that might make this run more smoothly. The way you're doing it now is not correct though and will result in constant uninstallation and reinstallation, whether the package is updated or not. – briantist Mar 24 '16 at 17:01
  • "may work." doesn't satisfy, and the product with which I'm dealing, doesn't have a product ID. However, a `Version` parameter is exactly what I'm looking for!!! Thank you @briantist. This answers my question. – Samer Mar 24 '16 at 17:06
  • OOPS!! The latest DSC release (3.9.0.0 released 6 days prior to the time stamp of this comment!) does NOT include a `Version` property in its `xPackage` resource, DESPITE of what the github page claims in its documentaion. @briantist – Samer Apr 05 '16 at 21:13
  • @SamersSalib I haven't worked on that project. I recommend you open an issue on the github page to get a response directly from the developers. – briantist Apr 05 '16 at 21:24
  • what is an alternative answer to my initial question given that there isn't a `Version` property. I filed an issue on the github repo. – Samer Apr 05 '16 at 21:41