DSC Package resource have identical key properties - powershell

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?

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.

Related

gradle openapi generator doesn't work for selective generation

When we run gradle openapi generator tasks, part of the generated output has an infrastructure folder with all of the shared/common files required for the client to build.
When I start specifying the apis and models that I want generated, then this infrastructure folder is no longer created, so nothing builds!!
What am I doing wrong?
task buildMyClient(type: org.openapitools.generator.gradle.plugin.tasks.GenerateTask){
generatorName = "kotlin"
inputSpec = "$rootDir/openapi/specs/myservice.yaml".toString()
outputDir = "$buildDir/generated".toString()
apiPackage = "com.mycompany.myservice"
packageName = "com.mycompany.myservice"
modelPackage = "com.mycompany.myservice.model"
globalProperties = [
apis: "MyController",
models: "MyApiRequest,MyApiResponse,EmbeddedApiResponse"]
configOptions = [
"enumPropertyNaming": "UPPERCASE"
]
}
Here are the docs on the gradle plugin:
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator-gradle-plugin/README.adoc
Here are the docs on global properties:
https://openapi-generator.tech/docs/globals/
Seems that I might have to specify all supporting files? How do I do that? There isn't some way to use the default?

Group Item: cannot install file to same location

In my project, I have several plugins depending on a single module, containing a Group item similar to:
Group {
name: "group"
qbs.install: true
qbs.installDir: "../"
files: <filename>
}
But compilation fails with "error: Cannot install files 'filename' and 'filename' to the same location 'location'". Basically, qbs cannot copy same file to same location twice (seems illogical to me)
How can this bug be resolved or is there any elegant workaround?
This is a job for the qbs.installSourceBase property. Basically, you set this to the base directory containing the files in your Group, and Qbs will install the listed files into qbs.installDir hierarchically based on their paths relative to the aforementioned base directory.
For example, given the following Group:
// defined in /source/myproject/myproject.qbs
Group {
qbs.install: true
qbs.installDir: "share/stuff"
qbs.installSourceBase: "." // relative to /source/myproject
files: [
"fileA.txt",
"fileB.txt",
"subdir/fileB.txt",
]
}
and the following command line invocation:
$ qbs [...] --install-root /sample/some-root
the following filesystem hierarchy will result:
/sample/some-root/share/stuff/fileA.txt
/sample/some-root/share/stuff/fileB.txt
/sample/some-root/share/stuff/subdir/fileB.txt
See the Qbs Installation Properties documentation for more info.
There is a workaround, which may require some restructuring of a project:
instead of:
Module {
name: "somemodule"
// module properties set to dependant products
Group {
// files to install
qbs.install: true
}
}
we can use:
Product {
name: "somemodule"
Group {
// files to install
qbs.install: true
}
Export {
// module properties set to dependant products
}
}
This way, files are only installed once when steps for mymodule are run, thus eliminating the conflict. Module properties, exported via Export Item, work just as ones exported via Module.
Limitations:
Product has to be added to references of the Project Item
Modules cannot depend on Product Items, which may require to restructure all dependant modules into Project/Export pairs too

Set TFS build version number PowerShell

I know that similar question already exist, but I cannot find appropriate answer.
My question is: Is it possible to set new build version number int TFS with PowerShell?
I want to create build version number and set through PowerShell. I want exactly like that, no other solutions.
Thanks
How about this?
# Change the following to your TFS collection and build URIs...
# These environment variables will exist during TFS builds
[String] $CollectionUrl = "$env:TF_BUILD_COLLECTIONURI"
[String] $BuildUrl = "$env:TF_BUILD_BUILDURI"
# Get the Team Project Collection:
$teamProjectCollection = [Microsoft.TeamFoundation.Client.TfsTeamProjectCollectionFactory]::GetTeamProjectCollection($CollectionUrl)
# Connect to the TFS build service:
$buildServer = $teamProjectCollection.GetService([Microsoft.TeamFoundation.Build.Client.IBuildServer])
# Get the build detail:
$buildDetail = $buildServer.GetBuild($BuildUrl)
# Updating the TFS build number with an example SemVer:
$buildDetail.BuildNumber = "1.2.3-alpha1"
# Make sure to save the changes:
$buildDetail.Save()

Installing an exe with Powershell DSC Package resource gets return code 1619

