[SOLVED]Unterschiedliche Produkte in ein Paket

Antworten
mopsi
Beiträge: 33
Registriert: 23 Apr 2021, 13:25

[SOLVED]Unterschiedliche Produkte in ein Paket

Beitrag von mopsi »

Hallo zusammen,

erstmal muss ich mich für den super Support in diesem Forum bedanken! Ich hätte noch eine Frage:
Wir haben unterschiedliche Versionen bei Visual Studio:

1. Auswahlmöglichkeit: Enterprise oder Professional
2. Auswahlmöglichkeit: Sprache (Englisch / Deutsch)
3. Auswahlmöglichkeit: Unterschiedliche Workloads (andere Parameter beim Ausführen des Installers)

Ich hab hier nun Produkteigenschaften angelegt, wie kann ich nun die Auswahlmöglichkeit im script verarbeiten? Gibt es hierzu eventuell schon ein kleines Beispielscript zur Orientierung?

Ich bedanke mich jetzt schon für die Hilfe!

Gruß
Zuletzt geändert von mopsi am 19 Mai 2021, 11:42, insgesamt 1-mal geändert.
mopsi
Beiträge: 33
Registriert: 23 Apr 2021, 13:25

Re: Unterschiedliche Produkte in ein Paket

Beitrag von mopsi »

thomas.besser hat geschrieben:https://download.uib.de/opsi_stable/doc ... ctProperty

sollte weiterhelfen.
Hi,

erstmal vielen Dank für die Information. Ich habe nun erfolgreich die Produkteigenschaften in unterschiedliche Variablen gespeichert. Anschließend habe ich mehrere verschachtelte IF-Anweisungen gemacht. Leider kommt bei mir im Log immer der Fehler:

Lasterror: 2 (The system cannot find the file specified.)
Error: Could not execute process "if(Professional(License Key) = "Enterprise(Account)")"


Für die Variablen EingabeSprache = "German" oder "Englisch"; Eingabe Version = "Enterprise(Account)" oder "Professional(License Key)"; EingabeAbteilung = "Warehouse" oder "CRM"

Hier meine IF-Verzweigungen:

Code: Alles auswählen

if($EingabeVersion$ = "Enterprise(Account)")
	if("$EingabeSprache$" = "German")
		if("$EingabeAbteilung$" = "CRM")
		"%ScriptPath%\vs_enterprise.exe" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoadsCRM$ --passive --norestart --locale 		de-DE
		else
		"%ScriptPath%\vs_enterprise.exe" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoadsWarehouse$ --passive --norestart --locale de-DE
		endif
	else
		if("$EingabeAbteilung$" = "CRM")
		"%ScriptPath%\vs_enterprise.exe" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoadsCRM$ --passive --norestart --locale en-US
		else
		"%ScriptPath%\vs_enterprise.exe" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoadsWarehouse$ --passive --norestart --locale en-US	
		endif
	endif	
else
	if("$EingabeSprache$" = "German")
		if("$EingabeAbteilung$" = "CRM")
		"%ScriptPath%\vs_professional.exe" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoadsCRM$ --passive --norestart --locale de-DE
		else
		"%ScriptPath%\vs_professional.exe" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoadsWarehouse$ --passive --norestart --locale de-DE
		endif
	else
		if("$EingabeAbteilung$" = "CRM")
		"%ScriptPath%\vs_professional.exe" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoadsCRM$ --passive --norestart --locale en-US
		else
		"%ScriptPath%\vs_professional.exe" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoadsWarehouse$ --passive --norestart --locale en-US
		endif
	endif
endif	
Hat jemand eine Vermutung warum einfach alle Befehle ausgeführt werden und die Verzweigungen ignoriert werden?

Vielen Dank und Gruß
Jan.Schmidt
Beiträge: 439
Registriert: 08 Jul 2017, 12:02

Re: Unterschiedliche Produkte in ein Paket

Beitrag von Jan.Schmidt »

dazu müsste man das ganze script sehen...
Vermutlich liegt es aber daran, das du klammern da benutzt, wo Sie nicht hingehören.

Code: Alles auswählen

if($EingabeVersion$ = "Enterprise_Account")
Dann ein anderer Tipp

Mach es nicht so kompliziert eine einzelne Installzeile reicht völlig, wenn du Variablen richtig einsetzt.

