Skip to content
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

Microsoft.Build.Artifacts conflicts with .NET 8 SDK simplified output paths #477

Open
bording opened this issue Sep 7, 2023 · 17 comments
Open

Comments

@bording
Copy link
Contributor

bording commented Sep 7, 2023

The .NET 8 SDK has a new simplified output paths feature that is opt-in.

However, the property that has been chosen to configure it is ArtifactsPath.

That leads to any projects using Microsoft.Build.Artifacts that are built with the .NET 8 SDK to suddenly find bin and obj folders in the build artifacts folder.

@bording
Copy link
Contributor Author

bording commented Sep 25, 2023

@jeffkl Any thoughts on how you'd like to solve this conflict?

If you have a direction in mind, I'd be happy to open a PR with the required changes.

@jeffkl
Copy link
Contributor

jeffkl commented Sep 25, 2023

The .NET SDK now disables itself if you're using Microsoft.Build.Artifacts: dotnet/sdk#33470

I'm trying to get this pull request to work as well: #458

@bording
Copy link
Contributor Author

bording commented Sep 25, 2023

The .NET SDK now disables itself if you're using Microsoft.Build.Artifacts: dotnet/sdk#33470

Do you know what version of the .NET 8 SDK should have that change? The merged PR mentions Preview 6, but I'm using RC1, and I'm still seeing the conflict.

@jeffkl
Copy link
Contributor

jeffkl commented Sep 25, 2023

@dsplaisted can you answer @bording's question? #477 (comment)

@dsplaisted
Copy link
Member

@bording I believe the fix went into Preview 6 as mentioned in the PR, but it should definitely be in RC1 in any case. Can you share a repro or a binlog for how you're still seeing the conflict?

@bording
Copy link
Contributor Author

bording commented Sep 25, 2023

It's happening in https://github.com/Particular/ServiceControl. When I build that with the RC1 SDK, the bin and obj folders end up in the folder configured in ArtifactsPath.

ArtifactsPath is defined in a Custom.Build.props file, which is imported into Directory.Build.props.

The other potentially relevant piece is that Microsoft.Build.Artifacts is added as a GlobalPackageReference.

I can also try and put together a simplified repro if that would also be helpful.

@bording
Copy link
Contributor Author

bording commented Sep 26, 2023

@dsplaisted Here's a simplified repro:

repro.zip

I included a binlog in there as well. When I build that with the RC1 SDK, the configured artifacts folder has both the default artifacts from Microsoft.Build.Artifacts and the project bin and obj folders.

@bording
Copy link
Contributor Author

bording commented Oct 10, 2023

@dsplaisted @jeffkl Anything else I can do to move this forward?

@jeffkl
Copy link
Contributor

jeffkl commented Oct 11, 2023

@bording you can disable Microsoft.Build.Artifacts if you're using the .NET SDK's artifacts functionality:

<PropertyGroup>
  <EnableArtifacts Condition="'$(UseArtifactsOutput)' == 'true'">false</EnableArtifacts>
</PropertyGroup>

Although the .NET SDK's artifacts should be disabling itself if you're using Microsoft.Build.Artifacts.

@bording
Copy link
Contributor Author

bording commented Oct 11, 2023

@jeffkl I'm not using the .NET SDK artifact functionality, but it's enabled anyway. That's the entire point of the issue I've raised here.

Whatever you've done in the SDK so far to try and detect Microsoft.Build.Artifacts is not working.

@jeffkl
Copy link
Contributor

jeffkl commented Oct 11, 2023

Would the opposite work then, disabling .NET SDK's artifacts?

<PropertyGroup>
  <UseArtifactsOutput>false</UseArtifactsOutput>
</PropertyGroup>

@bording
Copy link
Contributor Author

bording commented Oct 11, 2023

@jeffkl That does force it off, yes. For now, I'll go ahead and add that to my project that's having the problem as a workaround.

However, that doesn't address the larger issue here. According to dotnet/sdk#33470, the SDK is supposed to detect Microsoft.Build.Artifacts and automatically disable the SDK artifacts. That detection is not working properly, so it seems like something that should be investigated and fixed.

@bording
Copy link
Contributor Author

bording commented Oct 11, 2023

Reading through the changes and comments in dotnet/sdk#33470, I believe this is happening in my case because of the scenario being talked about in dotnet/sdk#33470 (comment)

I do think something more needs to be done in the SDK to cover that scenario as well.

@jeffkl
Copy link
Contributor

jeffkl commented Oct 11, 2023

Got it, I think we'll need to open an issue at https://github.com/dotnet/sdk/issues/new/choose instead, this issue is about Microsoft.Build.Artifacts disabling itself when the .NET SDK's functionality is enabled.

@bording
Copy link
Contributor Author

bording commented Oct 11, 2023

Got it, I think we'll need to open an issue at https://github.com/dotnet/sdk/issues/new/choose instead, this issue is about Microsoft.Build.Artifacts disabling itself when the .NET SDK's functionality is enabled.

Maybe you're thinking about a different issue? This is the issue I opened about the conflict.

@dsplaisted
Copy link
Member

Due to the order things are imported in, I'm not sure we can make this work without requiring the Directory.Build.props to set UseArtifactsOutput to false (or some other change to that file). The project is opting in to using Microsoft.Build.Artifacts by referencing the package and setting the ArtifactsPath. However, ArtifactsPath is now overloaded with the built-in functionality of the .NET SDK, and in this case at the point where we're determining whether we should use the built-in .NET SDK functionality, we don't know yet that the Microsoft.Build.Artifacts package has been referenced.

So I think the guidance should be, that if you're referencing Microsoft.Build.Artifacts as a NuGet package, and you are setting ArtifactsPath via Directory.Build.props, that you should also set UseArtifactsOutput to false when you set ArtifactsPath.

@bording
Copy link
Contributor Author

bording commented Oct 11, 2023

If it's not actually possible to resolve the conflict between the shared use of ArtifactsPath, then I don't think it's really acceptable to leave things in the state that they are currently in.

Instead, I think it makes more sense to go ahead and take a breaking change in a new major version of Microsoft.Build.Artifacts and have it use a different property name, for example BuildArtifactsPath.

That was what I was going to suggest doing when I opened this issue before learning that there was an attempt to modify the SDK.

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

No branches or pull requests

3 participants