Copy Files to Project Folder with Visual Studio Project Template - visual-studio

I'm making a custom Visual Studio Project Template for a CSharp project and was wondering if there was a way to copy a dll from the template zip file to the new project file without including the dll in the project files?
The idea is that the project references the dll, but I just dont want the developers to care about the assembly.

What I did was, created new template wizard i.e. by implementing IWizard interface.
This article(http://msdn.microsoft.com/en-us/magazine/cc188697.aspx) will help you to get started with custom wizard.
Then in the RunStarted() method you will be able to get path to the current template like this
Path.GetDirectoryName((string)customParams[0])
Also you can get the path where the project is created using below code
replacementsDictionary["$destinationdirectory$"]
Once you have these values, do a normal file copy on the RunFinished() method

Related

Visual Studio 2012 - How to assign multiple build actions to a TypeScript file

I am using Visual Studio 2012 to create a class library project that will also include a number of TypeScript (.ts) files, as well as their generated .js and .js.map files. All of these files need to be included in the assembly as embedded resources, so that they can be exposed to a consuming ASP.NET MVC application via a custom VirtualPathProvider.
Note: although only the generated JavaScript files are essential for the production environment, the .ts and .js.map files must also be accessible to the web application, for debugging.
This presents a conflict, since TypeScript files are usually assigned the TypeScriptCompile build action but I also need them to be assigned EmbeddedResource.
Is there any way to assign multiple build actions to a VisualStudio project component? Alternatively, is there another way to get TypeScript to compile files that are not explicitly marked as TypeScriptCompile or to get Visual Studio to embed files that are not marked as EmbeddedResource?
Thanks for your suggestions,
Tim
If you had a TypeScript file that referenced all of the others, only it would need to have the TypeScriptCompile type as the compiler should walk all the dependencies and compile all the rest too.
So creating a file that acts as the compilation target and that references all of your other files might allow you to change all the rest to EmbeddedResource.

Using a DLL I've created in another VS2010 project doesn't show the intellisense tooltips

I've created a DLL to a project in Visual Studio 2010.
I'm using this DLL in another project. Using the functions is completely possible - but I can't see any tooltip.
In addition - if I'm in the same project the tooltips can be seen.
I've read some issues about using the XML file with the name of the DLL in the 2nd project, but I'm afraid I don't have any XML file (as far as I see...).
I'll appreciate your help!
Lior
In the project settings of your DLL you can specify that a XML file will be created each time the assembly is build. Thi setting is located on the "Build" tab, region "Output" and is called "XML documentation file". Mark the checkbox in front and the xml file will be created.
When you use the dll in another project you have to copy the xml file along with the assembly file to have the IntelliSense information in place.

using Qt designer in visual studio?

I'm using visual studio 2010, Qt add-in etc all ok, then create new project using Qt add-in... when doubleclicking *.ui (the actual form) file in VS it opens Qtdesigner, then I put some controls on, but that does not change my code at all :/
Qt form is changed it contains those controls but source files are the same as before even after building my project.
I'm I missing something?
I think Qtdesinger shoult put some code for objects which I created using Qtdesigner.
cos without that we must write all the code as if there were no Qtdesigner so Qtdesinger is useles in Visual studio, the same thing we could just do by hand-coding a form interface.
thanks alot.
EDIT:
OK
I've copied this from Qt site:
You are referencing objects from a .ui file...
The Visual Studio code model parser only parses C++ sources, meaning
that widgets or objects defined in .ui files will not be accessible.
To workaround the problem, the Qt Visual Studio Add-in automatically
generates C++ code from the .ui file by saving the file and running
uic on it. This step is done everytime the project is built. If the
code completion does not work, try to rebuild the project. It is
possible that you have to wait some time, before code completion fully
works after updating an .ui file. For more information, you can refer
to the Modifying Project Properties section. It still does not work...
You should refresh the code model, Intellisense. This is done by
opening the solution explorer, invoking the context menu of the
project and activating the item Update Intellisense.
now it looks that I'm having such problems but this does not help at all, update intelisece. I can't see such option in visual studio,
it looks my visual studio add-in isn't working.
it says "You should refresh the code model" Woot? can someone explain me how to do that please.
here are some output warnings when building my project:
Warning 1 warning : No resources in 'C:\Users\Admin\documents\visual
studio
2010\Projects\VisualStudio\test\test.qrc'. C:\Users\Admin\documents\visual
studio 2010\Projects\VisualStudio\test\RCC Warning 2 warning LNK4099:
PDB 'vc100.pdb' was not found with 'qtmaind.lib(qtmain_win.obj)' or at
'C:\Users\Admin\documents\visual studio
2010\Projects\VisualStudio\vc100.pdb'; linking object as if no debug
info C:\Users\Admin\documents\visual studio
2010\Projects\VisualStudio\test\qtmaind.lib(qtmain_win.obj)
I'm going to explain a little bit how things work and the relationships between the files, and hopefully this will solve your problem.
When you edit the ui file using the designer all changes are made to the ui file itself. Then when you build a couple of things will happen.
First... a custom build step will be run on the ui file. This build step runs "uic" as Macke said, and will generate a file called "ui_thenameofyouruifile.h". Where this file is located depends on your project settings, but if you look in your project you should see a folder called Generated Files in your project.
If you look in there you should see the newly generated file. This is the code that is "changed" when you make changes to your form. Now if this file is not updated, or does not exist at all, then somehow your project settings got messed up. In this case I would remove your .ui file from the project and re-add it. The add-in should do it's magic and add all the stuff you need. Build again and it should work. (I assume that is probably your problem)
The second thing that should happen when you build, is that the class that uses your ui file should recompile. Generally when you create a ui file, you also create an accompanying .h and .cpp file. This is where we do any of the fun logic that we might need in our window. The Qt designer will never ever change this class.
In the header file we refer to the ui file by doing this:
namespace Ui {
class thenameofyouruifile;
}
#include "ui_thenameofyouruifile.h"
and then we add a member variable
Ui::thenameofyouruifile UI;
There are a couple of ways to do this, but basically that's the idea. The add-in is supposed to configure your project so that the directory where the generate files go is included in the "additional include directories" in your project settings, but that is another place to check to make sure that your code is really linking with the correct generated file.
If Qt Add-In installed properly, it should generate the custom build step for Qt related files (.ui or moc file). I have not tried Qt Add-in with VS 2010, but with VS 2008 it's okay.
The work-around for your problem, you need to add manually the custom build step for each ui file you have in the project. To do this, the step is:
Right clicked the ui file, and click the properties (I'm using VS-2008 to do this step, and expect this may not be much different in VS 2010).
Under custom build step, add this in the command line: "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_$(InputName).h" "$(InputPath)"
And add this under output: ".\GeneratedFiles\ui_$(InputName).h"
And this under additional dependencies: $(QTDIR)\bin\uic.exe. Then click apply / ok.
If this is done, the ui file is compilable, (when you right click it, it can be compiled), so when the ui file content change, the new ui code (.h) file is regenerated.
Alternatively, to reset the VS project file (vcprojx) you can create Qt project in Qt creator, (or if you have already one), and then convert the Qt creator project (.pro) into vcproj using this command line:
qmake -spec win32-msvc2010 -tp vc
This will create the vcproj with the proper custom build step for you (in case you have many ui files, then you don't need to do the first approach).
If you've created a Qt widget using the new class wizard, stuff should work as expected.
I.e. your .ui files are compiled by Qt's uic to .cpp files, i.e. you need to build your project to get these changes into the ui-class.
So, the .ui files should be added to the project, and have some special build rules that invoke 'uic' on them. If that's not the case, try and re-add them to your project (that way, the Qt add-in should configure the build rules)
Normally, you have a class that inherits QWidget which then includes the compiled cpp-class, by one way or another, usually as a member variable (but inheritance is an option too).
Adding an .ui-file straight up should work too (if you're in a Qt project, which you are..), but obviously something is wrong.
Does the example projects work as expected?

Deploy assembly containing IWizard for project template with VSIX

I have created an extension for VS 2010 that deploys a project template. The project template uses a custom wizard (in a specific assembly) that is called when I create a new project based on this template.
I want to package the assembly containing the wizard within the VSIX, so that it gets deployed somewhere the template can find it (I know GAC is not an option with VSIX).
Basically if I deploy the assembly to the GAC, install the VSIX and then create the project the wizard is invoked successfully.
If I do the same without deploying the assembly first, the project templates does not find the assembly when I create the project.
My question is: how to deploy a project template and the assembly it needs using a VSIX package?
Thank you for your help
EDIT: I changed the VSIX Sub Path of the wizard assembly reference to "ProjectTemplates" in both the installer project and updated the vsixmanifest content assembly reference accordingly. It seems to work now.
You don't need to get your assembly containing the IWizard implementation in the GAC. You can simply declare it in your extension.vsixmanifest file as an Assembly element in the Content section.
Unfortunately, this doesn't appear to be documented well anywhere.
The only tricky part is making sure that the AssemblyName attribute has the correct value.
I had no luck with the Assembly element technique to work, so in case anyone else runs into the same problem, here's another solution.
Visual Studio looks for wizard DLLs using the BindingPaths registry key. If you add the folder containing your DLL in a subkey of BindingPaths, then Visual Studio will find your DLL.
To do this from a VSIX, create a .pkgdef file in your VSIX project. Set its Include in VSIX property to True, and paste the following text into it:
[$RootKey$\BindingPaths\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}]
"$PackageFolder$"=""
(where the Xs represent the package GUID, though I suspect any GUID will do).
This works for me:
[$RootKey$\BindingPaths\{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}]
"$PackageFolder$"=""
But assembly element doesn't work.

VS.net 2010 Template and references

What is the best way to reference DLL (without copying localy into the projet) when creating a project from a "Template" project in VS.net 2010? Because, as known, project template can only make a template for a Project, not solution.
UPDATE
My question were not clear :
I want to know how to a project, lets say "Project1", that has few libraries with property "Copy Local" set to false in ASP.net and then use this project as "Template". Referencing DLL in the "project2", the one who use the "project1" as template, is not done properly without bringing each DLL into the project2 directory and recreate the same directory listning as project1. Is there a way to make a template do it all for ya?
A reference DLL won't get copied if it is registered in the GAC. Trying to avoid the copy for non-GAC-ed assemblies is possible, set the Copy Local property to False. It is however pretty unusual to do so, you can't debug the code because the CLR cannot find the required assembly at run time. Not being able to debug code is, well, a problem.

Resources