Code: Alles auswählen

def var $locale$
if x 
  set $locale$ = "en-US"
else 
  set $locale$ = "de-DE"
endif
   
/snip
\snap
"%ScriptPath%\vs_enterprise.exe" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoadsWarehouse$ --passive --norestart --locale $locale$   
wenn du ein vor deinen "%ScriptPath%\vs_enterprise.exe schreibst, und die zeile danch nochmal nimmst (ohne echo so wie aktuell) dann siehst du bestimmt mehr in deinem logfile...
Benutzeravatar
SisterOfMercy
Beiträge: 1523
Registriert: 22 Jun 2012, 19:18

Re: Unterschiedliche Produkte in ein Paket

Beitrag von SisterOfMercy »

And don't forget to put the executable stuff in a Winbatch section.
Bitte schreiben Sie Deutsch, when I'm responding in the German-speaking part of the forum!
mopsi
Beiträge: 33
Registriert: 23 Apr 2021, 13:25

Re: Unterschiedliche Produkte in ein Paket

Beitrag von mopsi »

Guten Morgen,

ich habe nun mein Script angepasst bzw. vereinfacht :) Hier meine Log-Datei vom Server und mein Script:

Code: Alles auswählen

[Actions]
requiredWinstVersion >= "4.11.4.6"
ScriptErrorMessages=off


DefVar $LogDir$
DefVar $ProductId$
DefVar $MinimumSpace$
DefVar $InstCfg$
DefVar $WrkLoads$
DefVar $ExitCode$
DefVar $EingabeSprache$
DefVar $EingabeAbteilung$
DefVar $EingabeVersion$
DefVar $Sprache$
DefVar $Setup$

Set $LogDir$ = "%SystemDrive%\temp\lm-visualstudio2019-script.log"
Set $ProductId$ = "Visual Studio 2019"
Set $MinimumSpace$ = "800MB"
Set $InstCfg$ = "x"
Set $WrkLoads$ = "Microsoft.VisualStudio.Workload.ManagedDesktop --includeRecommended --includeOptional"
Set $EingabeSprache$ = GetProductProperty("language", "German")
Set $EingabeAbteilung$ = GetProductProperty("department-selection", "CRM")
Set $EingabeVersion$ = GetProductProperty("version-selection", "Enterprise(Account)")


if not(HasMinimumSpace ("%SystemDrive%", $MinimumSpace$))
        LogError "Not enough space on %SystemDrive%, " + $MinimumSpace$ + " on drive %SystemDrive% needed for " + $ProductId$
        isFatalError "No Space"
        ; Stop process and set installation status to failed
		
