dotnet / project-system

The .NET Project System for Visual Studio
MIT License
959 stars 386 forks source link

Support TargetPath and Link metadata on CopyToOutputDirectory items in Properties window #9419

Open drewnoakes opened 3 months ago

drewnoakes commented 3 months ago

Any browse object rule that defines editable CopyToOutputDirectory metadata should also have TargetPath and possibly Link.

This will allow users to modify these values from the properties tool window in VS.

From https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-item-metadata:

The Visual Studio project system uses Link metadata (if present) to alter what shows up in the project tree; you can put a file in a different logical folder structure in Solution Explorer.

In addition, the AssignTargetPath task looks at Link to determine where in the output directory to copy a file to, if it’s one of the items that gets copied.

From https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items:

TargetPath is the output path (relative to the configuration- and/or platform-specific output directory) of an item, including the filename. This respects the Link metadata, if provided. If TargetPath isn't provided, it's computed during the build process. See AssignTargetPath.