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

Annotate RAR SearchPaths added because they're "next to a reference" #9700

Merged
merged 15 commits into from
Feb 7, 2024

Conversation

surayya-MS
Copy link
Member

@surayya-MS surayya-MS commented Feb 1, 2024

Fixes #9408

Context

When building this project from a Developer Command Prompt:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="$(DevEnvDir)\..\..\MSBuild\Current\Bin\Microsoft.Build.dll" />
    <Reference Include="Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </ItemGroup>

</Project>

That produces this RAR snippet for Framework:

Primary reference "Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". (TaskId:59)
    Resolved file path is "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Microsoft.Build.Framework.dll". (TaskId:59)
    Reference found at search path location "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin". (TaskId:59)
        For SearchPath "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin". (TaskId:59)
        Considered "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Microsoft.Build.Framework.winmd", but it didn't exist. (TaskId:59)

Changes Made

When calculating resolvers to resolve a reference we currently adding DirectoryResolvers for each directories of the reference's dependees:

var parentReferenceFolders = new List<string>();
foreach (Reference parentReference in reference.GetDependees())
{
CalculateParentAssemblyDirectories(parentReferenceFolders, parentReference);
}

Added ParentAssembly property to the Resolver to save that info to log it later for searchpath.
Added new type of log message for this specific case:

For SearchPath {searchPath}" (added by referencing assembly {parentAssemly}).

Now same example produces:

Primary reference "Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". (TaskId:21)
      Resolved file path is "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Microsoft.Build.Framework.dll". (TaskId:21)
      Reference found at search path location "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin". (TaskId:21)
          For SearchPath "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin" (added by referencing assembly "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Microsoft.Build.dll"). (TaskId:21)
          Considered "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\Microsoft.Build.Framework.winmd", but it didn't exist. (TaskId:21)

Testing

Unit test for new log message and manual test

Notes

@surayya-MS surayya-MS marked this pull request as ready for review February 6, 2024 12:42
src/Tasks/AssemblyDependency/Resolver.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@rokonec rokonec left a comment

Choose a reason for hiding this comment

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

Please consider changing value tuple (string, string) to readonly record struct for maintanability purposes

@surayya-MS surayya-MS merged commit bc11c1b into dotnet:main Feb 7, 2024
8 checks passed
@surayya-MS surayya-MS deleted the rar-log-searchPath-added branch February 7, 2024 15:36
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.

Annotate RAR SearchPaths added because they're "next to a reference"
4 participants