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

Infer <Link> missing attributes for files outside of project root #5765

Open
danmoseley opened this issue Jan 3, 2020 · 5 comments
Open
Labels
Feature Request Request for a new feature, or new scenario to be handled. Feature-Project-File-Simplification Related to cleaning up and simplification of the project format. Triage-Investigate Reviewed and investigation needed by dev team
Milestone

Comments

@danmoseley
Copy link
Member

danmoseley commented Jan 3, 2020

Visual Studio Version:
16.4.1

Summary:
Right now, if a project contains a file outside of the project file's subtree, it is displayed as if it was in the project folder. If there are more than a few of these, one likely wants them to be in some kind of structure and right now that can only be achieved by manually adding many "Link" attributes.

Eg., in a project we have ~50 entries like this. In this case it happens the paths are <repo-root>\src\Common\Interop\... and the project is in <repo-root>\src\Microsoft.Win32.SystemEvents

    <Compile Include="$(CommonPath)\Interop\Windows\Interop.Errors.cs">
      <Link>Common\Interop\Windows\Interop.Errors.cs</Link>
    </Compile>
    <Compile Include="$(CommonPath)\Interop\Windows\User32\Interop.Constants.cs">
      <Link>Common\Interop\Windows\User32\Interop.Constants.cs</Link>
    </Compile>

etc. It makes no difference whether Link is an attribute or an element - you can see how this is a burden to write, maintain, and it adds noise to the project and changes to it. But what is being done here is so mechanical. Can we improve the heuristic so that we can use Link less?

Perhaps if Link is not present, instead of "put everything at the root" we could use a heuristic like "remove any prefix common to the project path, then represent remainder". In this case, there is a common prefix: <repo-root>\src. Removing that and representing the rest would put the files in the solution explorer inside Common\Interop\Windows, which is what we want in this case.

@drewnoakes
Copy link
Member

Does MSBuild currently need this metadata, or is it just for VS?

@jkotas
Copy link
Member

jkotas commented Jan 3, 2020

Build does not need this metadata, it is just for VS.

@jjmew jjmew added Feature Request Request for a new feature, or new scenario to be handled. Triage-Investigate Reviewed and investigation needed by dev team labels Jan 6, 2020
@jjmew jjmew added this to the Backlog milestone Jan 6, 2020
@jjmew jjmew added the Feature-Project-File-Simplification Related to cleaning up and simplification of the project format. label Jan 6, 2020
@danmoseley
Copy link
Member Author

@davkean
Copy link
Member

davkean commented Feb 19, 2020

@danmosemsft We have LinkBase support which will simplify this:

    <ItemGroup>
        <Compile Include="..\..\System\Numerics\**\*.cs" LinkBase="System\Numerics" />
    </ItemGroup>

It works with Update, so you should be able to write something like the following that will prevent you from needing to opt into globs for the include if you want to explicitly pick individual source files:

    <ItemGroup>
        <Compile Include="..\..\System\Numerics\Vector.cs" />	
	<Compile Update="..\..\System\Numerics\**\*.cs" LinkBase="System\Numerics" />
    </ItemGroup>

I'll leave this open to track maybe being smarter about this, but I think LinkBase is a pretty good workaround.

@davkean
Copy link
Member

davkean commented Feb 19, 2020

Playing around with this, we do already support this via globs, just not individual items.

The following:

  <ItemGroup>
    <Compile Include="..\Common\**\*.cs" />
  </ItemGroup>

Results in a tree like:

image

Going deeper into the tree:

  <ItemGroup>
    <Compile Include="..\Common\VS\**\*.cs" />
  </ItemGroup>

Results in:

image

You can actually make use of this to do this individual items by globbing (I don't want to see what this does to evaluation time!).

<Compile Include="$(CommonPath)\**\Interop.Errors.cs">

This will result in Interop\Native becoming the LinkBase.

I'll leave this open, but this bug basically becomes "do something smarter with individual includes".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request Request for a new feature, or new scenario to be handled. Feature-Project-File-Simplification Related to cleaning up and simplification of the project format. Triage-Investigate Reviewed and investigation needed by dev team
Projects
None yet
Development

No branches or pull requests

5 participants