How to add .Net framework prerequisite to setup in

2019-03-13 08:19发布

问题:

I have a C# WinForms project in MS Visual Studio 2017. I have added a Visual Studio Installer Setup Wizard Project to create an installer for my application. This is my first time using an installer project.

The installer correctly has a prerequisite for .Net framework 4.5.1. However, I would like to make the installer include the .Net framework installation instead of asking the user to download and install it separately at install-time (some of the users' machines don't have internet connections).

I have already set the prerequisites to "Download prerequisites from the same location as my application" in the Setup Property Pages, but when I build the setup I see 3 errors as follows:

ERROR: To enable 'Download prerequisites from the same location as my application' in the Prerequisites dialog box, you must download file 'DotNetFX461\NDP461-KB3102436-x86-x64-AllOS-ENU.exe' for item 'Microsoft .NET Framework 4.6.1 (x86 and x64)' to your local machine. For more information, see http://go.microsoft.com/fwlink/?LinkId=616018.

The link included doesn't really help as it refers to ClickOnce installs. I have the mentioned NDP461 exe but I don't know where to put it. I see some other questions mention creating a bootstrapper package using the MS Bootstrapper Package Manager, but this seems to have disappeared from the internet with MS's closure of code.msdn.microsoft, with apparently no information on a replacement. Additionally, most documentation and SO questions that I can find on the subject relate to older versions of MSVS, and do not correlate (at least not directly enough for me to figure out!) to MSVS 2017.

How do I go about actually getting the setup project to find the exe? Do I simply need to plop it in the right location (already tried a few that were listed on various MSDN pages and under registry keys)? Or do I need to create a bootstrapper package? If the latter, is there up to date documentation on this process somewhere? Thanks!

PS: Would the process be easier if I chose instead to use the (more recent) .Net framework that is already installed on my development machine? (I'm guessing there might be install information for that already on the machine somewhere)

Update So I tried switching to targeting .NET 4.6 instead, downloaded NDP46-KB3045557-x86-x64-AllOS-ENU.exe and placed it in the directory C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX46. The installer setup project now builds but gives the following warning (again, 3 of them):

WARNING: The value of the 'PublicKey' attribute in 'Microsoft .NET Framework 4.6 (x86 and x64)' does not match that of file 'C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX46\NDP46-KB3045557-x86-x64-AllOS-ENU.exe'.

I guess this means I'm not supposed to do it this way?

回答1:

Just download NDP461-KB3102436-x86-x64-AllOS-ENU.exe file from This Link

and copy to C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX461



回答2:

For Microsoft Visual Studio 2017 the correct folder to add the bootstrapper packages is:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\SDK\Bootstrapper\Packages\

Links for the various redistributable .NET packages can be found here along with info on different deployment options: https://docs.microsoft.com/en-us/dotnet/framework/deployment/deployment-guide-for-developers

The error messages give you the correct folders to add to the packages folder. So the file NDP46-KB3045557-x86-x64-AllOS-ENU.exe should be added to a folder "DotNetFX46" under Packages.

I really do not understand why Microsoft has not taken the steps to make this an automated process or at least provide a step by step guide on how to add the bootstrap packages to different versions on Visual Studio. The procedure and folders have changed several times over the years.

The public key mismach is most likely due to the fact that there have been at least two versions of the NDP46-KB3045557-x86-x64-AllOS-ENU.exe file distributed with the same filename, but different public keys. Check this link: https://connect.microsoft.com/VisualStudio/feedback/details/1584164/bootstrapper-packages-have-broken-links-and-wrong-public-keys



回答3:

For me (VS2017 enterprise) the correct path is (for 4.7.1) C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages\DotNetFX471

hope this will help

Benoist LUGNIER