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

Improve docs on pack's CopyToOutput and Flatten #3274

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zivkan
Copy link
Member

@zivkan zivkan commented Apr 3, 2024

No description provided.

@zivkan zivkan requested review from a team as code owners April 3, 2024 13:46
Copy link

Learn Build status updates of commit 6d8804f:

✅ Validation status: passed

File Status Preview URL Details
docs/reference/msbuild-targets.md ✅Succeeded View

For more details, please refer to the build report.

For any questions, please:

Comment on lines +130 to +131
| PackageCopyToOutput | The file's `CopyToOutput` item metadata will be set the specified value in the project using the package. |
| PackageFlatten | The file's `Flatten` item metadata will be set to the specified value in the project using the package. |
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd love to link to some docs where customers can learn more about CopyToOutput and Flatten, but I can't find any Does anyone know where these are documented?

Copy link
Member Author

Choose a reason for hiding this comment

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

Rainer pointed me to CopyToOutputDirectory documented on https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items?view=vs-2022

I guess this is what PackageCopyToOutput sets, but since the NuGet name is missing Directory I feel like it's something we need to validate.

I still haven't found docs on Flatten though.

Copy link
Member

@nkolev92 nkolev92 Apr 4, 2024

Choose a reason for hiding this comment

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

I'd add BuildAction here.

In general, the BuildAction defaults to the item type.


As described in the section on [including content in your package](#including-content-in-a-package), there is certain [item metadata](/visualstudio/msbuild/msbuild-items#item-metadata) that can be added to [MSBuild items](/visualstudio/msbuild/msbuild-items), which pack will use.

| Metadata | Description |
Copy link
Member Author

Choose a reason for hiding this comment

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

I believe the nuspec allows files under contentFiles/ to set whatever item type they want, for example, you could have contentFiles/cs/any/stuff.cs and make it a <Compile item, not <Content.

@nkolev92 do you remember how to specify this? I didn't have much of a search yet, so if you don't know, don't waste time looking for it yourself, I'm just hoping you can save me some time 😁

Copy link
Member

Choose a reason for hiding this comment

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

BuildAction

Copy link
Member

Choose a reason for hiding this comment

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

| Metadata | Description |
|:--|:--|
| Pack | The file that this item represents should be included in the package. For items of type `Content` this defaults to the value of the `IncludeContentInPack` property. For all other item types, this defaults to `false`. |
| PackagePath | The path within the package that the file will be located. For items of type `Content`, this defaults to `content\;contentFiles\any\any\`. For all other items types, there is no default value. |
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm too lazy to edit the PR right now, but I think it would be worthwhile mentioning that this metadata allows package authors to put any file in any location in the package, even ones that are not part of any NuGet convention.

@zivkan zivkan marked this pull request as draft June 25, 2024 23:16
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.

2 participants