Skip to content

msbuild: run manifest install only once #51348

Merged
BillyONeal merged 8 commits into
microsoft:masterfrom
autoantwort:feature/run-install-only-once-2
May 7, 2026
Merged

msbuild: run manifest install only once #51348
BillyONeal merged 8 commits into
microsoft:masterfrom
autoantwort:feature/run-install-only-once-2

Conversation

@autoantwort

@autoantwort autoantwort commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Greatly inspired by #41605 and works the same way.

This reduces our ci build times by 15%

Leander Schulten added 2 commits April 23, 2026 16:51
VS 2015 is not supported anymore and even have problems to compare versions.
@mschofie

Copy link
Copy Markdown
Member

15% reduction is really impressive! What's that in minutes?

It's way more than I would have expected - is it that MSBuild is able to make forward progress without being blocked on the 'vcpkg install'? Or is it that the 'vcpkg install' backlog just clears more quickly?

@autoantwort

Copy link
Copy Markdown
Contributor Author

The latest run is with this change.
image

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the MSBuild manifest-mode install flow so that dependency installation is executed via a single shared MSBuild invocation, aiming to avoid repeated vcpkg install work across multi-project builds and reduce CI build time.

Changes:

  • Replaces the inline Exec in VcpkgInstallManifestDependencies with an MSBuild task that runs a shared implementation target.
  • Adds inline MSBuild tasks to capture global property names (for RemoveProperties) and to snapshot/restore selected VCPKG_/X_VCPKG_ environment variables.
  • Introduces a new InstallImplementation.targets project containing the actual install implementation and stamp touch.

Reviewed changes

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

Show a summary per file
File Description
scripts/buildsystems/msbuild/vcpkg.targets Switches manifest install target to call a shared MSBuild implementation and adds imports for new inline tasks.
scripts/buildsystems/msbuild/support/RestoreEnvVars.task Adds inline task to restore captured environment variables before running vcpkg.
scripts/buildsystems/msbuild/support/InstallImplementation.targets New shared implementation target that runs vcpkg install and touches the stamp file.
scripts/buildsystems/msbuild/support/GetVcpkgEnvVars.task Adds inline task to capture VCPKG-related environment variables into a property.
scripts/buildsystems/msbuild/support/GetGlobalProperties.task Adds inline task to retrieve current MSBuild global property names for RemoveProperties.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/buildsystems/msbuild/vcpkg.targets Outdated
Comment thread scripts/buildsystems/msbuild/support/RestoreEnvVars.task
Comment thread scripts/buildsystems/msbuild/support/GetGlobalProperties.task Outdated
Comment thread scripts/buildsystems/msbuild/vcpkg.targets Outdated
Comment thread scripts/buildsystems/msbuild/vcpkg.targets
Comment thread scripts/buildsystems/msbuild/vcpkg.targets
Comment thread scripts/buildsystems/msbuild/vcpkg.targets Outdated

@BillyONeal BillyONeal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I still need to demonstrate that this doesn't break export (the same blocker as #41605 )

Comment on lines 176 to 177
Inputs="@(_ZVcpkgInstallManifestDependenciesInputs)"
Outputs="$(_ZVcpkgMSBuildStampFile)">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm pretty sure that all the stuff about trying to make incremental be correct also needs to be moved to that other project. For example, this is declaring _ZVcpkgMSBuildStampFile as an output but is no longer creating it in the target.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But it is created while the target is executed. I can only say that it did the right thing when testing it.

Comment thread scripts/buildsystems/msbuild/support/GetGlobalProperties.task Outdated
Comment thread scripts/buildsystems/msbuild/vcpkg.targets Outdated
Comment thread scripts/buildsystems/msbuild/support/InstallImplementation.targets Outdated
@autoantwort

Copy link
Copy Markdown
Contributor Author

I still need to demonstrate that this doesn't break export (the same blocker as #41605 )

Can you explain why this could break export? According to the code you linked only a reference to the vcpkg.target file is exported and the behavior of this file does not change with this PR.

@BillyONeal

Copy link
Copy Markdown
Member

Can you explain why this could break export? According to the code you linked only a reference to the vcpkg.target file is exported and the behavior of this file does not change with this PR.

I'm like 80% sure it will be fine but I need to verify that because we don't have tests for export, and export does interact with all this MSBuild bindings stuff. (For example, a potential bug would be that the resulting exported package doesn't have this new support directory inside which would likely explode)

@autoantwort

Copy link
Copy Markdown
Contributor Author

I have tested the export, the .target file references the support files, but they are not included. I will make them conditional.

In the nuget export, the target file exists, but the support folder is not copied.
But since there is no vcpkg.json file manifest mode is not enabled and the files are not loaded.
@BillyONeal

Copy link
Copy Markdown
Member

@autoantwort

Copy link
Copy Markdown
Contributor Author

Or we can just fix it: https://github.com/microsoft/vcpkg-tool/blob/d51657069fcf70c67fa6411a0c81ced30c087904/src/vcpkg/commands.export.cpp#L157-L166

But we don't need to, we don't need the support files. We never want to run vcpkg install within an exported nuget package.

@BillyONeal BillyONeal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@BillyONeal BillyONeal merged commit d7ccba8 into microsoft:master May 7, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants