Is there a way that I can pass in a variable to change some Final Builder values in the options? For instance, we were looking at running more than one version of NuGet (for our current release and then upgrade to a new version for an upcoming release). I’m restricted to specifying the installation directory of the NuGet.exe file from the FB options page. We could potentially have multiple builds running on the same server, so I would be unable to overwrite the NuGet.exe file in the location specified in the options.
The other field on this particular options page is the API Key. Right now we don’t have more than one key, but we do have more than one NuGet repository. I could potentially see a day where we would want to use different API keys (pushing to a production instance as opposed to a local instance). So for either field I could see a desire to want to update these values on demand. Do I have the capability to do so?
I understand why these should be set up in the options so that the build verification checks can ensure that the destination location exists. However most of our builds are run at command line where we don’t really use the IDE all that much other than setting up the initial script.
Thanks!
Hi Stpitner,
You can achieve this through updating the Option object for nuget with the path during runtime scripts. The code for this in javascript is;
GetOptionsObject(“nuget”).InstallationDirectory = “C:\DirectoryForNuget”
Note that “” needs to be escaped. Also this sets the option value for this installation of FinalBuilder, its not a per-project setting. Therefore it needs to be set back before the script ends otherwise it could affect other scripts. Also its wise to do this in a try…catch…end block to make sure that even if the script stops the value is set back.
To capture and set the value back use the following code;
FBVariables.OldNuGetDir = GetOptionsObject(“nuget”).InstallationDirectory
GetOptionsObject(“nuget”).InstallationDirectory = FBVariables.OldNuGetDir
Lastly the directory has to be valid before it gets to the Validate & Execute of the NuGet action if it isn’t validation will fail or the execution will fail. Therefore this could be done at the latest in the BeforeAction script of the NuGet action. Typically I do this in a Run Script action and name the action to exactly what is occurring for maintenance purposes.
Also the APIKey on the options is as follows;
GetOptionsObject(“nuget”).APIKey = “MyAPIKey”