Qt VS Tools: Error reading VS project settings when trying to create Qt project from template in Visual Studio

112 Views Asked by At

I'm trying to create a standard Qt console app in Visual Studio using the Qt templates as provided by the Qt VS Tools extension. It initially was working fine, however I got some complier errors, and in trying to fix them I've managed to break the entire process.

Every time I try to create a project from any Qt template, I get the error:

QtVSException: Error reading VS project settings

Which has the stack trace:

Stack Trace:
   at QtVsTools.Core.VersionInformation..ctor(String qtDirIn)
   at QtVsTools.Core.VersionInformation.Get(String qtDir)
   at QtVsTools.Core.QtVersionManager.GetVersionInfo(String name)
   at QtVsTools.Wizards.ProjectWizard.ConfigPage..ctor()
   at QtVsTools.Wizards.ProjectWizard.ConsoleWizard.<get_WizardWindow>b__8_1()
   at QtVsTools.Common.LazyFactory.Get[T](Expression`1 propertyRef, Func`1 initFunc)
   at QtVsTools.Wizards.ProjectWizard.ProjectTemplateWizard.RunStarted(Object 
       automationObject, Dictionary`2 parameterValues, WizardRunKind runKind, Object[] 
       customParams)

Above this error is the error:

An exception (ArgumentException) occurred.
Message:
   An item with the same key has already been added.
Stack Trace:
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource 
    resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, 
    TValue value, Boolean add)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement] 
   (IEnumerable`1 source, Func`2 keySelector, Func`2 
    elementSelector, 
    IEqualityComparer`1 comparer)
   at QtVsTools.Core.HelperFunctions.SetVcVars(VersionInformation 
    versionInfo, ProcessStartInfo startInfo)
   at QtVsTools.Core.QMakeImport.QMakeProcess.Run()

I'm using Qt version 5.12.12 and Visual Studio 2022 Version 17.8.4, with Qt VS Tools 2022 Version 3.0.2 (but I've also tried version 3.0.1). When linking Qt VS Tools to Qt, I use the msvc2017_x64 version.

I've freshly reinstalled Visual Studio, Qt, and Qt VS Tools, but I'm still getting the error. I've tried the answers suggested in Qt VS Tools: error reading VS project settings to no avail. Interestingly, when installing Qt VS Tools, it doesn't create the QtMsBuild environment variable, so I've set it myself. I've also set the QTDIR environment variable to my Qt installation directory.

I can successfully create non-Qt projects from templates, so I'm confident it's a Qt issue and not a Visual Studio issue. However, other forums online simply aren't helping.

Below is a screenshot of the Qt version I have linked to Qt VS Tools.

enter image description here

I had initially created a Qt project that still opens fine, it's just when I try to create a new one. I have no idea what I could have done for it to suddenly stop working, so I'd appreciate any support. Thanks.

0

There are 0 best solutions below