Visual Studio Add-in: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''English''' [[QtVSAddin Russian|Русский]] [http://qt-devnet.developpez.com/tutoriels/add-in-visual-studio/compiler/ French] ''[qt-devnet.developpez.com]''
'''English''' [[QtVSAddin_Russian|Русский]] "French":http://qt-devnet.developpez.com/tutoriels/add-in-visual-studio/compiler/


=Qt Visual Studio Add-in=
[[Category:Tools]]<br />[toc align_right=&quot;yes&amp;quot; depth=&quot;3&amp;quot;]


==Getting the source==
= Qt Visual Studio Add-in =
 
== Getting the source ==


The source code of the add-in is hosted on gitorious at http://qt.gitorious.org/qt-labs/vstools
The source code of the add-in is hosted on gitorious at http://qt.gitorious.org/qt-labs/vstools
Line 9: Line 11:
To create a repository clone, execute the following command:
To create a repository clone, execute the following command:


==Instructions for Qt 5.x==
<code>git clone git://gitorious.org/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:
As the addin is a Qt app itself, make sure that you have the following software installed:
Line 17: Line 21:
* Qt 5.0+
* Qt 5.0+


<font size="larger">'''''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).'''''</font>
p{font-size:larger}. '''''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===
=== 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.
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:
Execute the following commands:
</code>cd Qt4VS2003<br />createUserFiles.bat<code>


This sets up reference paths and debug settings.
This sets up reference paths and debug settings.


This builds the external <span class="caps">QRC</span> editor which is launched from within Visual Studio.
</code>cd ..qmake<br />nmake<br />cd ..devenv qt5appwrapper2012.sln /useenv /Build release<br />cd ..<br />qmake <s>r<br />nmake<code>
<br />This builds the external QRC editor which is launched from within Visual Studio.
<br />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.
<br />h3. Installation
<br />Open the Qt4VS2003\Qt4VSAddin folder, and copy Qt5VSAddin.AddIn and the Release directory to your VS Addins folder</s> by default this is &quot;&amp;#37;USERPROFILE&amp;amp;#37;Studio 2012\Addins&amp;quot;, but this can be changed under Tools-&gt;Options-&gt;Environment-&gt;Add-in Security. Rename Release to something meaningful (like Qt5VSAddin, since it goes with the addin).


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.
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.


===Installation===
Go back to Visual Studio, and open Tools-&gt;Add-in Manager. Select the addin and restart VS. You should now have a QT5 menu, to the right of VIEW.


Open the Qt4VS2003\Qt4VSAddin folder, and copy Qt5VSAddin.AddIn and the Release directory to your VS Addins folder – by default this is “%<span class="caps">USERPROFILE</span>%\Documents\Visual Studio 2012\Addins”, but this can be changed under Tools-&gt;Options-&gt;Environment-&gt;Add-in Security. Rename Release to something meaningful (like Qt5VSAddin, since it goes with the addin).
=== Configuration ===
 
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-&gt;Add-in Manager. Select the addin and restart VS. You should now have a QT5 menu, to the right of <span class="caps">VIEW</span>.
 
===Configuration===


You should probably configure the addin for your Qt installation. Open QT5-&gt;Qt options, and add any versions of Qt you have installed. The rest of the options should be fine for normal use.
You should probably configure the addin for your Qt installation. Open QT5-&gt;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==
== Build Instructions for Qt 4.x ==


Make sure that you have the following software installed:
Make sure that you have the following software installed:
Line 54: Line 58:


Execute the following commands:
Execute the following commands:
</code>cd Qt4VS2003<br />createUserFiles.cmd<code>


This sets up reference paths and debug settings.
This sets up reference paths and debug settings.


Adjust the number in qtappwrapper2008.sln according to the VS version you’re using.<br /> Duplicates of the addin’s project files exist for every supported Visual Studio version.
</code>cd ComWrappers\qmakewrapper<br />qmake<br />nmake<br />cd ..devenv qtappwrapper2008.sln /useenv /Build release<code>
 
Adjust the number in qtappwrapper2008.sln according to the VS version you’re using.<br />Duplicates of the addin’s project files exist for every supported Visual Studio version.
 
</code>cd ..<br />qmake -r<br />nmake<code>


This builds the external <span class="caps">QRC</span> editor which is launched from within Visual Studio.<br /> Now we’re ready to open the main solution which contains the actual add-in.
This builds the external QRC editor which is launched from within Visual Studio.<br />Now we’re ready to open the main solution which contains the actual add-in.


Now you should be able to build the solution.<br /> Before trying to run your freshly built add-in, read the next section.
</code>start Qt4VS2003\Qt4VSAddin2008.sln</code>


==Running and Debugging==
Now you should be able to build the solution.<br />Before trying to run your freshly built add-in, read the next section.


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


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


Open the directory where your personal Visual Studio settings are stored. This is usually<br /> something like “USERPROFILE\Documents\Visual Studio 2008”.<br /> We’ll just use that directory for illustration. Also, we’ll assume that the<br /> add-in’s repository is located in c:\dev\qtvstools.<br /> Execute the following commands:
=== Install the Add-in’s Description File ===


Qt4VSAddin.AddIn is the add-in’s description file and Visual Studio can now find it.<br /> For other Visual Studio versions than 2008 you must adjust the Version tag in the<br /> Qt4VSAddin.Addin file.
Open the directory where your personal Visual Studio settings are stored. This is usually<br />something like “USERPROFILE\Documents\Visual Studio 2008”.<br />We’ll just use that directory for illustration. Also, we’ll assume that the<br />add-in’s repository is located in c:.<br />Execute the following commands:


