Visual Studio Installer Projects including too many DLLs? - c#

I am attempting to use Visual Studio Installer Projects to make an installer for my app. I am using Visual Studio 2015, and my app is built using WPF and .NET 4.5.
I was following this general tutorial on how to make a Visual Studio Installer Project: https://www.youtube.com/watch?v=z0v6hmumCFU
When I include the "primary output" of each of my projects in the installer, it goes out and identifies the dependencies of these projects and includes them as files that need to be in the installer. I am puzzled, however, because it even seems to be including several standard "system" .NET DLL files, as you can see in this image below:
I tried building it, and then running the installer that it builds, and sure enough it installs all of these "system" DLL files into the install directory.
My understanding is that these DLL files should be on the user's computer already in a standard location once the user has installed .NET 4.5 or later, so my installer shouldn't need to copy over many of these dependencies into the install directory.
So my question is thus:
(1) Why does the Visual Studio Installer Project extension include these dependencies which are obviously part of .NET and should really be located in a standard .NET install location?
(2) Would it be fine to exclude them?
(3) Is there a way to get the VS Installer Project extension to simply not add them?

Related

LibGit2Sharp DllNotFoundException: Unable to load DLL 'git2-106a5f2'

I am working on a vsix project where I need to get information about a local git directory. I am following this article. When I am using LibGit2Sharp library, I am getting an exception as described in following image and error:-
How can I resolve this?
VS version details:
Visual Studio 2019
.Net Framework 4.7.2
LibGit2Sharp is a managed language (.NET) wrapper around a native (C) library, libgit2. It's a P/Invoke layer, plus a layer to give .NET semantics (objects, etc). This means, though, that you require both the LibGit2Sharp.dll (the managed-language side) and the git2-xxxxxxx.dll (the corresponding native library) that it calls into.
The native DLL is part of the LibGit2Sharp.NativeBinaries project that LibGit2Sharp takes a dependency on. It should be installed (transitively) when you install LibGit2Sharp itself. And although it tries to set itself up as a dependency that will be installed in the output directory, since native binaries are not well-understood in the .NET project world, this can sometimes fail, especially for more complex project types like VSIX.
Ultimately, LibGit2Sharp will look for the corresponding native DLL alongside where it's located. So within your output directory, wherever your VSIX is being executed from, try copying the git2-xxxxxxx.dll that is part of the LibGit2Sharp.NativeBinaries project to that location.
Once you've identified the correct location for the git2-xxxxxxx.dll binary to live, you should copy this as part of your installation for the project. (eg Build action: None, Copy to output directory: Copy always)
I had the same issue and I solved it like this:
Copy the dir folder from VisualStudioExtension -> Bin -> Debug -> lib to the root of the VisualStudioExtension project. This folder contains the DLL files required for LibGit2Sharp to work.
Drag the lib folder onto the VisualStudioExtension project in Visual Studio.
Select the dll files, right-click, Properties, and set it to Copy always and include in VSIX.
That worked for me.
LibGit2Sharp has a dependency on the git2-106a5f2.dll which is under [Debug|Release]\lib\win32\[x86|[x64] directory.
If that particular version is missing, you may need to reinstall LibGit2Sharp library, but uninstall LibGit2Sharp.NativeBinaries library between uninstall and install.
The following operations on NuGet packages should help:
Uninstall LibGit2Sharp.
Uninstall LibGit2Sharp.NativeBinaries.
Install LibGit2Sharp.
Note: do not update LibGit2Sharp.NativeBinaries even if there is a newer version.
I got the same issue. It turn out I ignored the dependecies.
Installing its dependency : LibGit2Sharp.NativeBinaries sort out my problem.
For me, I manually installed the Debug and Release VSIX, and tested against regular VS instance and it worked fine. The LibGit2Sharp threw a DllNotFoundException only when debugging my code via the Exp version of Visual Studio 2019.
So I deleted the entire Extensions folder of the Exp verison of Visual Studio. It is the folder where the Exp version of VS installs all Plugins, like other versions of VS:
%AppData%\Local\Microsoft\VisualStudio\16.0_a31c0a3aExp\Extensions
The next time I debugged my VSIX through Visual Studio, it worked. Hope this helps, I think it has something to do with extensions.en-US files inside that folder. Deleting just my plugin folder insted the Extensions folder did nothing.

How to package .NET Core 3 in Visual Studio Installer Project

So, I want to create an installer for my .NET Core 3 based C# project. I installed the Installer Projects extension for Visual Studio 2019 and created a new Installer project within my solution. After some trying around with different settings, I ended up with adding PublishItemsOutputGroup for my two executables to the Application Folder.
This (throwing various warnings for duplicate dlls) creates a nice installer package with "supposedly" all required dlls (there are quite a lot of .net libs). However, upon executing one of the installed exe files on a target computer, I am getting:
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '3.0.0' was not found.
- Check application dependencies and target a framework version installed at:
C:\Program Files\dotnet
- Installing .NET Core prerequisites might help resolve this problem:
https://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
- The .NET Core framework and SDK can be installed from:
https://aka.ms/dotnet-download
- The following versions are installed:
2.2.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
I know, I could create a gigantic self-contained .exe when publishing the .exe files, however, that seems kind of wasteful to me - creating two gigantic .exe files that contain mostly the same .dlls anyways.
Is there no way to include a .NET Core 3 setup in the installer project as well? I can't find anything on that topic on the internet...
I found this as had same problem, but eventually worked out if you set the publishProfilePath setting in the Installer Project it will include all the files and works fine.
For me replacing PrimaryOutput with PublishItemsOutputGroup works fine, when it comes to gathering the dependencies.
Unfortunately it does not allow referencing those outputs inside the installer. E.g. if you want to run custom actions or create Shortcuts during the installation, it does not work. The outputs are not available.

VS compiles correctly but command line doesn't

I have a project (.NET Core targeting .NET 4.6.1) that has lots of libraries in it. When I build the project from Visual Studio all assemblies are created correctly.
But when I delete the bin and obj folders and try to rebuild from PowerShell with dotnet publish, one of the libraries' assembly gets created badly; it's only half the file size and it doesn't work when I run the functionalities of that library.
The problem exist because I need to publish it through Team City so I can't do it from Visual Studio.
Anybody got any idea why it's behaving like this?

Visual Studio projects copy dependencies from referenced project into output

Is it possible to make Visual Studio to copy all dependencies of referenced projects into the output path?
Example
In the Solution, Project A (Library, .NET Standard) defines some functions and is dependent on Library L1 (via NuGet) and Library L2 (local .dll, referenced and copied to project)
Project B (Console Application) references Project A.
When building B, The output folder contains all direct dependencies of B and A.dll. L1 and L2 are not available in the output. Therefore, the program does not work correctly.
How can I force VS to copy also L1 and L2 to the output of B?
The only way I found so far is packing A as NuGet, but this seems to be unnecessary overhead and uncomfortable. I think I am just forgetting something everyone else seems to know...
Edit (clearifying Example)
My solutions consists of two projects.
Project MongoWrapper
.NET Standard 2.0 class Library
depends on NuGet MongoDB.Driver package
Actually uses this dependency (no zombie dependency)
Project ConsoleUser
.Net Framework 4.6.1 Console Application
References MongoWrapper project
Actually uses MongoWrapper
Observation
When debugging the ConsoleUser application, it compiles and starts. During runtime, when it calls a method in the MongoWrapper which uses the MongoDB.Driver, the application crashes, as the MongoDB.Driver dependency was not copied into the output folder of the ConsoleUser.
How to fix this?
The problem was introduced by the usage of .Net Standard library and a .Net Framework application.
TLDR
Open the .csproj file of the .Net Framework project with a text editor. Inside the first PropertyGroup add the line
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
Save the file, reopen Solution in Visual Studio and perform Clean & Build
Dependencies in different project file versions
.Net Framework projects use an old version of the .csproj project files. References/Dependencies are stored in the additional packages.configfile. By default, building a .Net Framework project makes the system to search for a packages.config file in the referenced projects. If no such file is found, the build task treats the referenced project as having no dependencies. Therefore, in the example, the MongoDB.Driver library is not added.
By adding the proposed line in the .csproj project file, the build task searches the project file of the referenced project for dependencies, where they are stored in .Net Standard project files.
.Net Core projects by default search for the newer project file structure.
The default behavior for new projects can be set in the Options -> NuGet -> General -> Package Management
Is it possible to make Visual Studio to copy all dependencies of referenced projects into the output path?
Yes.
This is what publishing the application does - it prepares the application for deployment. When you publish, it will include all of the dependencies that the application requires to run in the output.
Use the Publish tool to deploy to a local folder. The exact options available depend on your app type. In Solution Explorer, right-click your project and choose Publish, and then choose Folder. For more information, see Deploy to a local folder.
Tutorial: Publish your Hello World application with Visual Studio 2017
Also see: .NET Core application deployment.

Clickonce WPF application with custom and default prerequisites

I have a .Net 4 WPF ClickOnce app that has .NET Framework 4, VC++ 2013 Runtime Libraries and Windows Installer 4.5 as prerequisites.
I now have to add VC++ 2010 Libraries.
I have followed the steps here to create a custom prerequisite package. In visual studio, the package shows up in my prerequisite list. However, the installer is not attempting to install the VC++2010 package.
product.xml
package.xml
I have downloaded the vcredist_x86.exe into the package directory, however I am unsure what to set under "Specify the install location for prerequisites", since I am now mixing custom and default pre-reqs.
Any assistance would be much appreciated!
Edit: I have logged my clickonce installation and see nothing referencing the VC++ package at all. No errors or anything.
The following configurations worked without having to include the package in the deploy.
package.xml
package.xml
product.xml
product.xml
I placed the files above in a new directory:
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bootstrapper\Packages\vcredist_x86-2010\product.xml
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\Bootstrapper\Packages\vcredist_x86-2010\en\package.xml
Note: I did not include the vcredist_x86.exe package anywhere in the bootstrapper directory - it is downloaded during installation.
Before the installer is run, on a fresh Windows 8.1 install;
Prompt for prerequisites;
After installer, both C++ Runtime Libraries installed;

Categories

Resources