Skip to content

Fix ASP.NET Core module installer upgrade issues #60769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2025

Conversation

lextm
Copy link
Contributor

@lextm lextm commented Mar 6, 2025

Fix ASP.NET Core module installer upgrade issues

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Summary of the changes (Less than 80 chars)

  • Add version numbers to ARM64X pure forwarder compilation.
  • Revise WiX installer component/file relationship to ensure upgrade is possible.

Description

Initial PR #59483 left a few issues unresolved and led to #60764.

Changes in ancm_iis_expressv2.wxs and aspnetcoremodulev2.wxs

The previously introduced new components AspNetCoreModuleV2.forwarder and AspNetCoreModuleHandler.forwarder can confuse Windows Installer, and caused files like aspnetcorev2.dll to be mistakenly removed during upgrades from .NET 7/8/9.

Here they have been removed and the new files are conditionally included in previously existing components AspNetCoreModuleV2 and AspNetCoreModuleHandler.

Changes in all.cmd/build.cmd and build.proj

Previously the pure forwarder dlls were not built with version information. That confused Windows Installer when it tried to compare files like aspnetcorev2.dll with previous installed versions.

Here we ask the linker to use .res files that were used to build the x64 builds of related .dll files. This ensures that pure forwarders have the same version information as well as other metadata.

Fixes #60764

@Copilot Copilot AI review requested due to automatic review settings March 6, 2025 05:00
@lextm lextm requested review from wtgodbe and a team as code owners March 6, 2025 05:00
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

@ghost ghost added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Mar 6, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Mar 6, 2025
@lextm lextm force-pushed the ancm-installer-update branch from b2adfba to 9b68a79 Compare March 6, 2025 06:11
@lextm lextm changed the title [WIP] Fix ASP.NET Core module installer upgrade issues Fix ASP.NET Core module installer upgrade issues Mar 6, 2025
@lextm
Copy link
Contributor Author

lextm commented Mar 6, 2025

Tested with IIS Express and IIS. This pull request is now ready for further review.

@eerhardt eerhardt requested review from joeloff and halter73 March 6, 2025 14:27
<File Id="AspNetCoreModuleDll"
Name="aspnetcorev2.dll"
Source="$(var.AspNetCoreV2ProgramFilesTargetPath)"
DiskId="1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File@DiskId="1" and File@Vital="yes" are the defaults, there are probably more of these to clean up

DiskId="1"
Vital="yes"/>
<?endif ?>
<RegistryKey Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\EventLog\Application\$(var.ProductShortName)">
Copy link
Member

@joeloff joeloff Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The general rule for components is one file/reg key per component. When performing repairs, the keypath of the component is used to determine its state and whether it needs to be reinstalled during a repair. If non-keypath items are missing or damaged, repairs my not necessarily work. It's likely repair will write the registry keys again since WiX by default will set the reinstall mode to include registry keys. Just calling it out in case this is an issue.

<File Id="AspNetCoreModuleV2Dll.forwarder"
<Component Id="AspNetCoreModule" Guid="84ed6ce6-c8a3-4fa8-a872-c98a1d15dd4f" Win64="$(var.IsWin64)">
<?if $(var.Platform) = "arm64" ?>
<File Id="AspNetCoreModuleDll"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should consider setting the File@KeyPath="yes". If child elements of a component do not have a keypath set, and the parent directory of the component is not a key path, then the first child is selected. In this case, it would be the file. However, if you modify the order, the key path will change. Setting it explicitly will avoid issues in the future.

This might be a good read: https://learn.microsoft.com/en-us/windows/win32/msi/what-happens-if-the-component-rules-are-broken

Copy link
Member

@joeloff joeloff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wtgodbe once this is merged, I'd suggest doing a full setup test pass on multiple scenarios including

  • Clean install
  • Upgrade (8+10+9)
  • Include Repair/Uninstall tests for the scenarios above
  • Double check what happens with success blockers. In this case, install 10.0.0-preview.2 and then install 10.0.0-preview.1 Success blockers bypass the downgrade check at the bundle level, allowing it to run. The MSI though should not get executed.

@halter73
Copy link
Member

@joeloff Since you approved the PR and your suggestions seem like style improvements, I'm going to merge it as-is to make it easier to get started manually testing upgrade scenarios.

Let me know if any of these suggestions are important enough to warrant a quick follow up PR or tracking issue to look at more holistically across all our .wxs files.

@halter73 halter73 merged commit a848bfa into dotnet:main Mar 13, 2025
27 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the 10.0-preview3 milestone Mar 13, 2025
@joeloff
Copy link
Member

joeloff commented Mar 13, 2025

They're not style suggestions.

lextm added a commit to lextudio/httpplatformhandlerv2 that referenced this pull request Mar 15, 2025
* Added correct version numbers to ANCM pure forwarders (dotnet#60764)
* Revised component/file relationship (dotnet#60764)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Windows hosting bundle upgrade breaks ANCM on ARM64 machines
3 participants