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

Add support for new output path format #29599

Merged

Conversation

dsplaisted
Copy link
Member

@dsplaisted dsplaisted commented Dec 16, 2022

Add support for simplified output paths and RootOutputPath property.

Based on this design spec: dotnet/designs#281. The design doc needs to be updated. The main changes from the current version:

  • Switching away from the "artifacts" name, and putting the new output paths under bin instead. This is discussed in this comment
  • The new output path format is not enabled by default on .NET 8 and higher. You have to opt in to it. This is due to some of the issues in the previously referenced comment, as well as concerns about builds (especially Maui builds) running into Windows path length issues.

I needed a name for a property that would enable the new output paths. I went with UseStandardOutputPaths, which was the best I could think of. Better name suggestions are welcome.

The property that puts all output for a solution under a single folder is RootOutputPath, which I think is a reasonably good name. Still open to suggestions though.

@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@dsplaisted dsplaisted force-pushed the artifacts-output-paths branch 3 times, most recently from 0dfec36 to 2b20308 Compare January 12, 2023 20:20
@dsplaisted
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dsplaisted dsplaisted force-pushed the artifacts-output-paths branch from 2b20308 to 459c758 Compare January 13, 2023 00:36
@dsplaisted dsplaisted force-pushed the artifacts-output-paths branch 3 times, most recently from bdee25b to fc0df06 Compare January 27, 2023 20:52
@dsplaisted dsplaisted marked this pull request as ready for review January 27, 2023 21:05
@dsplaisted dsplaisted requested review from a team as code owners January 27, 2023 21:05
@dsplaisted dsplaisted requested review from nagilson, joeloff, rainersigwald and a team and removed request for a team January 27, 2023 21:06
Copy link
Member

@nagilson nagilson left a comment

Choose a reason for hiding this comment

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

Thank you for wrangling up all of those tests... wow that was a lot of hard-coded paths.

It looks like there are still a lot of test failures, including a few of the newer tests, so I won't look at the MSBuild code and try it out until those are fixed. Also hoping to get a little more engagement on the design spec

UseStandardOutputPaths seems like it has a similar-ish problem in what is "standard" might change... (I am thinking of netstandard rids.)
Some brainstormed ideas:
UseSimplifiedOutputPaths
UseExperimentalOutputPaths

I like RootOutputPath. Maybe also: FlatOutputPath?

Copy link
Member

@baronfel baronfel left a comment

Choose a reason for hiding this comment

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

Very excited to see this land for previews and user feedback!

Re: the name of the opt-in property, I agree with @nagilson that Standard's meaning can change over time, but I don't have a compelling alternative. Maybe UseUnifiedOutputPaths? This is something we can potentially update across previews.



<!-- We need to put the UseStandardOutputPaths logic after the import of Directory.Build.props, but before the MSBuild Project Extensions .props import.
However, both of these things happen in Microsoft.Common.props with no opportunity to insert logic in between them.
Copy link
Member

Choose a reason for hiding this comment

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

Do you think this is a gap in the layering that we should try to change for .NET 8? I see a few lines below that you suggest this - I think it would be worth doing for a later preview!

src/Tasks/Microsoft.NET.Build.Tasks/sdk/Sdk.props Outdated Show resolved Hide resolved
Copy link
Contributor

@Nirmal4G Nirmal4G left a comment

Choose a reason for hiding this comment

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

Why not BuildDir?

My proposals:

  1. Introduce BuildDir as a top-level directory for all things build
  2. Fix output path customization limitations

I personally think we should start from existing paths and modify it to cover all the goals presented in the new proposal. I'm not good at explaining things over words, so I could create a PR on both MSBuild repo and here to explain the changes better!

@joeloff
Copy link
Member

joeloff commented Jan 31, 2023

For the Standard naming issue, I'll toss another suggestion out, Legacy

@richlander
Copy link
Member

Can you add an example to your initial comment what default and opt-in will look like? That would help a lot.

@dsplaisted dsplaisted force-pushed the artifacts-output-paths branch from caf9af8 to ebcbb81 Compare February 24, 2023 22:54
@dsplaisted
Copy link
Member Author

@joeloff @nagilson @baronfel @rainersigwald I've updated the implementation here to (I believe) match the latest version of the design proposal.

I still need to update tests and probably add some more test coverage, but the implementation is ready to review, I believe.

@dsplaisted dsplaisted changed the base branch from main to release/8.0.1xx-preview2 February 28, 2023 00:42
@dsplaisted dsplaisted force-pushed the artifacts-output-paths branch from 030e11f to de35c57 Compare March 21, 2023 18:09
@marcpopMSFT marcpopMSFT deleted the branch dotnet:release/8.0.1xx-preview3 March 21, 2023 20:40
@marcpopMSFT marcpopMSFT reopened this Mar 21, 2023
@marcpopMSFT
Copy link
Member

@dsplaisted fyi, we had a bad branch creation for preview 3 so we deleted it and repushed with the right commit. I had to close and reopen your PR during that activity (and fixed a merge conflict)

Copy link
Member

@rainersigwald rainersigwald left a comment

Choose a reason for hiding this comment

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

I didn't look at all the tests, but have a few small comments on the MSBuild logic.

<PropertyGroup Condition="'$(UseArtifactsOutput)' == 'true' And '$(ArtifactsPath)' == '' And '$(_DirectoryBuildPropsBasePath)' != ''">
<!-- Default ArtifactsPath to be in the directory where Directory.Build.props is found
Note that we do not append a backslash to the ArtifactsPath as we do with most paths, because it may be a global property passed in on the command-line which we can't easily change -->
<ArtifactsPath>$(_DirectoryBuildPropsBasePath)\.artifacts</ArtifactsPath>
Copy link
Member

Choose a reason for hiding this comment

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

If you stick with .artifacts I think you should add it to the .gitignore template

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

<!-- Repeat ArtifactsPath logic from Sdk.props here, in case UseArtifactsOutput was set in the project file -->
Copy link
Member

Choose a reason for hiding this comment

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

Could we error in that case instead? I don't like the idea of accidentally diverging the implementation over time.

Copy link
Member Author

Choose a reason for hiding this comment

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

So ArtifactsPath just wouldn't be allowed in the project file at all?

We go through some hoops to make BaseIntermediateOutputPath work whether it's set in the project file or beforehand. If it's set in the project file then it doesn't affect MSBuildProjectExtensionsPath. This seemed analogous.

I just had a crazy idea: Maybe we could de-duplicate some of the logic by having a .props file that's conditionally imported in two different places depending on where ArtifactsPath is defined?

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't sound crazy to me, sounds pretty smart 😄

@dsplaisted
Copy link
Member Author

Might be totally unrelated, but does this potentially impact things like the build configuration dialogs in Visual Studio? What happens when a user launches VS directly/from a console that don't have the properties set for using a single output path or is the assumption that they're either specified as environment variables or defined in a directory.build.props?

@joeloff I think the main scenario is to put it in Directory.Build.props or to specify it on the command-line. If ArtifactsPath is specified in Directory.Build.props then Visual Studio should respect it. Do you mean the Configuration Manager dialog? It doesn't look like that shows output paths so I don't think it would be affected at all.

If you only specify the artifacts path on the command-line, then Visual Studio would build using the default (old) paths. The different output paths shouldn't interfere with each other though (the test that verifies that you can switch between output path formats helps verify that). Also, I think specifying the artifacts path on the command line may be more of a CI scenario so it isn't as likely to happen together with Visual Studio.

@dsplaisted dsplaisted merged commit 49a96a8 into dotnet:release/8.0.1xx-preview3 Mar 22, 2023
@dsplaisted
Copy link
Member Author

dsplaisted commented Mar 22, 2023

Followup items:

  • Port changes to main branch
  • Add .artifacts to Visual Studio default .gitignore file. 1 2
  • De-duplicate default output path logic depending on whether ArtifactsPath is defined in project file or beforehand
  • Add hook to MSBuild to inject targets after Directory.Build.props import, and use that in SDK instead of duplicate import logic.
  • Consider adding telemetry data point to detect when artifacts output path is turned on

@nagilson
Copy link
Member

It would also be good to de-duplicate the code for TestSolution and the new test library code for solutions.

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.

8 participants