Visual Studio Add-in: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
(14 intermediate revisions by 6 users not shown)
Line 1: Line 1:
 
{{LangSwitch}}
'''English''' [[QtVSAddin_Russian|Русский]] [http://qt-devnet.developpez.com/tutoriels/add-in-visual-studio/compiler/ French]
 
[[Category:Tools]]
[[Category:Tools]]


'''French translators see also:''' http://qt-devnet.developpez.com/tutoriels/add-in-visual-studio/compiler/


= Qt Visual Studio Add-in =
= Qt Visual Studio Tools =


== Getting the source ==
=== Get the sources ===


The source code of the add-in is hosted on gitorious at http://qt.gitorious.org/qt-labs/vstools
Use Git to check out the Qt Visual Studio Tools sources that are hosted at: http://code.qt.io/cgit/qt-labs/vstools.git


To create a repository clone, execute the following command:
To create a repository clone, execute the following command:


<code>git clone git://code.qt.io/qt-labs/vstools.git</code>
<code lang="bash">git clone git://code.qt.io/qt-labs/vstools.git</code>
 
== Instructions for Qt 5.x ==
 
As the addin is a Qt app itself, make sure that you have the following software installed:
 
* Visual Studio 2008+
* Perl
* Qt 5.0+
 
'''''These instructions refer to Visual Studio 2012. Replace any references to VS2012 with the appropriate file for your VS version (2008, 2010 and 2012 supported).'''''
 
=== Building the addin ===
 
Open a command shell with a Qt build environment (Visual Studio built-in prompt configured with Qt in appropriate environment variables, 32 or 64-bit) and cd into your add-in source directory.
 
Execute the following commands:
 
<code>cd Qt4VS2003
createUserFiles.bat</code>
 
This sets up reference paths and debug settings.
 
<code>cd ..qmake
nmake
cd ..devenv qt5appwrapper2012.sln /useenv /Build release
cd ..
qmake -r
nmake</code>
 
This builds the external QRC editor which is launched from within Visual Studio.
 
At this point, the addin can be built. Open Qt4VS2003\Qt5VSAddin2012.sln as an administrator (the build will fail if you don't), and build the entire solution.
 
=== Installation ===
 
Open the Qt4VS2003\Qt4VSAddin folder, and copy Qt5VSAddin.AddIn and the Release directory to your VS Addins folder- by default this is "%USERPROFILE%\Documents\Visual Studio 2012\Addins", but this can be changed under Tools->Options->Environment->Add-in Security. Rename Release to something meaningful (like Qt5VSAddin, since it goes with the addin).
 
Open Qt5VSAddin.AddIn in your favorite text editor, and find the Version tag. Change it to the version appropriate for your VS version - 2008 is 9.0, 2010 is 10.0, and 2012 is 11.0. Find the Assembly tag and change it to reflect the location of the Qt5VSAddin.dll file within the binary folder, i.e. Qt5VSAddin\Qt5VSAddin.dll.
 
Go back to Visual Studio, and open Tools->Add-in Manager. Select the addin and restart VS. You should now have a QT5 menu, to the right of VIEW.
 
=== Configuration ===
 
You should probably configure the addin for your Qt installation. Open QT5->Qt options, and add any versions of Qt you have installed. The rest of the options should be fine for normal use.
 
== Build Instructions for Qt 4.x ==
 
Make sure that you have the following software installed:
 
* Visual Studio 2005 or above
* Perl
* Qt 4.7.0 or newer
 
Open a command shell with a Qt build environment (Visual Studio build, 32 bit) and cd into your add-in source directory.
 
Execute the following commands:
 
<code>cd Qt4VS2003
createUserFiles.cmd</code>
 
This sets up reference paths and debug settings.
 
<code>cd ComWrappers\qmakewrapper
qmake
nmake
cd ..devenv qtappwrapper2008.sln /useenv /Build release</code>
 
Adjust the number in qtappwrapper2008.sln according to the VS version you’re using.
Duplicates of the addin’s project files exist for every supported Visual Studio version.
 
<code>cd ..
qmake -r
nmake</code>
 
This builds the external QRC editor which is launched from within Visual Studio.
Now we’re ready to open the main solution which contains the actual add-in.
 
<code>start Qt4VS2003\Qt4VSAddin2008.sln</code>


Now you should be able to build the solution.
=== Build a static Qt ===
Before trying to run your freshly built add-in, read the next section.


== Running and Debugging ==
Building the Qt Visual Studio Tools from sources requires a static build of Qt (version 5.6.0 or newer).Supported
compilers are MSVC 2013 or newer, GCC 4.7 or newer, and Clang 3.1 or newer. See the Qt documentation
for the prerequisites and steps to build Qt from sources. https://wiki.qt.io/Building_Qt_5_from_Git#Windows<br /><br />
'''''Recommended configuration options:''''' configure -prefix %CD%\qtbase -release -static -static-runtime -opensource -nomake examples -nomake tests<br />
'''''Recommended (n)make options:''''' (n)make module-qtbase


To run and debug the development version of the Qt Visual Studio Add-in we need to do a little
=== Build the Qt Visual Studio Tools ===
setup work once again. Note that you can have the Add-in’s release version installed.
You can switch between these two installations as you will see soon.


=== Install the Add-in’s Description File ===
Change the directory into 'src' and run 'qmake && make' (or 'mingw32-make', 'nmake' ...) to build
the Qt Visual Studio Tools command line applications. Once finished, open the solution QtVsTools.sln
in Visual Studio and build the solution.


Open the directory where your personal Visual Studio settings are stored. This is usually
=== Build the Qt Visual Studio Tools documentation ===
something like “USERPROFILE\Documents\Visual Studio 2008”.
We’ll just use that directory for illustration. Also, we’ll assume that the
add-in’s repository is located in c:.
Execute the following commands:


<code>cd "USERPROFILEStudio 2008"
Run 'qmake && make docs' (or 'mingw32-make docs', 'nmake docs' ...) from the root directory to
md Addins
build the Qt Visual Studio Tools documentation. You need to have 'qdoc' and friends built already.
cd Addins
See the Qt documentation for the prerequisites and steps to build Qt documentation from sources.
copy c:4VS2003\Qt4VSAddin\Qt4VSAddin.AddIn</code> .
https://wiki.qt.io/Building_Qt_Documentation


Qt4VSAddin.AddIn is the add-in’s description file and Visual Studio can now find it.
=== How to debug the Qt Visual Studio Tools ===
For other Visual Studio versions than 2008 you must adjust the Version tag in the
Qt4VSAddin.Addin file.


Your installed release version of the add-in is now turned off and cannot be loaded into
To debug the resulting VSIX, select the 'QtVsTools' node, right click and choose 'Properties|Debug'.
Visual Studio anymore. To restore the old state, rename the file extension of Qt4VSAddin.AddIn
Update 'Start Action|Start external program:' to point to your Visual Studio 'devenv.exe' application.
to some bogus value like Qt4VSAddin.AddIn.foo. This ensures that it will be ignored by Visual
Update 'Start Options|Command line arguments:' with '/rootSuffix Exp'. Note: The implemented post
Studio and the original add-in will be loaded.
build targets will only work reliable if you use the 'Exp' hive of Visual Studio.


=== Run the Add-in’s Development Version ===
=== How to locally test the Qt Visual Studio Tools update ===


Now that the .Addin file is in place, we’re ready to try out the development version of the
Inside the src\config directory, edit the qt.io.xml file and modify the following tags:
add-in. Open the solution file (e.g. Qt4VSAddin2008.sln) and press F5.


Another instance of Visual Studio is started. We will call this instance VS2 and the Visual
    <updated>2016-11-11T10:51:55Z</updated>  Use the current date and time, keep the 'T' and 'Z'
Studio Instance where the add-in’s solution is loaded VS1.
    <id>{ Product ID }</id>                  Set to the Product ID that can be found in the 'source.extension.vsixmanifest' file,
                                              for example: <id>QtVsTools.30112013-cd02-4fd0-89bd-e36f85abe16a</id>
    <Version>{ Version }</Version>            Set to the Version that can be found in the 'source.extension.vsixmanifest' file,
                                              for example: <Version>2.0.0</Version>


The add-in is not yet loaded in VS2. To load it, select “Tools/Add-in Manager…” click the
Copy the XML file and the VSIX package inside a new folder side by side and open the
first checkbox in the “Qt4 Add-in Development Version” line and press OK.
'Tools | Options | Extensions and Updates' settings dialog in Visual Studio. Add a new entry in the
Now you should have a “Qt” menu entry in the menubar of Visual Studio which means that the
Additional Extension Gallery, like this:
add-in has been successfully loaded.


In VS1 you can set breakpoints and do all the debugging you need. In VS2 you’re controlling the add-in.
    Name: qt.io
    Url: file://path/to/your/atom.xml

Revision as of 10:33, 20 December 2016

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

French translators see also: http://qt-devnet.developpez.com/tutoriels/add-in-visual-studio/compiler/

Qt Visual Studio Tools

Get the sources

Use Git to check out the Qt Visual Studio Tools sources that are hosted at: http://code.qt.io/cgit/qt-labs/vstools.git

To create a repository clone, execute the following command:

git clone git://code.qt.io/qt-labs/vstools.git

Build a static Qt

Building the Qt Visual Studio Tools from sources requires a static build of Qt (version 5.6.0 or newer).Supported compilers are MSVC 2013 or newer, GCC 4.7 or newer, and Clang 3.1 or newer. See the Qt documentation for the prerequisites and steps to build Qt from sources. https://wiki.qt.io/Building_Qt_5_from_Git#Windows

Recommended configuration options: configure -prefix %CD%\qtbase -release -static -static-runtime -opensource -nomake examples -nomake tests
Recommended (n)make options: (n)make module-qtbase

Build the Qt Visual Studio Tools

Change the directory into 'src' and run 'qmake && make' (or 'mingw32-make', 'nmake' ...) to build the Qt Visual Studio Tools command line applications. Once finished, open the solution QtVsTools.sln in Visual Studio and build the solution.

Build the Qt Visual Studio Tools documentation

Run 'qmake && make docs' (or 'mingw32-make docs', 'nmake docs' ...) from the root directory to build the Qt Visual Studio Tools documentation. You need to have 'qdoc' and friends built already. See the Qt documentation for the prerequisites and steps to build Qt documentation from sources. https://wiki.qt.io/Building_Qt_Documentation

How to debug the Qt Visual Studio Tools

To debug the resulting VSIX, select the 'QtVsTools' node, right click and choose 'Properties|Debug'. Update 'Start Action|Start external program:' to point to your Visual Studio 'devenv.exe' application. Update 'Start Options|Command line arguments:' with '/rootSuffix Exp'. Note: The implemented post build targets will only work reliable if you use the 'Exp' hive of Visual Studio.

How to locally test the Qt Visual Studio Tools update

Inside the src\config directory, edit the qt.io.xml file and modify the following tags:

   <updated>2016-11-11T10:51:55Z</updated>   Use the current date and time, keep the 'T' and 'Z'
   <id>{ Product ID }</id>                   Set to the Product ID that can be found in the 'source.extension.vsixmanifest' file,
                                             for example: <id>QtVsTools.30112013-cd02-4fd0-89bd-e36f85abe16a</id>
   <Version>{ Version }</Version>            Set to the Version that can be found in the 'source.extension.vsixmanifest' file,
                                             for example: <Version>2.0.0</Version>

Copy the XML file and the VSIX package inside a new folder side by side and open the 'Tools | Options | Extensions and Updates' settings dialog in Visual Studio. Add a new entry in the Additional Extension Gallery, like this:

   Name: qt.io
   Url: file://path/to/your/atom.xml