-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add support for IfDifferent #51826
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
base: main
Are you sure you want to change the base?
Add support for IfDifferent #51826
Conversation
|
Thanks for your PR, @@JanKrivanek. |
There was a problem hiding this comment.
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 adds support for the IfDifferent value of CopyToOutputDirectory and CopyToPublishDirectory metadata for static web assets, aligning with the new capability added to MSBuild in dotnet/msbuild#11052. This enables Project System to offer the new copy action in its dropdown without causing issues with static web asset handling.
- Adds filtering logic to split static web assets with
IfDifferentcopy semantics into dedicated item groups - Creates new copy targets that use
SkipUnchangedFiles="true"to implement the IfDifferent behavior - Updates target dependencies to ensure the new IfDifferent targets are executed during build and publish
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.targets | Adds _BuildStaticWebAssetsIfDifferent item group and _BuildCopyStaticWebAssetsIfDifferent target for build scenarios, updates WriteStaticWebAssetsUpToDateCheck dependencies |
| src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.Publish.targets | Adds _PublishStaticWebAssetsIfDifferent item group and _PublishCopyStaticWebAssetsIfDifferent target for publish scenarios, adds condition guards to existing PreserveNewest and Always targets |
src/StaticWebAssetsSdk/Targets/Microsoft.NET.Sdk.StaticWebAssets.targets
Show resolved
Hide resolved
|
I suspect we'll also need to extend the copies done as part of CopyFilesToPublishDirectory: sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets Lines 267 to 271 in b64c645
The build-time Copy usage was updated in the MSBuild Targets, but Publish is more of an SDK concept. |
|
We'll likely want to schedule a follow-up item to find usages of |
|
@JanKrivanek I think this point from your linked issue
needs to happen with this PR - otherwise all normal publishes are broken (even if staticwebassets works). The audit of the rest of the SDK I agree is a separate unit of work, but the |
Fair point. |
|
/azp run |
|
Commenter does not have sufficient privileges for PR 51826 in repo dotnet/sdk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent - these are the publish-related things I was worried about. I'd love to get these backported to 10.0.2xx once this merges!
Context
dotnet/msbuild#11052 Added support for
IfDifferentvalue ofCopyToOutputDirectorymetadata.The building/publishing of static web assets was not honoring this. It should be supported, so that the new copy action can be added to Project System copy action dropdown without risk of causing issues.
FYI @baronfel @drewnoakes