How to "force the WiX .exes to run out-of-process" - visual-studio

There is a bug in the WiX plugin for Visual Studio where file locks on referenced DLLs are not properly released. Therefore, you have to restart Visual Studio every time you want to recompile a custom extension DLL or any assembly referenced by it.
This is a known bug, but the issue was closed because there seems to be a solution / workaround:
You can force the WiX .exes to run out-of-process to avoid the lock
MSBuild has.
I don't understand how to achieve this. I checked...
the properties of my WiX setup project
the properties of the extension assembly (C# class library)
all Visual Studio settings
the available command line arguments of candle.exe
...but did not find anything. What am I missing? How do I apply this workaround?
I'm using WiX 3.10 and Visual Studio 2013.

The example that I've seen several times around the web is to add <RunWixToolsOutOfProc>true</RunWixToolsOutOfProc> to the Wix Installer's project file within a property group. Unfortunately, documentation of this feature has thus far eluded me.

Related

Unity keeps removing log4net from my Visual Studio project

I tried to install log4net for use in my Unity project with the following command :
Install-Package Unity.log4net
However, when I go back to the editor, then back to Visual Studio again, the log4net reference is removed, just like the Unity Editor had regenerated the project or something like that. The log4net reference no longer appears in the reference list and thus the log4net namespace can no longer be found.
I'm using Visual Studio 2017 Community Edition.
Has anyone experienced that and found a solution ? Thanks !
It seems like one cannot freely add references to a Unity project since Unity has to know about them. DLLs should be placed in a folder of the project called Plugins and then it works.
However it's weird that people are telling to use nuget packages. I'm assuming that must work somehow, but I don't know how. The solution above is dirty, but at least it works.
Unity projects require a special process to add NuGet packages. This is because when you open a project in Unity, its Visual Studio project files are regenerated, undoing necessary configurations. To add a package from NuGet to your Unity project you can check this doc from Microsoft: https://learn.microsoft.com/zh-cn/visualstudio/cross-platform/unity-scripting-upgrade?view=vs-2019

Visual Studio 2010 , QT and intellisense/highlight error

Hi have a problem with VisualStudio 2010 and the QT5 plugin, it seems that VisualStudio doesnt recognize the QT Library (despite i have installed the plugin and followed the whole procedure).
This is what I see:
https://www.dropbox.com/s/yyzvfev0zoj8x9n/visualstrudel.jpg
So the IDE highlights the QT stuff like if the files were not present, and Intellisense is not working. But, If I compile the application, it compiles without error and works like a charm.
What could be the cause of the highlight/Intellisense issue?
You cannot launch Visual Studio 2010 directly.
You will need to launch the QT 5.0.1 for Desktop(MSVC 2010) command line from Program Files->Qt 5.0.1->5.0.1
After which you will need to run the vcvarsall.bat and devenv after.
x:\program files(x86)\Microsoft Visual Studio 10.0.\VC\vcvarsall.bat
x:\program files(x86)\Microsoft Visual Studio 10.0.\Common7\IDE\devenv.exe
This is applicable to VS2012 and Qt4.5.0, though I believe Qt version does not matter.
I am not sure if it is the same/similar to VS2010, but I stumbled upon this post while looking the answer to the same question for VS2012.
Here is what you can do:
Right-click the project in your solution and select Properties.
Select Configuration Properties -> VC++ Directories.
Edit Include Directories entry.
Add $(QTDIR)\include\QtCore and any other (required by your project) Qt folders to the list (it depends what Qt headers you are using).
This has to be done to every project in your solution that uses Qt, unfortunately.
Now, there is another note:
We were transferring our solution from VS2005 to VS2012 and that problem happened to me when I converted the solution 2005->2012 BEFORE setting the QTDIR environment variable.
When I re-converted the solution again (AFTER *QTDIR* variable was created) the problem didn't appear. So make sure you have this variable before you open/convert your solution for the first time.
Based on the previous note, I believe that some information related to the issue is stored in one of the following files: .sdf and/or .v11.suo.
So closing VS, deleting these files and opening VS again might help. Just back them up before you do it - I haven't tried it myself (I just re-imported the whole solution which generated these files anew).

Removing all unused references from a project in Visual Studio projects

I just wondered if it possible within various Visual Studio versions to automatically remove all references from a project that were never been used?
In your answer, please specify which version of VS the solution applies to.
If you have Resharper (plugin) installed, you can access a feature that allows you to analyze used references via Solution Explorer > (right click) References > Optimize References...
http://www.jetbrains.com/resharper/webhelp/Refactorings__Remove_Unused_References.html
This feature does not correctly handle:
Dependency injected assemblies
Dynamically loaded assemblies (Assembly.LoadFile)
Native code assemblies loaded through interop
ActiveX controls (COM interop)
Other creative ways of loading assemblies
All you need is stone and bare knuckle then you can do it like a caveman.
Remove unused namespaces (for each class)
Run Debug build
Copy your executable and remaining namespace references to new location
Run the executable
Missing Reference DLL error will occur
Copy required DLL from Debug folder
Repeat 4-6
Gu Gu Ga Ga?
Throw your stone
You can also rely on your build tools to let you know which reference is still required. It's the era of VS 2017, caveman still survived.
The Resharper extension will do this for you.
This extension supports Visual Studio 2005 through 2017.
While the compiler won't include unused assemblies, extraneous using statements and references slows down Visual Studio and Intellisense, since there's more code the tools have to consider.
You can try the free VS2010 extension: Reference Assistant by Lardite group. It works perfectly for me. This tool helps to find unused references and allows you to choose which references should be removed.
In a Visual Basic project there is support to remove "Unused References" (Project-->References-->Unused References). In C# there isn´t such a function.
The only way to do it in a C# project (without other tools) is to remove possible unused assemblies, compile the project and verify if any errors occur during compilation. If none errors occur you have removed a unused assembly. (See my post)
If you want to know which project (assembly) depends on other assemblies you can use NDepend.
With Visual Studio versions 2017 and 2015, you can do this with the Code Map feature, but this feature is only available in the Enterprise Edition, not the Community or Professional versions.
Right-click on the project node in the solution explorer and select 'Show on Code Map.' This will display your .dll as a single node in a blank graph. Right-click on that node in the Code Map and select "Show Assemblies This References." This will add an additional node called "Externals" which can be expanded to show only the assemblies that are actually referenced.
For Visual Studio 2013/2015/2017 there is an extension that does exactly what you want: ResolveUR. What this basically does is:
reference is removed in the project
project is compiled with msbuild
check for build errors
restore removed references if there were build errors.
For anybody coming here looking for Visual studio 2012:
Download and Install Reference Assistant for Visual Studio 11
Later you can do:
In Visual Studio 2013 this extension works:
ResolveUR
Some people suggested to use an awesome tool - Reference Assistant for Visual Studio. The problem is that VS2012 is the latest supported Visual Studio. But there is the way to make it work in VS2013 as well ;)
And here is how:
1) Download Lardite.RefAssistant.11.0.vsix
2) Change the extension to zip: Lardite.RefAssistant.11.0.vsix -> Lardite.RefAssistant.11.0.zip
3) Unzip and open the extension.vsixmanifest file in the text editor
4) Find all occurences of InstallationTarget Version="[11.0,12.0)" and replace them with InstallationTarget Version="[11.0,12.0]" (note the closing bracket)
5) Save the file and zip all files so they are on the root zip level
6) Change the extension of the new zip to vsix
7) Install and enjoy :)
I've tested it with VS2013, thanks source for the tutorial
EDIT
Add to support VS 2015 Community Edition
<InstallationTarget Version="[14.0,15.0]" Id="Microsoft.VisualStudio.Community" />
Meaning of the brackets
[ – minimum version inclusive.
] – maximum version inclusive.
( – minimum version exclusive.
) – maximum version exclusive.
[Update] This feature is only available for .Net core projects.
This feature will be coming to Visual Studio 2019 very soon and already available with Visual Studio 2019 v16.10 Preview 1.
This option is turned off by default, but you can enable it under menu Tools > Options > Text Editor > C# > Advanced. Select the Remove Unused References command in Solution Explorer (Experimental). Once the option is enabled, the Remove Unused References command will appear in the right-click menu of a project name or dependencies node.
You can use Reference Assistant extension from the Visual Studio extension gallery.
Used and works for Visual Studio 2010.
In the VS2022 (preview at the moment of writing) this comes out of the box for SDK Style Projects (read: .NET Core and newer).
If it is available you can find it in the project context menu:
You get to choose what to do with each finding.
Read more about it here.
Pro-tip: Check if your project compiles and runs correctly after applying this. In my experience it doesn't check whether a dependency is used at runtime, for instance.
Using DevExpress, I follow these instructions:
In VS, go to DevExpress - Editor - Code Cleanup. Under Rules, check 'Remove unused namespace references'. Click OK.
Right-click on the solution, and choose 'Code Cleanup'. The cleanup runs for a few minutes, and finishes.
Build your application
The following method does not depend on any 'add-on's and is not very painful.
Step through each of your source files and
Select all (Ctrl-A)
Toggle outline expansion (Ctrl-M, M). This will reduce the file to two lines.
Click on the namespace's '+'. This will show each of the file's classes as a single line. Scan each class's reference count, looking for unreferenced classes.
Click on each of the classes' '+'. This will show each of the class functions as a single line. Scan each function's reference count, looking for unreferenced functions.
Scanning each file looking for '0 reference' takes only a second.
Scanning an entire project takes only a couple of minutes.
In VB2008, it works this way:
Project>Add References
Then click on the Recent tab where you can see list of references used recently. Locate the one you do not want and delet it. Then you close without adding anything.