else
        if FileExists("%ScriptPath%\delsub.opsiscript")
                comment "Start uninstall sub section"
                Sub "%ScriptPath%\delsub.opsiscript"
        
		comment "Show product picture"
		ShowBitmap "%ScriptPath%\" + $ProductId$ + ".png" $ProductId$
		Message "Installing " + $ProductId$ + " ..."
		if("$EingabeAbteilung$" = "CRM")
			Set $WrkLoads$ = "Microsoft.VisualStudio.Workload.ManagedDesktop --add Microsoft.VisualStudio.Workload.NetWeb --includeRecommended --includeOptional"
		else
			Set $WrkLoads$ = "Microsoft.VisualStudio.Workload.ManagedDesktop --includeRecommended --includeOptional"
			endif
	
		if("$EingabeSprache$" = "German")
			Set $Sprache$ = de-DE
		else
			Set $Sprache$ = en-US
			endif
	
		if("$EingabeVersion$" = "Enterprise(Account)
			Set $Setup$ = vs_enterprise.exe
		else
			Set $Setup$ = vs_professional.exe
			endif
		Winbatch_Install
		Sub_check_exitcode
		endif






[Winbatch_Install]
"%ScriptPath%\$Setup$" --add Microsoft.VisualStudio.Component.CoreEditor --add $WrkLoads$ --passive --norestart --locale $Sprache$

Code: Alles auswählen

opsi-script has version  4.12.4.13, required is : >= 4.11.4.6
(84)      [6] [2021-05-19 07:51:18.310] [visualstudio] ScriptErrorMessages was False is set to false
(85)      [6] [2021-05-19 07:51:18.312] [visualstudio] Set  $LogDir$ = "C:\temp\lm-visualstudio2019-script.log"
(86)      [6] [2021-05-19 07:51:18.312] [visualstudio]   The value of the variable "$LogDir$" is now: "C:\temp\lm-visualstudio2019-script.log"
(87)      [6] [2021-05-19 07:51:18.312] [visualstudio] Set  $ProductId$ = "Visual Studio 2019"
(88)      [6] [2021-05-19 07:51:18.312] [visualstudio]   The value of the variable "$ProductId$" is now: "Visual Studio 2019"
(89)      [6] [2021-05-19 07:51:18.312] [visualstudio] Set  $MinimumSpace$ = "800MB"
(90)      [6] [2021-05-19 07:51:18.312] [visualstudio]   The value of the variable "$MinimumSpace$" is now: "800MB"
(91)      [6] [2021-05-19 07:51:18.312] [visualstudio] Set  $InstCfg$ = "x"
(92)      [6] [2021-05-19 07:51:18.312] [visualstudio]   The value of the variable "$InstCfg$" is now: "x"
(93)      [6] [2021-05-19 07:51:18.312] [visualstudio] Set  $WrkLoads$ = "Microsoft.VisualStudio.Workload.ManagedDesktop --includeRecommended --includeOptional"
(94)      [6] [2021-05-19 07:51:18.313] [visualstudio]   The value of the variable "$WrkLoads$" is now: "Microsoft.VisualStudio.Workload.ManagedDesktop --includeRecommended --includeOptional"
(95)      [6] [2021-05-19 07:51:18.313] [visualstudio] Set  $EingabeSprache$ = GetProductProperty("language", "German")
(96)      [6] [2021-05-19 07:51:18.313] [visualstudio]   The value of the variable "$EingabeSprache$" is now: "English"
(97)      [6] [2021-05-19 07:51:18.313] [visualstudio] Set  $EingabeAbteilung$ = GetProductProperty("department-selection", "CRM")
(98)      [6] [2021-05-19 07:51:18.313] [visualstudio]   The value of the variable "$EingabeAbteilung$" is now: "CRM"
(99)      [6] [2021-05-19 07:51:18.313] [visualstudio] Set  $EingabeVersion$ = GetProductProperty("version-selection", "Enterprise(Account)")
(100)     [6] [2021-05-19 07:51:18.313] [visualstudio]   The value of the variable "$EingabeVersion$" is now: "Enterprise(Account)"
(101)     [6] [2021-05-19 07:51:18.313] [visualstudio] If
(102)     [6] [2021-05-19 07:51:18.314] [visualstudio]     Free on Disk C:: 14,627,667,968 bytes  This is more than the required amount of 800,000,000 bytes
(103)     [6] [2021-05-19 07:51:18.314] [visualstudio]   not(HasMinimumSpace ("C:", $MinimumSpace$))   <<< result false
(104)     [6] [2021-05-19 07:51:18.314] [visualstudio] Then
(105)     [6] [2021-05-19 07:51:18.314] [visualstudio] Else
(106)     [6] [2021-05-19 07:51:18.314] [visualstudio]   If
(107)     [6] [2021-05-19 07:51:18.314] [visualstudio]     Starting query if file exist ...
(108)     [6] [2021-05-19 07:51:18.315] [visualstudio]     FileExists("p:\visualstudio\delsub.opsiscript")   <<< result true
(109)     [6] [2021-05-19 07:51:18.315] [visualstudio]   Then
(110)     [5] [2021-05-19 07:51:18.315] [visualstudio]     comment: Start uninstall sub section
(111)     [6] [2021-05-19 07:51:18.327] [visualstudio]     
(112)     [6] [2021-05-19 07:51:18.327] [visualstudio]     ~~~~~~~ Start Sub ~~~~~~~  Sub "p:\visualstudio\delsub.opsiscript"
(113)     [6] [2021-05-19 07:51:18.327] [visualstudio]     Section ending since next line is starting with "["
(114)     [6] [2021-05-19 07:51:18.327] [visualstudio]     
(115)     [6] [2021-05-19 07:51:18.327] [visualstudio]     ~~~~~~~ End Sub   ~~~~~~~  Sub "p:\visualstudio\delsub.opsiscript"
(116)     [6] [2021-05-19 07:51:18.327] [visualstudio]     
(117)     [5] [2021-05-19 07:51:18.331] [visualstudio]     comment: Show product picture
(118)     [5] [2021-05-19 07:51:18.358] [visualstudio]     message Installing Visual Studio 2019 ...
(119)     [6] [2021-05-19 07:51:18.360] [visualstudio]     If
(120)     [6] [2021-05-19 07:51:18.360] [visualstudio]       ("$EingabeAbteilung$" = "CRM")   <<< result false
(121)     [6] [2021-05-19 07:51:18.360] [visualstudio]     Then
(122)     [6] [2021-05-19 07:51:18.360] [visualstudio]     Else
(123)     [6] [2021-05-19 07:51:18.364] [visualstudio]       Set  $WrkLoads$ = "Microsoft.VisualStudio.Workload.ManagedDesktop --includeRecommended --includeOptional"
(124)     [6] [2021-05-19 07:51:18.364] [visualstudio]         The value of the variable "$WrkLoads$" is now: "Microsoft.VisualStudio.Workload.ManagedDesktop --includeRecommended --includeOptional"
(125)     [6] [2021-05-19 07:51:18.364] [visualstudio]     EndIf
(126)     [6] [2021-05-19 07:51:18.364] [visualstudio]     If
(127)     [6] [2021-05-19 07:51:18.364] [visualstudio]       ("$EingabeSprache$" = "German")   <<< result false
(128)     [6] [2021-05-19 07:51:18.364] [visualstudio]     Then
(129)     [6] [2021-05-19 07:51:18.364] [visualstudio]     Else
(130)     [6] [2021-05-19 07:51:18.367] [visualstudio]       Set  $Sprache$ = en-US
(131)     [2] [2021-05-19 07:51:18.368] [visualstudio]       Syntax Error in Section: Actions (Command in line 62 in section: Actions; file: install.opsiscript; section start at line: 13; origin: install.opsiscript; line: 62): $Sprache$ = en-US -> en-US illegal String Expressionstr
(132)     [2] [2021-05-19 07:51:18.368] [visualstudio]       Syntax Error in Section: Actions (Command in line 63 in section: Actions; file: install.opsiscript; section start at line: 13; origin: install.opsiscript; line: 63): EndIf -> expected
(133)     [1] [2021-05-19 07:51:18.368] [visualstudio] ___________________
(134)     [1] [2021-05-19 07:51:18.368] [visualstudio] script finished: failed
Die Werte werden von der Funktion GetProductProperty richtig abgegriffen und in den oben stehenden Variablen gespeichert. Nun verwende ich diese Variablen in meinen IF-Abfragen. Hier die folgende Probleme:

1. Variable EingabeAbteilung hat den Wert "CRM" und wird mit der IF verglichen, müsste als True sein (CRM=CRM). Hier sagt er false und geht in die else, gleiches Problem hatte ich auch mit der EingabeSprache (German=German --> false)
2. Ist es nicht möglich den Wert (en-US, de-DE) als String zu speichern? Gibt es hier eine andere Möglichkeit?

Vielen Dank und Gruß
mopsi
Beiträge: 33
Registriert: 23 Apr 2021, 13:25

Re: Unterschiedliche Produkte in ein Paket

Beitrag von mopsi »

Ich glaube das Problem ist der Bindestrich zwischen en-US und de-DE. Hier bekomme ich den Expressionstr error.
Wie bekomme ich dass erfolgreich in eine Variable gespeichert?

Gruß
mopsi
Beiträge: 33
Registriert: 23 Apr 2021, 13:25

Re: [SOLVED]Unterschiedliche Produkte in ein Paket

Beitrag von mopsi »

Problem ist gelöst. Ich habe vergessen, die Anführungszeichen beim zuweisen des Wertes der Variable zu setzen :D

Gruß
Jan.Schmidt
Beiträge: 439
Registriert: 08 Jul 2017, 12:02

Re: [SOLVED]Unterschiedliche Produkte in ein Paket

Beitrag von Jan.Schmidt »

Hi,
Mein Ansatz:

Code: Alles auswählen

  set $locale$ = "en-US"
dein Ansatz

Code: Alles auswählen

 Set $Sprache$ = en-US
Du hast die Anführungszeichen weggelassen...
Antworten