I'm trying to use Powershell DSC's Package resource to install an exe... Perforce's P4V to be specific. Here's my code:
Configuration PerforceMachine
{
Node "SERVERNAME"
{
Package P4V
{
Ensure = "Present"
Name = "Perforce Visual Components"
Path = "\\nas\share\p4vinst64.exe"
ProductId = ''
Arguments = "/S /V/qn" # args for silent mode
LogPath = "$env:ProgramData\p4v_install.log"
}
}
}
When running this, this is the error Powershell gives me:
PowerShell provider MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: The return code 1619 was not expected. Configuration is likely not
correct
+ CategoryInfo : InvalidOperation: (:) [], CimException
+ FullyQualifiedErrorId : ProviderOperationExecutionFailure
+ PSComputerName : SERVERNAME
According to documentation, return code 1619 means the MSI package couldn't be opened. However, when I manually log in to the machine and run "\\nas\share\p4vinst64.exe /S /V/qn", the install works flawlessly.
Does anyone know why this is failing? Alternately, can anyone tell me how to troubleshoot this? I pasted all the error information I got from the terminal, my log file (p4v_install.log) is a 0 byte file, and there are no events in the event viewer. I don't know how to troubleshoot it any further!
EDIT: I should note that I also tried using the File resource to copy the file locally, and then install it from there. Sadly, that met with the same result.
Daniel over at the Powershell.org forums was able to figure this out for me.
The P4V InstallShield setup wrapper puts the MSI file into wrong path if you execute as LocalSystem.
I’ve managed to develop a Configuration that works, see below. The key is the /b switch here which puts the MSI file into a defined location. I’ve added ALLUSERS=1 to get the shortcuts visible to all users and REBOOT=ReallySuppress to avoid a sudden restart (which will happen otherwise).
Configuration PerforceMachine
{
Package P4V
{
Ensure = "Present"
Name = "Perforce Visual Components"
Path = "C:\My\p4vinst64.exe"
ProductId = ''
Arguments = '/b"C:\Windows\Temp\PerforceClient" /S /V"/qn ALLUSERS=1 REBOOT=ReallySuppress"' # args for silent mode
}
}
Well, what happens here is that the package gets installed (not tested with p4vinst64.exe yet! So, not sure why it says pack cannot be opened as the error) but since you did not specify a ProductID value, the verification at the end of install fails. That is the error you are seeing. The Package resource is no good for installing .exe packages or even MSIs with no ProductID represented as a GUID.
You can use the WindowsProcess resource instead.

Firebird custom installation

I want to deploy a firebird installation, and thus will launch it from my installer using command-line parameters. I read Inno Setup's documentation but still can't get it to work.
I just want to install a "Super server" with no documentation or whatsoever.
Here's what I have so far
Firebird-2.1.2.18118_0_Win32.exe /sp- /silent /SUPPRESSMSGBOXES /nocancel /noicons /components="Super Server binary"
But it won't install the server. If I remove the /components it does install the server but install other developer stuff, which customers don't need.
read installation_scripted.txt in C:\Program Files\Firebird\Firebird_2_1\doc
/COMPONENTS="comma separated list of
component names"
Choose from -
ServerComponent\SuperServerComponent,
ServerComponent\ClassicServerComponent,
ServerComponent,
DevAdminComponent and
ClientComponent
Overrides the default components
settings. Using this command line
parameter causes Setup to
automatically select a custom type. A
full install requires combining
components. For example:
/COMPONENTS="ServerComponent\SuperServerComponent,ServerComponent,DevAdminComponent,ClientComponent"
would be required for a full
install.
I use the following and it works fine, however I need to install to a custom directory and also change the server option
string installerFilePath = #"C:\BennaOlivier\Randoms\Delter\Firebird\FirebirdMainInstaller\MainInstaller\MainInstaller\Firebird X64\FirebirdInstallX64\Firebird-2.5x64.exe";
Process installerProcess = new Process();
installerProcess = Process.Start(installerFilePath, Arguments);
while (installerProcess.HasExited == false)
{
//indicate progress to user
Application.DoEvents();
System.Threading.Thread.Sleep(250);
}
}
catch (Exception FBX64)
{
MessageBox.Show(FBX64.Message);
throw;
}public const string comps = #"ServerComponent\ClassicServerComponent,ServerComponent,ClientComponent";
public const string Arguments = "/VERYSILENT /SUPPRESSMSGBOXES";