Creating a custom project type for Visual Studio to build Borland C++ Builder projects into Visual Studio

I want to start the develop of a custom project type for Visual Studio that builds a BPR project with Visual Studio.
I need some hints to beginning with this project. Where can I find a template for this type of projects?
My target is to remove the Borland C++Builder's ugly and unstable interface from the development process and work enterely from Visual Studio.
Edit: Oops, I didn't really see that you're about to create a new project type for C++ Builder files. In that case, you have to build a language package. The Visual Studio Extensibility site should get you started. Also have a look at this more specific link.
I'll leave my old answer here for reference, because it might help people who just want to build C++Builder projects without creating a whole new project type :)
You didn't specify the version of Visual Studio, but I'll assume a recent one. In Visual Studio 8 and 9, most project files (all popular ones except Visual C++) are actually MSBuild files and can therefore be built by MSBuild. You can add a simple command line task (Exec) to build your bpr on the command line, or you can create a custom task for this (if you don't find one already available - the search terms should be MSBuild and custom task). This way, both Visual Studio and MSBuild can build anything you like. If you don't have an MSBuild file to start with or want to dive into developing a task, the MSBuild project template for Visual Studio will help you.
Oh, and other than that, if you don't actually need C++Builder things, you might as well export the BPR as a solution (or create a new solution and add the files).
Integrating C++Builder projects into a build process should be a lot easier with C++Builder 2007 or 2009 as both use MSBuild as build system. But then, I think that upgrading to a recent version of C++Builder solves your problem the other way :)

Watch for addition of a referenced library to a project (Visual Studio 2008 plug-in)

I am hoping someone can help me with this. What I have been looking around for but can't seem to find is if there is someway to add an event, or anything else that will allow a visual studio plug-in to watch for an external reference to be added to a currently open solution / project?
Or even better yet would anyone happen to know of an add-in that automatically adds all controls from a referenced dll into the visual studio toolbox?
Thanks.
Not exactly what you asked, but I've written a Visual Studio 2008 Integration Package, and if I recall correctly I could override the "add reference" method, as well as inherit the "reference node" and thus change its behavior, for example its constructor.
This functionality might be missing from an add-in (which is more limited than an integration package), so you might consider writing a package instead.
I have written a macro that will change a file reference to a project reference if you add the project to the solution (and vice versa), but I don't think that's what you want?

Resources