dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI

Home Page:https://dot.net/core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide a map file generation to use for remove unused references functionality

ivanbasov opened this issue · comments

This task is a part of dotnet/roslyn#6763

The build team will generate a file with a map of assemblies, packages which can be checked for usage/non-usage. MS Build will generated the file. If other environments are used, they have to provide this file on their own.

@nguerrera and @livarcocc please help with scheduling.

@rainersigwald please help with scheduling.

A proposal for what the mapping could look like.

<Build ProjectPath="">
  <Projects>
    <Project Path="" IsRuntimeRequired="">
      <References>
        <ProjectReference Path="" />
        <PackageReference Name="" Version="" />
        <SdkReference Name="" />
        <FrameworkReference Name="" Version="" />
        <AssemblyReference AssemblyName="" />
      </References>
    </Project>
  </Projects>
  <Packages>
    <Package Name="" Version="" IsRuntimeRequired="">
      <References>
        <PackageReference Name="" Version="" />
        <AssemblyReference AssemblyName="" />
      </References>
  </Packages>
  <Sdks>
    <Sdk Name="" IsRuntimeRequired="">
      <References>
        <AssemblyReference AssemblyName="" />
      </References>
  </Sdks>
  <Frameworks>
    <Framework Name="" Version="" IsRuntimeRequired="">
      <References>
        <AssemblyReference AssemblyName="" />
      </References>
    </Framework>
  </Frameworks>
  <Assemblies>
    <Assembly AssemblyName="" Path="" IsRuntimeRequired="" />
  </Assemblies>
</Build>

Updated to include IsRuntimeRequired property which is used to indicate a reference is knowingly unused at compile time but necessary at runtime.

When we discussed this last time, this was going to be some metadata on the resulting resolved reference that pointed back to the original item spec + original item type. We would use the same data for when you copied a reference from one project to another or used a code fix to install a reference from another project.

Will this file contain assembyrefs that were walked as part of compilation but never ended up in the output assembly? So for example an assembly that only has type forwards?

Update: There is an effort to see if the data needed for this can be pulled from the project.assets.json file so a map may not be needed from the SDK. We'll keep an eye on that and update this issue if that ends up being the case.

@marcpopMSFT - do you have any update for the effort?

Adding @JonDouglas and @aortiz-msft to see if they recall if any effort on the nuget side for this made progress.