-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Prevent built-in artifacts output functionality from conflicting with Microsoft.Build.Artifacts SDK #33470
Conversation
… Microsoft.Build.Artifacts SDK Fixes dotnet#33052
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.
Looks good. Should we expect to generalize the logic for other SDKs in the future?
@@ -20,7 +20,7 @@ Copyright (c) .NET Foundation. All rights reserved. | |||
</PropertyGroup> | |||
|
|||
<!-- Setting ArtifactsPath automatically opts in to the artifacts output format --> | |||
<PropertyGroup Condition="'$(ArtifactsPath)' != ''"> | |||
<PropertyGroup Condition="'$(ArtifactsPath)' != '' And '$(UsingMicrosoftArtifactsSdk)' != 'true'"> |
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.
When a user references Microsoft.Build.Artifacts as a package, its .props
is imported by .nuget.g.props
which is imported after this. So I don't think UsingMicrosoftArtifactsSdk
will be set yet since this is imported immediately after Directory.Build.props
.
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.
This is only imported early on if UseArtifactsOutput
or ArtifactsPath
are set in Directory.Build.props:
sdk/src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.props
Lines 64 to 65 in 9d157dc
<Import Project="$(MSBuildThisFileDirectory)..\targets\Microsoft.NET.DefaultArtifactsPath.props" | |
Condition="'$(UseArtifactsOutput)' == 'true' Or '$(ArtifactsPath)' != ''"/> |
If they are set later on (ie in the project file), then this file will be imported later, during the .targets evaluation: https://github.com/dotnet/sdk/blob/main/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.DefaultOutputPaths.targets#L42-L43
So if the Microsoft.Build.Artifacts NuGet package is being used and ArtifactsPath
is set in Directory.Build.props, then the built-in SDK artifacts functionality will be used. If ArtifactsPath
is set in the project file (as seems to be suggested in the Microsoft.Build.Artifacts documentation), then the Microsoft.Build.Artifacts logic will be used.
Does this sound OK? Do you know if anyone using Microsoft.Build.Artifacts is setting ArtifactsPath
in Directory.Build.props? IE, something like:
<Project>
<PropertyGroup>
<BaseArtifactsPath>$(MSBuildThisFileDirectory)artifacts</BaseArtifactsPath>
<ArtifactsPath>$(BaseArtifactsPath)\$(MSBuildProjectName)</ArtifactsPath>
</PropertyGroup>
</Project>
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.
@jeffkl I went ahead and merged this because we wanted to get the fix in before the .NET 8 Preview 6 branch, Let me know what you think about this and we can follow up with another change if need be.
I've also created a pull request to disable Microsoft.Build.Artifacts if the .NET SDK's built-in functionality is enabled: microsoft/MSBuildSdks#458 |
No, this is because we added a specific property that was already in use by this specific SDK. |
Fixes #33052