Your installed release version of the add-in is now turned off and cannot be loaded into<br /> Visual Studio anymore. To restore the old state, rename the file extension of Qt4VSAddin.AddIn<br /> to some bogus value like Qt4VSAddin.AddIn.foo. This ensures that it will be ignored by Visual<br /> Studio and the original add-in will be loaded.
<code>cd &quot;USERPROFILEStudio 2008&amp;quot;<br />md Addins<br />cd Addins<br />copy c:4VS2003\Qt4VSAddin\Qt4VSAddin.AddIn</code> .


===Run the Add-in’s Development Version===
Qt4VSAddin.AddIn is the add-in’s description file and Visual Studio can now find it.<br />For other Visual Studio versions than 2008 you must adjust the Version tag in the<br />Qt4VSAddin.Addin file.


Now that the .Addin file is in place, we’re ready to try out the development version of the<br /> add-in. Open the solution file (e.g. Qt4VSAddin2008.sln) and press F5.
Your installed release version of the add-in is now turned off and cannot be loaded into<br />Visual Studio anymore. To restore the old state, rename the file extension of Qt4VSAddin.AddIn<br />to some bogus value like Qt4VSAddin.AddIn.foo. This ensures that it will be ignored by Visual<br />Studio and the original add-in will be loaded.


Another instance of Visual Studio is started. We will call this instance VS2 and the Visual<br /> Studio Instance where the add-in’s solution is loaded VS1.
=== Run the Add-in’s Development Version ===


The add-in is not yet loaded in VS2. To load it, select “Tools/Add-in Manager…” click the<br /> first checkbox in the “Qt4 Add-in Development Version” line and press OK.<br /> Now you should have a “Qt” menu entry in the menubar of Visual Studio which means that the<br /> add-in has been successfully loaded.
Now that the .Addin file is in place, we’re ready to try out the development version of the<br />add-in. Open the solution file &amp;#40;e.g. Qt4VSAddin2008.sln&amp;amp;#41; and press F5.


In VS1 you can set breakpoints and do all the debugging you need. In VS2 you’re controlling<br /> the add-in.
Another instance of Visual Studio is started. We will call this instance VS2 and the Visual<br />Studio Instance where the add-in’s solution is loaded VS1.


===Categories:===
The add-in is not yet loaded in VS2. To load it, select “Tools/Add-in Manager…” click the<br />first checkbox in the “Qt4 Add-in Development Version” line and press OK.<br />Now you should have a “Qt” menu entry in the menubar of Visual Studio which means that the<br />add-in has been successfully loaded.


* [[:Category:Tools|Tools]]
In VS1 you can set breakpoints and do all the debugging you need. In VS2 you’re controlling

Revision as of 14:10, 23 February 2015

English Русский "French&quot;:http://qt-devnet.developpez.com/tutoriels/add-in-visual-studio/compiler/
[toc align_right="yes&quot; depth="3&quot;]

Qt Visual Studio Add-in

Getting the source

The source code of the add-in is hosted on gitorious at http://qt.gitorious.org/qt-labs/vstools

To create a repository clone, execute the following command:

git clone git://gitorious.org/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+

p{font-size:larger}. '''''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:

cd Qt4VS2003
createUserFiles.bat

This sets up reference paths and debug settings.

cd ..qmake
nmake
cd ..devenv qt5appwrapper2012.sln /useenv /Build release
cd ..
qmake r
nmake

<br />This builds the external QRC editor which is launched from within Visual Studio.
<br />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.
<br />h3. Installation
<br />Open the Qt4VS2003\Qt4VSAddin folder, and copy Qt5VSAddin.AddIn and the Release directory to your VS Addins folder</s> by default this is &quot;&amp;#37;USERPROFILE&amp;amp;#37;Studio 2012\Addins&amp;quot;, but this can be changed under Tools-&gt;Options-&gt;Environment-&gt;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-&gt;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-&gt;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:

cd Qt4VS2003
createUserFiles.cmd

This sets up reference paths and debug settings.

cd ComWrappers\qmakewrapper
qmake
nmake
cd ..devenv qtappwrapper2008.sln /useenv /Build release

Adjust the number in qtappwrapper2008.sln according to the VS version youre using.<br />Duplicates of the addins project files exist for every supported Visual Studio version.

cd ..
qmake -r
nmake

This builds the external QRC editor which is launched from within Visual Studio.<br />Now were ready to open the main solution which contains the actual add-in.

start Qt4VS2003\Qt4VSAddin2008.sln

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

Running and Debugging

To run and debug the development version of the Qt Visual Studio Add-in we need to do a little
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

Open the directory where your personal Visual Studio settings are stored. This is usually
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:

cd &quot;USERPROFILEStudio 2008&amp;quot;<br />md Addins<br />cd Addins<br />copy c:4VS2003\Qt4VSAddin\Qt4VSAddin.AddIn

.

Qt4VSAddin.AddIn is the add-in’s description file and Visual Studio can now find it.
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
Visual Studio anymore. To restore the old state, rename the file extension of Qt4VSAddin.AddIn
to some bogus value like Qt4VSAddin.AddIn.foo. This ensures that it will be ignored by Visual
Studio and the original add-in will be loaded.

Run the Add-in’s Development Version

Now that the .Addin file is in place, we’re ready to try out the development version of the
add-in. Open the solution file &#40;e.g. Qt4VSAddin2008.sln&amp;#41; and press F5.

Another instance of Visual Studio is started. We will call this instance VS2 and the Visual
Studio Instance where the add-in’s solution is loaded VS1.

The add-in is not yet loaded in VS2. To load it, select “Tools/Add-in Manager…” click the
first checkbox in the “Qt4 Add-in Development Version” line and press OK.
Now you should have a “Qt” menu entry in the menubar of Visual Studio which means that the
add-in has been successfully loaded.

In VS1 you can set breakpoints and do all the debugging you need. In VS2 you’re controlling