问题
The extension Visual Studio Installer Projects was dropped at some point - about 10 years ago. Protests from many developers caused Microsoft to change its mind and the extension was reintroduced and then left unchanged as far as I know. I have worked with it for a long time - actually to package applications built outside Visual Studio (i.e. Delphi and Java stuff). This worked well until recently. Now a dependency is somehow detected for .NET Framework 4.7.2, but my colleagues assured me that it is not needed. I cannot remove this dependency. And I could not remove the associated launch condition either. I even tried to hack the *.vdproj file by removing some JSON from it that referred to the .NET framework, but to no avail. When I added a second project to the solution, I was able to at least remove the launch condition that would prompt the user to install the framework. I was able to save the solution like that. However: when I clicked to start the build process, the launch condition was added again before the actual process started. Does anybody know any other trick which I could use?
回答1:
Disclaimer: Added after the below answer. Please skim. Strongly recommend you consider a more capable and transparent MSI tool (no surprises like these) if you plan to keep delivering your software. Just for the record:
1)
Problem list VS Installer projects.2)
Even longer list.
I am not sure what the custom action
CheckFX
does. You might need to disable this custom action too. Update: After more testing I think you should leave this action in.There are also two interesting properties in the Property table:
VSDFrameworkVersion
= v4.6.1VSDAllowLaterFrameworkVersions
= FalseThese properties might be possible to manipulate to change the behavior of the custom actions mentioned below. Particularly the
VSDAllowLaterFrameworkVersions
looks interesting. Try setting it to"True"
and test on your target platforms? My quick test seemed ineffective.
Overall Recommendation: The summary of it all is that
1)
I suggest you use a better tool if you need this to work properly in the future without "black box surprises" (you don't know how things really work).2)
The "solution" to disable theVSDCA_VsdLaunchConditions custom action
as described below should work though.3)
Please test thoroughly on all target OS versions. Remember upgrade scenarios and uninstall.4)
You could try those properties in the property table (VSDFrameworkVersion
,VSDAllowLaterFrameworkVersions
). Various settings. I didn't discover anything in particular after a smoke test.
Prerequisites: The first proposed solution I added (at the bottom of this answer now) will remove the dependency on the .NET framework to look at, but it seems there is a custom action in the MSI which will check for the baseline .NET version anyway. It is called: VSDCA_VsdLaunchConditions
.
Hack MSI: To prevent any checks for the .NET framework you can hack the MSI as follows:
- Open your MSI with Orca.
- In the
InstallExecuteSequence table
locateVSDCA_VsdLaunchConditions
and change its condition by adding:"AND 0"
to what is there already. This will prevent the custom action from running at all. - Continue in the
InstallUISequence table
. LocateVSDCA_VsdLaunchConditions
and change its condition by adding:"AND 0"
to what is there already. - Save the MSI and do a test install on a box without recent versions of the .NET framework (some are built-in on most OS versions now).
Always False Condition: AND 0
makes the condition for the sequence custom action always false - which means it never runs. You can also delete the custom action itself, but that would generate some dangling foreign keys - this approach should not do so.
MSI Tables: The InstallExecuteSequence table
runs the installation. The InstallExecuteSequence table
runs the setup GUI - both locations must be modified to prevent any .NET checks.
Consequences: Side-effects of this approach should be minimal (unless your application really does require a specific, higher version of the .NET framework), but I don't know what else goes on in that custom action.
Custom Action DLL: The actual custom action binary inside the VS Installer Project seems to be capable of a lot of things, but this functionality should inject other custom actions than the above dependency custom action. Looking at the exported functions of the dll it seems most calls relate to IIS functionality:
Below is the original answer. It seems to prevent the bundling of .NET frameworks with your MSI, but it seems there is a "baseline check" anyway for a "lowest possible" version of the .NET framework. For Visual Studio 2019 this seems to be .NET 4.6.
When you right click the main project and go properties do you see the "Prerequisites" dialog as shown here? Here you can change what prerequisites your setup bundles:
In the top left corner, select your "Release" configuration.
Now press the "Prerequisites" button to get this dialog:
Adjust the required version of the .NET framework - or remove the dependency.
Note that this is done by the setup.exe launcher and not the MSI it seems. You should be able to run the MSI itself or the setup.exe launcher. The latter will install the .NET framework specified (if missing), and the MSI installed on its own should not.
Links:
- How to: Determine which .NET Framework versions are installed
来源:https://stackoverflow.com/questions/65233333/visual-studio-2019-installer-project-how-to-remove-launch-condition-for-net-fr