CliGenerator throws error when no user preferences were found

Posts   
 
    
Posts: 30
Joined: 19-Dec-2022
# Posted on: 09-Jun-2023 16:55:53   

Hi,

we want to generate the Entities source code via the CliGenerator.exe on our build server. I have the minimum subset of dlls, tasks and templates available at the build agents, but I don't want to install LLBLGen on the agents or put anything in the user's AppData directory. The documentation on the CliGenerator (https://www.llblgen.com/documentation/5.10/Designer/Functionality%20Reference/CliGenerator.htm) says that "The tool will use the preferences set as stored for the executing user, or use the defaults if no preferences are found." In contrast to that an error is thrown when no preferences are found:

 Message: Could not find file 'C:\Users\buildagent\AppData\Roaming\LLBLGen Pro\Preferences510.xml'.
  Source: mscorlib
  Stack trace:
     at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
     at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
     at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
     at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials, IWebProxy proxy, RequestCachePolicy cachePolicy)
     at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
     at System.Xml.XmlTextReaderImpl.OpenUrlDelegate(Object xmlResolver)
     at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
     at System.Threading.CompressedStack.Run(CompressedStack compressedStack, ContextCallback callback, Object state)
     at System.Xml.XmlTextReaderImpl.OpenUrl()
     at System.Xml.XmlTextReaderImpl.Read()
     at SD.LLBLGen.Pro.ApplicationCore.Configuration.UserConfiguration.DeserializeFromReader(XmlReader reader)
     at SD.LLBLGen.Pro.Tools.CommandLineGenerator.Startup.LoadPreferences()
     at SD.LLBLGen.Pro.Tools.CommandLineGenerator.Startup.StartProcess(CommandLineArgs parsedArgs)
     at SD.LLBLGen.Pro.Tools.CommandLineGenerator.Startup.Main(String[] args)

Can you help us with this?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 10-Jun-2023 08:47:55   

Hmm. I see that the method indeed doesn't check if the preference file is there. It's in Startup.cs, line 461 if you want to correct it manually (you can compile the clicodegenerator from source, it's in the sourcecode archive). We'll look into it if it's ok to simply skip the load action or that we have to provide the code generator with meaningful defaults in case the file isn't there.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 12-Jun-2023 09:27:51   

We've updated the method a bit so it returns a new UserPreferences object when no preferences were found, this is now available in 5.9.6 and 5.10.2 hotfixes

Frans Bouma | Lead developer LLBLGen Pro
Posts: 30
Joined: 19-Dec-2022
# Posted on: 12-Jun-2023 09:30:04   

Very nice. Thank you very much!